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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
800 | vinala/kernel | src/Http/Router/Route.php | Route.getResourceName | private function getResourceName($url, $target)
{
switch ($target) {
case 'index':
return [$url, $url.'/index'];
break;
case 'show':
return [$url.'/show/{param}'];
break;
case 'add':
return [$url.'/add'];
break;
case 'insert':
return [$url.'/insert'];
break;
case 'edit':
return [$url.'/edit/{param}'];
break;
case 'update':
return [$url.'/update', $url.'/update/{param}'];
break;
case 'update':
return [$url.'/delete/{param}'];
break;
}
} | php | private function getResourceName($url, $target)
{
switch ($target) {
case 'index':
return [$url, $url.'/index'];
break;
case 'show':
return [$url.'/show/{param}'];
break;
case 'add':
return [$url.'/add'];
break;
case 'insert':
return [$url.'/insert'];
break;
case 'edit':
return [$url.'/edit/{param}'];
break;
case 'update':
return [$url.'/update', $url.'/update/{param}'];
break;
case 'update':
return [$url.'/delete/{param}'];
break;
}
} | [
"private",
"function",
"getResourceName",
"(",
"$",
"url",
",",
"$",
"target",
")",
"{",
"switch",
"(",
"$",
"target",
")",
"{",
"case",
"'index'",
":",
"return",
"[",
"$",
"url",
",",
"$",
"url",
".",
"'/index'",
"]",
";",
"break",
";",
"case",
"'show'",
":",
"return",
"[",
"$",
"url",
".",
"'/show/{param}'",
"]",
";",
"break",
";",
"case",
"'add'",
":",
"return",
"[",
"$",
"url",
".",
"'/add'",
"]",
";",
"break",
";",
"case",
"'insert'",
":",
"return",
"[",
"$",
"url",
".",
"'/insert'",
"]",
";",
"break",
";",
"case",
"'edit'",
":",
"return",
"[",
"$",
"url",
".",
"'/edit/{param}'",
"]",
";",
"break",
";",
"case",
"'update'",
":",
"return",
"[",
"$",
"url",
".",
"'/update'",
",",
"$",
"url",
".",
"'/update/{param}'",
"]",
";",
"break",
";",
"case",
"'update'",
":",
"return",
"[",
"$",
"url",
".",
"'/delete/{param}'",
"]",
";",
"break",
";",
"}",
"}"
] | Get the resource name.
@param string $url
@param string $target
@return array | [
"Get",
"the",
"resource",
"name",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L470-L501 |
801 | vinala/kernel | src/Http/Router/Route.php | Route.getResourceClosure | private function getResourceClosure($controller, $method)
{
if ($method == 'show' || $method == 'edit' || $method == 'delete') {
return function ($id) use ($controller, $method) {
return $controller::$method($id);
};
} elseif ($method == 'update') {
return function ($request, $id) use ($controller, $method) {
return $controller::$method($request, $id);
};
} elseif ($method == 'insert') {
return function ($request) use ($controller, $method) {
return $controller::$method($request);
};
} else {
return function () use ($controller, $method) {
return $controller::$method();
};
}
} | php | private function getResourceClosure($controller, $method)
{
if ($method == 'show' || $method == 'edit' || $method == 'delete') {
return function ($id) use ($controller, $method) {
return $controller::$method($id);
};
} elseif ($method == 'update') {
return function ($request, $id) use ($controller, $method) {
return $controller::$method($request, $id);
};
} elseif ($method == 'insert') {
return function ($request) use ($controller, $method) {
return $controller::$method($request);
};
} else {
return function () use ($controller, $method) {
return $controller::$method();
};
}
} | [
"private",
"function",
"getResourceClosure",
"(",
"$",
"controller",
",",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"==",
"'show'",
"||",
"$",
"method",
"==",
"'edit'",
"||",
"$",
"method",
"==",
"'delete'",
")",
"{",
"return",
"function",
"(",
"$",
"id",
")",
"use",
"(",
"$",
"controller",
",",
"$",
"method",
")",
"{",
"return",
"$",
"controller",
"::",
"$",
"method",
"(",
"$",
"id",
")",
";",
"}",
";",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'update'",
")",
"{",
"return",
"function",
"(",
"$",
"request",
",",
"$",
"id",
")",
"use",
"(",
"$",
"controller",
",",
"$",
"method",
")",
"{",
"return",
"$",
"controller",
"::",
"$",
"method",
"(",
"$",
"request",
",",
"$",
"id",
")",
";",
"}",
";",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'insert'",
")",
"{",
"return",
"function",
"(",
"$",
"request",
")",
"use",
"(",
"$",
"controller",
",",
"$",
"method",
")",
"{",
"return",
"$",
"controller",
"::",
"$",
"method",
"(",
"$",
"request",
")",
";",
"}",
";",
"}",
"else",
"{",
"return",
"function",
"(",
")",
"use",
"(",
"$",
"controller",
",",
"$",
"method",
")",
"{",
"return",
"$",
"controller",
"::",
"$",
"method",
"(",
")",
";",
"}",
";",
"}",
"}"
] | Return a resource closure for resource route.
@param string $controller
@param string $methode
@return Closure | [
"Return",
"a",
"resource",
"closure",
"for",
"resource",
"route",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L524-L543 |
802 | vinala/kernel | src/Http/Router/Route.php | Route.setResource | private function setResource($url, $route, $controller, $target)
{
$url = $url.$route;
$route = new self($url);
$closure = $this->getResourceClosure($controller, $target);
$route->setClosure($closure);
$route->setMethod('resource');
$route->setTarget($controller, $target);
$this->addResource($route);
$route->add();
return $route;
} | php | private function setResource($url, $route, $controller, $target)
{
$url = $url.$route;
$route = new self($url);
$closure = $this->getResourceClosure($controller, $target);
$route->setClosure($closure);
$route->setMethod('resource');
$route->setTarget($controller, $target);
$this->addResource($route);
$route->add();
return $route;
} | [
"private",
"function",
"setResource",
"(",
"$",
"url",
",",
"$",
"route",
",",
"$",
"controller",
",",
"$",
"target",
")",
"{",
"$",
"url",
"=",
"$",
"url",
".",
"$",
"route",
";",
"$",
"route",
"=",
"new",
"self",
"(",
"$",
"url",
")",
";",
"$",
"closure",
"=",
"$",
"this",
"->",
"getResourceClosure",
"(",
"$",
"controller",
",",
"$",
"target",
")",
";",
"$",
"route",
"->",
"setClosure",
"(",
"$",
"closure",
")",
";",
"$",
"route",
"->",
"setMethod",
"(",
"'resource'",
")",
";",
"$",
"route",
"->",
"setTarget",
"(",
"$",
"controller",
",",
"$",
"target",
")",
";",
"$",
"this",
"->",
"addResource",
"(",
"$",
"route",
")",
";",
"$",
"route",
"->",
"add",
"(",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Set a resource routes.
@param string $url
@param string $route
@param string $controller
@return null | [
"Set",
"a",
"resource",
"routes",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L568-L585 |
803 | vinala/kernel | src/Http/Router/Route.php | Route.only | public function only()
{
$targets = func_get_args();
$result = [];
foreach ($this->targets as $method) {
if (in_array($method, $targets)) {
array_push($result, $method);
} else {
if (!is_null($this->getResourceName($this->name, $method))) {
foreach ($this->getResourceName($this->name, $method) as $resource) {
if (array_has($this->resources, $resource)) {
$this->resources[$resource]->delete();
unset($this->resources[$resource]);
}
}
}
}
}
$this->targets = $result;
return $this;
} | php | public function only()
{
$targets = func_get_args();
$result = [];
foreach ($this->targets as $method) {
if (in_array($method, $targets)) {
array_push($result, $method);
} else {
if (!is_null($this->getResourceName($this->name, $method))) {
foreach ($this->getResourceName($this->name, $method) as $resource) {
if (array_has($this->resources, $resource)) {
$this->resources[$resource]->delete();
unset($this->resources[$resource]);
}
}
}
}
}
$this->targets = $result;
return $this;
} | [
"public",
"function",
"only",
"(",
")",
"{",
"$",
"targets",
"=",
"func_get_args",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"targets",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"method",
",",
"$",
"targets",
")",
")",
"{",
"array_push",
"(",
"$",
"result",
",",
"$",
"method",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getResourceName",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"method",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getResourceName",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"method",
")",
"as",
"$",
"resource",
")",
"{",
"if",
"(",
"array_has",
"(",
"$",
"this",
"->",
"resources",
",",
"$",
"resource",
")",
")",
"{",
"$",
"this",
"->",
"resources",
"[",
"$",
"resource",
"]",
"->",
"delete",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"resources",
"[",
"$",
"resource",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"targets",
"=",
"$",
"result",
";",
"return",
"$",
"this",
";",
"}"
] | Choose the resource methods to work.
@return Route | [
"Choose",
"the",
"resource",
"methods",
"to",
"work",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L690-L715 |
804 | dekuan/deuclientpro | src/UCProSession.php | UCProSession.checkSessionByRPC | public function checkSessionByRPC( $objParam, & $nCheckReturn = null )
{
if ( ! CLib::IsObjectWithProperties( $objParam,
[
UCProConst::CKX_MID,
UCProConst::CKT_SS_ID,
UCProConst::CKT_SS_URL,
'cookie_array'
] ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM;
}
// ...
$nRet = UCProError::UCPROSESSION_CHECKSESSIONBYRPC_FAILURE;
$nCheckReturn = CConst::ERROR_UNKNOWN;
// ...
$sMId = $objParam->{ UCProConst::CKX_MID };
$sSessionId = $objParam->{ UCProConst::CKT_SS_ID };
$sSessionUrl = $objParam->{ UCProConst::CKT_SS_URL };
$arrCookie = $objParam->{ 'cookie_array' };
if ( ! CLib::IsExistingString( $sMId, true ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_MID;
}
if ( ! CLib::IsExistingString( $sSessionId, true ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_ID;
}
if ( ! CLib::IsExistingString( $sSessionUrl, true ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_URL;
}
if ( false === filter_var( $sSessionUrl, FILTER_VALIDATE_URL ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_URL2;
}
// ...
$nTimeout = 5;
$cRequest = CRequest::GetInstance();
$arrResponse = [];
$nCall = $cRequest->Get
(
[
'url' => $sSessionUrl,
'data' => [
UCProConst::CKX_MID => $sMId,
UCProConst::CKT_SS_ID => $sSessionId,
],
'version' => '1.0', // required version of service
'timeout' => $nTimeout, // timeout in seconds
'cookie' => $arrCookie,
],
$arrResponse
);
if ( CConst::ERROR_SUCCESS == $nCall )
{
if ( CVData::GetInstance()->IsValidVData( $arrResponse ) )
{
// ...
$nRet = UCProError::SUCCESS;
$nCheckReturn = $arrResponse[ 'errorid' ];
}
else
{
$nRet = UCProError::UCPROSESSION_CHECKSESSIONBYRPC_INVALID_VDATA;
}
}
else
{
$nRet = $nCall;
}
// ...
return $nRet;
} | php | public function checkSessionByRPC( $objParam, & $nCheckReturn = null )
{
if ( ! CLib::IsObjectWithProperties( $objParam,
[
UCProConst::CKX_MID,
UCProConst::CKT_SS_ID,
UCProConst::CKT_SS_URL,
'cookie_array'
] ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM;
}
// ...
$nRet = UCProError::UCPROSESSION_CHECKSESSIONBYRPC_FAILURE;
$nCheckReturn = CConst::ERROR_UNKNOWN;
// ...
$sMId = $objParam->{ UCProConst::CKX_MID };
$sSessionId = $objParam->{ UCProConst::CKT_SS_ID };
$sSessionUrl = $objParam->{ UCProConst::CKT_SS_URL };
$arrCookie = $objParam->{ 'cookie_array' };
if ( ! CLib::IsExistingString( $sMId, true ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_MID;
}
if ( ! CLib::IsExistingString( $sSessionId, true ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_ID;
}
if ( ! CLib::IsExistingString( $sSessionUrl, true ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_URL;
}
if ( false === filter_var( $sSessionUrl, FILTER_VALIDATE_URL ) )
{
return UCProError::UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_URL2;
}
// ...
$nTimeout = 5;
$cRequest = CRequest::GetInstance();
$arrResponse = [];
$nCall = $cRequest->Get
(
[
'url' => $sSessionUrl,
'data' => [
UCProConst::CKX_MID => $sMId,
UCProConst::CKT_SS_ID => $sSessionId,
],
'version' => '1.0', // required version of service
'timeout' => $nTimeout, // timeout in seconds
'cookie' => $arrCookie,
],
$arrResponse
);
if ( CConst::ERROR_SUCCESS == $nCall )
{
if ( CVData::GetInstance()->IsValidVData( $arrResponse ) )
{
// ...
$nRet = UCProError::SUCCESS;
$nCheckReturn = $arrResponse[ 'errorid' ];
}
else
{
$nRet = UCProError::UCPROSESSION_CHECKSESSIONBYRPC_INVALID_VDATA;
}
}
else
{
$nRet = $nCall;
}
// ...
return $nRet;
} | [
"public",
"function",
"checkSessionByRPC",
"(",
"$",
"objParam",
",",
"&",
"$",
"nCheckReturn",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"CLib",
"::",
"IsObjectWithProperties",
"(",
"$",
"objParam",
",",
"[",
"UCProConst",
"::",
"CKX_MID",
",",
"UCProConst",
"::",
"CKT_SS_ID",
",",
"UCProConst",
"::",
"CKT_SS_URL",
",",
"'cookie_array'",
"]",
")",
")",
"{",
"return",
"UCProError",
"::",
"UCPROSESSION_CHECKSESSIONBYRPC_PARAM",
";",
"}",
"//\t...",
"$",
"nRet",
"=",
"UCProError",
"::",
"UCPROSESSION_CHECKSESSIONBYRPC_FAILURE",
";",
"$",
"nCheckReturn",
"=",
"CConst",
"::",
"ERROR_UNKNOWN",
";",
"//\t...",
"$",
"sMId",
"=",
"$",
"objParam",
"->",
"{",
"UCProConst",
"::",
"CKX_MID",
"}",
";",
"$",
"sSessionId",
"=",
"$",
"objParam",
"->",
"{",
"UCProConst",
"::",
"CKT_SS_ID",
"}",
";",
"$",
"sSessionUrl",
"=",
"$",
"objParam",
"->",
"{",
"UCProConst",
"::",
"CKT_SS_URL",
"}",
";",
"$",
"arrCookie",
"=",
"$",
"objParam",
"->",
"{",
"'cookie_array'",
"}",
";",
"if",
"(",
"!",
"CLib",
"::",
"IsExistingString",
"(",
"$",
"sMId",
",",
"true",
")",
")",
"{",
"return",
"UCProError",
"::",
"UCPROSESSION_CHECKSESSIONBYRPC_PARAM_MID",
";",
"}",
"if",
"(",
"!",
"CLib",
"::",
"IsExistingString",
"(",
"$",
"sSessionId",
",",
"true",
")",
")",
"{",
"return",
"UCProError",
"::",
"UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_ID",
";",
"}",
"if",
"(",
"!",
"CLib",
"::",
"IsExistingString",
"(",
"$",
"sSessionUrl",
",",
"true",
")",
")",
"{",
"return",
"UCProError",
"::",
"UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_URL",
";",
"}",
"if",
"(",
"false",
"===",
"filter_var",
"(",
"$",
"sSessionUrl",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"return",
"UCProError",
"::",
"UCPROSESSION_CHECKSESSIONBYRPC_PARAM_SS_URL2",
";",
"}",
"//\t...",
"$",
"nTimeout",
"=",
"5",
";",
"$",
"cRequest",
"=",
"CRequest",
"::",
"GetInstance",
"(",
")",
";",
"$",
"arrResponse",
"=",
"[",
"]",
";",
"$",
"nCall",
"=",
"$",
"cRequest",
"->",
"Get",
"(",
"[",
"'url'",
"=>",
"$",
"sSessionUrl",
",",
"'data'",
"=>",
"[",
"UCProConst",
"::",
"CKX_MID",
"=>",
"$",
"sMId",
",",
"UCProConst",
"::",
"CKT_SS_ID",
"=>",
"$",
"sSessionId",
",",
"]",
",",
"'version'",
"=>",
"'1.0'",
",",
"//\trequired version of service",
"'timeout'",
"=>",
"$",
"nTimeout",
",",
"//\ttimeout in seconds",
"'cookie'",
"=>",
"$",
"arrCookie",
",",
"]",
",",
"$",
"arrResponse",
")",
";",
"if",
"(",
"CConst",
"::",
"ERROR_SUCCESS",
"==",
"$",
"nCall",
")",
"{",
"if",
"(",
"CVData",
"::",
"GetInstance",
"(",
")",
"->",
"IsValidVData",
"(",
"$",
"arrResponse",
")",
")",
"{",
"//\t...",
"$",
"nRet",
"=",
"UCProError",
"::",
"SUCCESS",
";",
"$",
"nCheckReturn",
"=",
"$",
"arrResponse",
"[",
"'errorid'",
"]",
";",
"}",
"else",
"{",
"$",
"nRet",
"=",
"UCProError",
"::",
"UCPROSESSION_CHECKSESSIONBYRPC_INVALID_VDATA",
";",
"}",
"}",
"else",
"{",
"$",
"nRet",
"=",
"$",
"nCall",
";",
"}",
"//\t...",
"return",
"$",
"nRet",
";",
"}"
] | check session from remote server
@param object $objParam
@param int $nCheckReturn
@return bool | [
"check",
"session",
"from",
"remote",
"server"
] | 56f39ad0efc023d7e069f34df1f15e4324fca84e | https://github.com/dekuan/deuclientpro/blob/56f39ad0efc023d7e069f34df1f15e4324fca84e/src/UCProSession.php#L47-L125 |
805 | CampaignChain/channel-linkedin | REST/LinkedInClientService.php | LinkedInClientService.shareOnCompanyPage | public function shareOnCompanyPage(Activity $activity, array $content)
{
$id = $activity->getLocation()->getIdentifier();
return $this->connect->request(
'POST',
'companies/'.$id.'/shares',
[
'headers' => [
'x-li-format' => 'json',
],
'body' => json_encode($content),
'query' => [
'format' => 'json',
]
]
);
} | php | public function shareOnCompanyPage(Activity $activity, array $content)
{
$id = $activity->getLocation()->getIdentifier();
return $this->connect->request(
'POST',
'companies/'.$id.'/shares',
[
'headers' => [
'x-li-format' => 'json',
],
'body' => json_encode($content),
'query' => [
'format' => 'json',
]
]
);
} | [
"public",
"function",
"shareOnCompanyPage",
"(",
"Activity",
"$",
"activity",
",",
"array",
"$",
"content",
")",
"{",
"$",
"id",
"=",
"$",
"activity",
"->",
"getLocation",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"return",
"$",
"this",
"->",
"connect",
"->",
"request",
"(",
"'POST'",
",",
"'companies/'",
".",
"$",
"id",
".",
"'/shares'",
",",
"[",
"'headers'",
"=>",
"[",
"'x-li-format'",
"=>",
"'json'",
",",
"]",
",",
"'body'",
"=>",
"json_encode",
"(",
"$",
"content",
")",
",",
"'query'",
"=>",
"[",
"'format'",
"=>",
"'json'",
",",
"]",
"]",
")",
";",
"}"
] | Share a news on a company page
@param Activity $activity
@param string $content
@return array | [
"Share",
"a",
"news",
"on",
"a",
"company",
"page"
] | f3a52c78e719ab888f237dd8b99ab429350f3113 | https://github.com/CampaignChain/channel-linkedin/blob/f3a52c78e719ab888f237dd8b99ab429350f3113/REST/LinkedInClientService.php#L92-L109 |
806 | CampaignChain/channel-linkedin | REST/LinkedInClientService.php | LinkedInClientService.getCompanyUpdate | public function getCompanyUpdate(Activity $activity, NewsItem $newsItem)
{
$id = $activity->getLocation()->getIdentifier();
return $this->connect->request(
'GET',
'companies/'.$id.'/updates/key='.$newsItem->getUpdateKey(),
[
'query' => [
'format' => 'json',
]
]
);
} | php | public function getCompanyUpdate(Activity $activity, NewsItem $newsItem)
{
$id = $activity->getLocation()->getIdentifier();
return $this->connect->request(
'GET',
'companies/'.$id.'/updates/key='.$newsItem->getUpdateKey(),
[
'query' => [
'format' => 'json',
]
]
);
} | [
"public",
"function",
"getCompanyUpdate",
"(",
"Activity",
"$",
"activity",
",",
"NewsItem",
"$",
"newsItem",
")",
"{",
"$",
"id",
"=",
"$",
"activity",
"->",
"getLocation",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"return",
"$",
"this",
"->",
"connect",
"->",
"request",
"(",
"'GET'",
",",
"'companies/'",
".",
"$",
"id",
".",
"'/updates/key='",
".",
"$",
"newsItem",
"->",
"getUpdateKey",
"(",
")",
",",
"[",
"'query'",
"=>",
"[",
"'format'",
"=>",
"'json'",
",",
"]",
"]",
")",
";",
"}"
] | Get a company update statistics
@param Activity $activity
@param NewsItem $newsItem
@return array | [
"Get",
"a",
"company",
"update",
"statistics"
] | f3a52c78e719ab888f237dd8b99ab429350f3113 | https://github.com/CampaignChain/channel-linkedin/blob/f3a52c78e719ab888f237dd8b99ab429350f3113/REST/LinkedInClientService.php#L142-L155 |
807 | CampaignChain/channel-linkedin | REST/LinkedInClientService.php | LinkedInClientService.getUserUpdate | public function getUserUpdate(Activity $activity, NewsItem $newsItem)
{
//LinkedIn API seems broken, re-enable when it works again.
//return [];
return $this->connect->request(
'GET',
'people/~/network/updates/key='.$newsItem->getUpdateKey(),
[
'query' => [
'format' => 'json',
]
]
);
} | php | public function getUserUpdate(Activity $activity, NewsItem $newsItem)
{
//LinkedIn API seems broken, re-enable when it works again.
//return [];
return $this->connect->request(
'GET',
'people/~/network/updates/key='.$newsItem->getUpdateKey(),
[
'query' => [
'format' => 'json',
]
]
);
} | [
"public",
"function",
"getUserUpdate",
"(",
"Activity",
"$",
"activity",
",",
"NewsItem",
"$",
"newsItem",
")",
"{",
"//LinkedIn API seems broken, re-enable when it works again.",
"//return [];",
"return",
"$",
"this",
"->",
"connect",
"->",
"request",
"(",
"'GET'",
",",
"'people/~/network/updates/key='",
".",
"$",
"newsItem",
"->",
"getUpdateKey",
"(",
")",
",",
"[",
"'query'",
"=>",
"[",
"'format'",
"=>",
"'json'",
",",
"]",
"]",
")",
";",
"}"
] | Get a user update statistics
@param Activity $activity
@param NewsItem $newsItem
@return array | [
"Get",
"a",
"user",
"update",
"statistics"
] | f3a52c78e719ab888f237dd8b99ab429350f3113 | https://github.com/CampaignChain/channel-linkedin/blob/f3a52c78e719ab888f237dd8b99ab429350f3113/REST/LinkedInClientService.php#L164-L178 |
808 | Thuata/FrameworkBundle | Bridge/MongoDB/ConnectionFactory.php | ConnectionFactory.addConnection | public function addConnection(string $name = null, Connection $connection = null): self
{
if (is_null($name)) {
$this->defaultConnection = $connection;
} else {
$this->registry[$name] = $connection;
}
return $this;
} | php | public function addConnection(string $name = null, Connection $connection = null): self
{
if (is_null($name)) {
$this->defaultConnection = $connection;
} else {
$this->registry[$name] = $connection;
}
return $this;
} | [
"public",
"function",
"addConnection",
"(",
"string",
"$",
"name",
"=",
"null",
",",
"Connection",
"$",
"connection",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"defaultConnection",
"=",
"$",
"connection",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"registry",
"[",
"$",
"name",
"]",
"=",
"$",
"connection",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a connection
@param string $name
@param Connection $connection
@return ConnectionFactory | [
"Adds",
"a",
"connection"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Bridge/MongoDB/ConnectionFactory.php#L50-L59 |
809 | Thuata/FrameworkBundle | Bridge/MongoDB/ConnectionFactory.php | ConnectionFactory.getConnection | public function getConnection(string $name = null): Connection
{
if (is_null($name) and !is_null($this->defaultConnection)) {
return $this->defaultConnection;
}
if (is_null($name) or !array_key_exists($name, $this->registry)) {
throw new MongoDBConnectionNameNotFoundException($name);
}
return $this->registry[$name];
} | php | public function getConnection(string $name = null): Connection
{
if (is_null($name) and !is_null($this->defaultConnection)) {
return $this->defaultConnection;
}
if (is_null($name) or !array_key_exists($name, $this->registry)) {
throw new MongoDBConnectionNameNotFoundException($name);
}
return $this->registry[$name];
} | [
"public",
"function",
"getConnection",
"(",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Connection",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
"and",
"!",
"is_null",
"(",
"$",
"this",
"->",
"defaultConnection",
")",
")",
"{",
"return",
"$",
"this",
"->",
"defaultConnection",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
"or",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"registry",
")",
")",
"{",
"throw",
"new",
"MongoDBConnectionNameNotFoundException",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"registry",
"[",
"$",
"name",
"]",
";",
"}"
] | Gets a connection
@param string $name
@return Connection
@throws MongoDBConnectionNameNotFoundException | [
"Gets",
"a",
"connection"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Bridge/MongoDB/ConnectionFactory.php#L70-L81 |
810 | fiedsch/datamanagement | src/Fiedsch/Data/Utility/TokenCreator.php | TokenCreator.initializeTokenCharacters | protected function initializeTokenCharacters()
{
$allowed = 'abcdefghijklmnopqrstuvwxyz';
$allowed .= strtoupper($allowed);
$allowed .= '0123456789';
//$allowed .= '!§$%&?';
$this->tokenChars = str_split($allowed);
shuffle($this->tokenChars);
} | php | protected function initializeTokenCharacters()
{
$allowed = 'abcdefghijklmnopqrstuvwxyz';
$allowed .= strtoupper($allowed);
$allowed .= '0123456789';
//$allowed .= '!§$%&?';
$this->tokenChars = str_split($allowed);
shuffle($this->tokenChars);
} | [
"protected",
"function",
"initializeTokenCharacters",
"(",
")",
"{",
"$",
"allowed",
"=",
"'abcdefghijklmnopqrstuvwxyz'",
";",
"$",
"allowed",
".=",
"strtoupper",
"(",
"$",
"allowed",
")",
";",
"$",
"allowed",
".=",
"'0123456789'",
";",
"//$allowed .= '!§$%&?';",
"$",
"this",
"->",
"tokenChars",
"=",
"str_split",
"(",
"$",
"allowed",
")",
";",
"shuffle",
"(",
"$",
"this",
"->",
"tokenChars",
")",
";",
"}"
] | Initialize the list of characters that are used to create tokens | [
"Initialize",
"the",
"list",
"of",
"characters",
"that",
"are",
"used",
"to",
"create",
"tokens"
] | 06e8000399d46e83f848944b73afecabf619f52b | https://github.com/fiedsch/datamanagement/blob/06e8000399d46e83f848944b73afecabf619f52b/src/Fiedsch/Data/Utility/TokenCreator.php#L82-L90 |
811 | fiedsch/datamanagement | src/Fiedsch/Data/Utility/TokenCreator.php | TokenCreator.getTokenCharacters | protected function getTokenCharacters($count = 1)
{
$result = '';
for ($i = 0; $i < $count; $i++) {
$result .= $this->tokenChars[mt_rand(0, count($this->tokenChars) - 1)];
}
return $result;
} | php | protected function getTokenCharacters($count = 1)
{
$result = '';
for ($i = 0; $i < $count; $i++) {
$result .= $this->tokenChars[mt_rand(0, count($this->tokenChars) - 1)];
}
return $result;
} | [
"protected",
"function",
"getTokenCharacters",
"(",
"$",
"count",
"=",
"1",
")",
"{",
"$",
"result",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"tokenChars",
"[",
"mt_rand",
"(",
"0",
",",
"count",
"(",
"$",
"this",
"->",
"tokenChars",
")",
"-",
"1",
")",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get random characters
@param int $count number of characters to return
@return string | [
"Get",
"random",
"characters"
] | 06e8000399d46e83f848944b73afecabf619f52b | https://github.com/fiedsch/datamanagement/blob/06e8000399d46e83f848944b73afecabf619f52b/src/Fiedsch/Data/Utility/TokenCreator.php#L215-L222 |
812 | 1g0rbm/prettycurl | src/Request/Request.php | Request.getCompleteUrl | private function getCompleteUrl($uri = '')
{
$uri = $uri === '' ? $this->urlResolver->getPath() : $uri;
$url = sprintf('%s%s', $this->urlResolver->getDomain(), $uri);
if ($this->isGet() && $this->GET) {
$url = sprintf('%s?%s', $url, http_build_query($this->GET->getAll()));
}
return $url;
} | php | private function getCompleteUrl($uri = '')
{
$uri = $uri === '' ? $this->urlResolver->getPath() : $uri;
$url = sprintf('%s%s', $this->urlResolver->getDomain(), $uri);
if ($this->isGet() && $this->GET) {
$url = sprintf('%s?%s', $url, http_build_query($this->GET->getAll()));
}
return $url;
} | [
"private",
"function",
"getCompleteUrl",
"(",
"$",
"uri",
"=",
"''",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"===",
"''",
"?",
"$",
"this",
"->",
"urlResolver",
"->",
"getPath",
"(",
")",
":",
"$",
"uri",
";",
"$",
"url",
"=",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"this",
"->",
"urlResolver",
"->",
"getDomain",
"(",
")",
",",
"$",
"uri",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isGet",
"(",
")",
"&&",
"$",
"this",
"->",
"GET",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s?%s'",
",",
"$",
"url",
",",
"http_build_query",
"(",
"$",
"this",
"->",
"GET",
"->",
"getAll",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Get the full url address for the request
@param string $uri
@return string | [
"Get",
"the",
"full",
"url",
"address",
"for",
"the",
"request"
] | afe0bd6e323c4096ae15749848dd19cba38f970a | https://github.com/1g0rbm/prettycurl/blob/afe0bd6e323c4096ae15749848dd19cba38f970a/src/Request/Request.php#L225-L235 |
813 | 1g0rbm/prettycurl | src/Request/Request.php | Request.buildResponse | protected function buildResponse()
{
$this->curl->persist();
$response = $this->curl->exec();
$info = $this->curl->getInfo();
$errors = [
'text' => $this->curl->error(),
'code' => $this->curl->errno()
];
try {
return new Response(new ResponseBuilder($response, $info, $errors), new Filesystem());
} catch (ResponseBuilderException $e) {
throw new RequestException($e->getMessage(), $e->getCode());
}
} | php | protected function buildResponse()
{
$this->curl->persist();
$response = $this->curl->exec();
$info = $this->curl->getInfo();
$errors = [
'text' => $this->curl->error(),
'code' => $this->curl->errno()
];
try {
return new Response(new ResponseBuilder($response, $info, $errors), new Filesystem());
} catch (ResponseBuilderException $e) {
throw new RequestException($e->getMessage(), $e->getCode());
}
} | [
"protected",
"function",
"buildResponse",
"(",
")",
"{",
"$",
"this",
"->",
"curl",
"->",
"persist",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"curl",
"->",
"exec",
"(",
")",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"curl",
"->",
"getInfo",
"(",
")",
";",
"$",
"errors",
"=",
"[",
"'text'",
"=>",
"$",
"this",
"->",
"curl",
"->",
"error",
"(",
")",
",",
"'code'",
"=>",
"$",
"this",
"->",
"curl",
"->",
"errno",
"(",
")",
"]",
";",
"try",
"{",
"return",
"new",
"Response",
"(",
"new",
"ResponseBuilder",
"(",
"$",
"response",
",",
"$",
"info",
",",
"$",
"errors",
")",
",",
"new",
"Filesystem",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ResponseBuilderException",
"$",
"e",
")",
"{",
"throw",
"new",
"RequestException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"}"
] | Construct an instance of the Response based on data received from the server
@return Response
@throws RequestException | [
"Construct",
"an",
"instance",
"of",
"the",
"Response",
"based",
"on",
"data",
"received",
"from",
"the",
"server"
] | afe0bd6e323c4096ae15749848dd19cba38f970a | https://github.com/1g0rbm/prettycurl/blob/afe0bd6e323c4096ae15749848dd19cba38f970a/src/Request/Request.php#L243-L258 |
814 | Dhii/container-helper-base | src/ContainerGetPathCapableTrait.php | ContainerGetPathCapableTrait._containerGetPath | protected function _containerGetPath($container, $path)
{
$path = $this->_normalizeIterable($path);
$service = $container;
foreach ($path as $segment) {
$service = $this->_containerGet($service, $segment);
}
return $service;
} | php | protected function _containerGetPath($container, $path)
{
$path = $this->_normalizeIterable($path);
$service = $container;
foreach ($path as $segment) {
$service = $this->_containerGet($service, $segment);
}
return $service;
} | [
"protected",
"function",
"_containerGetPath",
"(",
"$",
"container",
",",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"_normalizeIterable",
"(",
"$",
"path",
")",
";",
"$",
"service",
"=",
"$",
"container",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"segment",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"_containerGet",
"(",
"$",
"service",
",",
"$",
"segment",
")",
";",
"}",
"return",
"$",
"service",
";",
"}"
] | Retrieves a value from a chain of nested containers by path.
@since [*next-version*]
@param array|ArrayAccess|stdClass|BaseContainerInterface $container The top container in the chain to read from.
@param array|Traversable|stdClass $path The list of path segments.
@throws InvalidArgumentException If one of the containers in the chain is invalid.
@throws ContainerExceptionInterface If an error occurred while reading from one of the containers in the chain.
@throws NotFoundExceptionInterface If one of the containers in the chain does not have the corresponding key.
@return mixed The value at the specified path. | [
"Retrieves",
"a",
"value",
"from",
"a",
"chain",
"of",
"nested",
"containers",
"by",
"path",
"."
] | ccb2f56971d70cf203baa596cd14fdf91be6bfae | https://github.com/Dhii/container-helper-base/blob/ccb2f56971d70cf203baa596cd14fdf91be6bfae/src/ContainerGetPathCapableTrait.php#L35-L46 |
815 | monomelodies/ornament | src/Identify.php | Identify.guessIdentifier | public function guessIdentifier(callable $fn = null)
{
static $guesser;
static $table;
if (isset($table)) {
return $table;
}
if (isset($fn)) {
$guesser = $fn;
}
if (!isset($guesser)) {
$guesser = function ($class) {
$class = preg_replace('@\\\\?Model$@', '', $class);
return Helper::normalize($class);
};
}
$class = get_class($this);
if (strpos($class, '@anonymous') !== false) {
$class = (new ReflectionClass($this))->getParentClass()->name;
}
return $guesser($class);
} | php | public function guessIdentifier(callable $fn = null)
{
static $guesser;
static $table;
if (isset($table)) {
return $table;
}
if (isset($fn)) {
$guesser = $fn;
}
if (!isset($guesser)) {
$guesser = function ($class) {
$class = preg_replace('@\\\\?Model$@', '', $class);
return Helper::normalize($class);
};
}
$class = get_class($this);
if (strpos($class, '@anonymous') !== false) {
$class = (new ReflectionClass($this))->getParentClass()->name;
}
return $guesser($class);
} | [
"public",
"function",
"guessIdentifier",
"(",
"callable",
"$",
"fn",
"=",
"null",
")",
"{",
"static",
"$",
"guesser",
";",
"static",
"$",
"table",
";",
"if",
"(",
"isset",
"(",
"$",
"table",
")",
")",
"{",
"return",
"$",
"table",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fn",
")",
")",
"{",
"$",
"guesser",
"=",
"$",
"fn",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"guesser",
")",
")",
"{",
"$",
"guesser",
"=",
"function",
"(",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"preg_replace",
"(",
"'@\\\\\\\\?Model$@'",
",",
"''",
",",
"$",
"class",
")",
";",
"return",
"Helper",
"::",
"normalize",
"(",
"$",
"class",
")",
";",
"}",
";",
"}",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"class",
",",
"'@anonymous'",
")",
"!==",
"false",
")",
"{",
"$",
"class",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getParentClass",
"(",
")",
"->",
"name",
";",
"}",
"return",
"$",
"guesser",
"(",
"$",
"class",
")",
";",
"}"
] | Return the guesstimated identifier, optionally by using the callback
passed as an argument.
@param callable $fn Optional callback doing the guesstimating.
@return string A guesstimated identifier. | [
"Return",
"the",
"guesstimated",
"identifier",
"optionally",
"by",
"using",
"the",
"callback",
"passed",
"as",
"an",
"argument",
"."
] | d7d070ad11f5731be141cf55c2756accaaf51402 | https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Identify.php#L21-L42 |
816 | tixastronauta/acc-ip | src/TixAstronauta/AccIp/AccIp.php | AccIp.getIpAddress | public function getIpAddress()
{
foreach ($this->headers as $k)
{
if (isset($this->server[$k]))
{
// header can be comma separated
$ips = explode(',', $this->server[$k]);
$ip = trim(end($ips));
$ip = filter_var($ip, FILTER_VALIDATE_IP);
if (false !== $ip)
{
return $ip;
}
}
}
// no valid ip found
return false;
} | php | public function getIpAddress()
{
foreach ($this->headers as $k)
{
if (isset($this->server[$k]))
{
// header can be comma separated
$ips = explode(',', $this->server[$k]);
$ip = trim(end($ips));
$ip = filter_var($ip, FILTER_VALIDATE_IP);
if (false !== $ip)
{
return $ip;
}
}
}
// no valid ip found
return false;
} | [
"public",
"function",
"getIpAddress",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"k",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
"$",
"k",
"]",
")",
")",
"{",
"// header can be comma separated",
"$",
"ips",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"server",
"[",
"$",
"k",
"]",
")",
";",
"$",
"ip",
"=",
"trim",
"(",
"end",
"(",
"$",
"ips",
")",
")",
";",
"$",
"ip",
"=",
"filter_var",
"(",
"$",
"ip",
",",
"FILTER_VALIDATE_IP",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"ip",
")",
"{",
"return",
"$",
"ip",
";",
"}",
"}",
"}",
"// no valid ip found",
"return",
"false",
";",
"}"
] | Returns client's accurate IP Address
@return bool|string ip address, false on failure | [
"Returns",
"client",
"s",
"accurate",
"IP",
"Address"
] | 8c03422aa256ee424633f9a0f758b865a35e39e9 | https://github.com/tixastronauta/acc-ip/blob/8c03422aa256ee424633f9a0f758b865a35e39e9/src/TixAstronauta/AccIp/AccIp.php#L90-L109 |
817 | bishopb/vanilla | applications/dashboard/controllers/class.messagecontroller.php | MessageController.Delete | public function Delete($MessageID = '', $TransientKey = FALSE) {
$this->Permission('Garden.Messages.Manage');
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$Session = Gdn::Session();
if ($TransientKey !== FALSE && $Session->ValidateTransientKey($TransientKey)) {
$Message = $this->MessageModel->Delete(array('MessageID' => $MessageID));
// Reset the message cache
$this->MessageModel->SetMessageCache();
}
if ($this->_DeliveryType === DELIVERY_TYPE_ALL)
Redirect('dashboard/message');
$this->Render();
} | php | public function Delete($MessageID = '', $TransientKey = FALSE) {
$this->Permission('Garden.Messages.Manage');
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$Session = Gdn::Session();
if ($TransientKey !== FALSE && $Session->ValidateTransientKey($TransientKey)) {
$Message = $this->MessageModel->Delete(array('MessageID' => $MessageID));
// Reset the message cache
$this->MessageModel->SetMessageCache();
}
if ($this->_DeliveryType === DELIVERY_TYPE_ALL)
Redirect('dashboard/message');
$this->Render();
} | [
"public",
"function",
"Delete",
"(",
"$",
"MessageID",
"=",
"''",
",",
"$",
"TransientKey",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Messages.Manage'",
")",
";",
"$",
"this",
"->",
"DeliveryType",
"(",
"DELIVERY_TYPE_BOOL",
")",
";",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"$",
"TransientKey",
"!==",
"FALSE",
"&&",
"$",
"Session",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
")",
"{",
"$",
"Message",
"=",
"$",
"this",
"->",
"MessageModel",
"->",
"Delete",
"(",
"array",
"(",
"'MessageID'",
"=>",
"$",
"MessageID",
")",
")",
";",
"// Reset the message cache",
"$",
"this",
"->",
"MessageModel",
"->",
"SetMessageCache",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_DeliveryType",
"===",
"DELIVERY_TYPE_ALL",
")",
"Redirect",
"(",
"'dashboard/message'",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Delete a message.
@since 2.0.0
@access public | [
"Delete",
"a",
"message",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.messagecontroller.php#L43-L58 |
818 | bishopb/vanilla | applications/dashboard/controllers/class.messagecontroller.php | MessageController.Edit | public function Edit($MessageID = '') {
$this->AddJsFile('jquery.autogrow.js');
$this->AddJsFile('messages.js');
$this->Permission('Garden.Messages.Manage');
$this->AddSideMenu('dashboard/message');
// Generate some Controller & Asset data arrays
$this->SetData('Locations', $this->_GetLocationData());
$this->AssetData = $this->_GetAssetData();
// Set the model on the form.
$this->Form->SetModel($this->MessageModel);
$this->Message = $this->MessageModel->GetID($MessageID);
$this->Message = $this->MessageModel->DefineLocation($this->Message);
// Make sure the form knows which item we are editing.
if (is_numeric($MessageID) && $MessageID > 0)
$this->Form->AddHidden('MessageID', $MessageID);
$CategoriesData = CategoryModel::Categories();
$Categories = array();
foreach ($CategoriesData as $Row) {
if ($Row['CategoryID'] < 0)
continue;
$Categories[$Row['CategoryID']] = str_repeat(' ', max(0, $Row['Depth'] - 1)).$Row['Name'];
}
$this->SetData('Categories', $Categories);
// If seeing the form for the first time...
if (!$this->Form->AuthenticatedPostBack()) {
$this->Form->SetData($this->Message);
} else {
if ($MessageID = $this->Form->Save()) {
// Reset the message cache
$this->MessageModel->SetMessageCache();
// Redirect
$this->InformMessage(T('Your changes have been saved.'));
//$this->RedirectUrl = Url('dashboard/message');
}
}
$this->Render();
} | php | public function Edit($MessageID = '') {
$this->AddJsFile('jquery.autogrow.js');
$this->AddJsFile('messages.js');
$this->Permission('Garden.Messages.Manage');
$this->AddSideMenu('dashboard/message');
// Generate some Controller & Asset data arrays
$this->SetData('Locations', $this->_GetLocationData());
$this->AssetData = $this->_GetAssetData();
// Set the model on the form.
$this->Form->SetModel($this->MessageModel);
$this->Message = $this->MessageModel->GetID($MessageID);
$this->Message = $this->MessageModel->DefineLocation($this->Message);
// Make sure the form knows which item we are editing.
if (is_numeric($MessageID) && $MessageID > 0)
$this->Form->AddHidden('MessageID', $MessageID);
$CategoriesData = CategoryModel::Categories();
$Categories = array();
foreach ($CategoriesData as $Row) {
if ($Row['CategoryID'] < 0)
continue;
$Categories[$Row['CategoryID']] = str_repeat(' ', max(0, $Row['Depth'] - 1)).$Row['Name'];
}
$this->SetData('Categories', $Categories);
// If seeing the form for the first time...
if (!$this->Form->AuthenticatedPostBack()) {
$this->Form->SetData($this->Message);
} else {
if ($MessageID = $this->Form->Save()) {
// Reset the message cache
$this->MessageModel->SetMessageCache();
// Redirect
$this->InformMessage(T('Your changes have been saved.'));
//$this->RedirectUrl = Url('dashboard/message');
}
}
$this->Render();
} | [
"public",
"function",
"Edit",
"(",
"$",
"MessageID",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.autogrow.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'messages.js'",
")",
";",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Messages.Manage'",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'dashboard/message'",
")",
";",
"// Generate some Controller & Asset data arrays",
"$",
"this",
"->",
"SetData",
"(",
"'Locations'",
",",
"$",
"this",
"->",
"_GetLocationData",
"(",
")",
")",
";",
"$",
"this",
"->",
"AssetData",
"=",
"$",
"this",
"->",
"_GetAssetData",
"(",
")",
";",
"// Set the model on the form.",
"$",
"this",
"->",
"Form",
"->",
"SetModel",
"(",
"$",
"this",
"->",
"MessageModel",
")",
";",
"$",
"this",
"->",
"Message",
"=",
"$",
"this",
"->",
"MessageModel",
"->",
"GetID",
"(",
"$",
"MessageID",
")",
";",
"$",
"this",
"->",
"Message",
"=",
"$",
"this",
"->",
"MessageModel",
"->",
"DefineLocation",
"(",
"$",
"this",
"->",
"Message",
")",
";",
"// Make sure the form knows which item we are editing.",
"if",
"(",
"is_numeric",
"(",
"$",
"MessageID",
")",
"&&",
"$",
"MessageID",
">",
"0",
")",
"$",
"this",
"->",
"Form",
"->",
"AddHidden",
"(",
"'MessageID'",
",",
"$",
"MessageID",
")",
";",
"$",
"CategoriesData",
"=",
"CategoryModel",
"::",
"Categories",
"(",
")",
";",
"$",
"Categories",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"CategoriesData",
"as",
"$",
"Row",
")",
"{",
"if",
"(",
"$",
"Row",
"[",
"'CategoryID'",
"]",
"<",
"0",
")",
"continue",
";",
"$",
"Categories",
"[",
"$",
"Row",
"[",
"'CategoryID'",
"]",
"]",
"=",
"str_repeat",
"(",
"' '",
",",
"max",
"(",
"0",
",",
"$",
"Row",
"[",
"'Depth'",
"]",
"-",
"1",
")",
")",
".",
"$",
"Row",
"[",
"'Name'",
"]",
";",
"}",
"$",
"this",
"->",
"SetData",
"(",
"'Categories'",
",",
"$",
"Categories",
")",
";",
"// If seeing the form for the first time...",
"if",
"(",
"!",
"$",
"this",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
")",
"{",
"$",
"this",
"->",
"Form",
"->",
"SetData",
"(",
"$",
"this",
"->",
"Message",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"MessageID",
"=",
"$",
"this",
"->",
"Form",
"->",
"Save",
"(",
")",
")",
"{",
"// Reset the message cache",
"$",
"this",
"->",
"MessageModel",
"->",
"SetMessageCache",
"(",
")",
";",
"// Redirect",
"$",
"this",
"->",
"InformMessage",
"(",
"T",
"(",
"'Your changes have been saved.'",
")",
")",
";",
"//$this->RedirectUrl = Url('dashboard/message');",
"}",
"}",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Form to edit an existing message.
@since 2.0.0
@access public | [
"Form",
"to",
"edit",
"an",
"existing",
"message",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.messagecontroller.php#L87-L131 |
819 | bishopb/vanilla | applications/dashboard/controllers/class.messagecontroller.php | MessageController.Index | public function Index() {
$this->Permission('Garden.Messages.Manage');
$this->AddSideMenu('dashboard/message');
$this->AddJsFile('jquery.autogrow.js');
$this->AddJsFile('jquery.tablednd.js');
$this->AddJsFile('jquery-ui.js');
$this->AddJsFile('messages.js');
$this->Title(T('Messages'));
// Load all messages from the db
$this->MessageData = $this->MessageModel->Get('Sort');
$this->Render();
} | php | public function Index() {
$this->Permission('Garden.Messages.Manage');
$this->AddSideMenu('dashboard/message');
$this->AddJsFile('jquery.autogrow.js');
$this->AddJsFile('jquery.tablednd.js');
$this->AddJsFile('jquery-ui.js');
$this->AddJsFile('messages.js');
$this->Title(T('Messages'));
// Load all messages from the db
$this->MessageData = $this->MessageModel->Get('Sort');
$this->Render();
} | [
"public",
"function",
"Index",
"(",
")",
"{",
"$",
"this",
"->",
"Permission",
"(",
"'Garden.Messages.Manage'",
")",
";",
"$",
"this",
"->",
"AddSideMenu",
"(",
"'dashboard/message'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.autogrow.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.tablednd.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery-ui.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'messages.js'",
")",
";",
"$",
"this",
"->",
"Title",
"(",
"T",
"(",
"'Messages'",
")",
")",
";",
"// Load all messages from the db",
"$",
"this",
"->",
"MessageData",
"=",
"$",
"this",
"->",
"MessageModel",
"->",
"Get",
"(",
"'Sort'",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Main page. Show all messages.
@since 2.0.0
@access public | [
"Main",
"page",
".",
"Show",
"all",
"messages",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.messagecontroller.php#L139-L151 |
820 | bishopb/vanilla | applications/dashboard/controllers/class.messagecontroller.php | MessageController._GetAssetData | protected function _GetAssetData() {
$AssetData = array();
$AssetData['Content'] = T('Above Main Content');
$AssetData['Panel'] = T('Below Sidebar');
$this->EventArguments['AssetData'] = &$AssetData;
$this->FireEvent('AfterGetAssetData');
return $AssetData;
} | php | protected function _GetAssetData() {
$AssetData = array();
$AssetData['Content'] = T('Above Main Content');
$AssetData['Panel'] = T('Below Sidebar');
$this->EventArguments['AssetData'] = &$AssetData;
$this->FireEvent('AfterGetAssetData');
return $AssetData;
} | [
"protected",
"function",
"_GetAssetData",
"(",
")",
"{",
"$",
"AssetData",
"=",
"array",
"(",
")",
";",
"$",
"AssetData",
"[",
"'Content'",
"]",
"=",
"T",
"(",
"'Above Main Content'",
")",
";",
"$",
"AssetData",
"[",
"'Panel'",
"]",
"=",
"T",
"(",
"'Below Sidebar'",
")",
";",
"$",
"this",
"->",
"EventArguments",
"[",
"'AssetData'",
"]",
"=",
"&",
"$",
"AssetData",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'AfterGetAssetData'",
")",
";",
"return",
"$",
"AssetData",
";",
"}"
] | Get descriptions of asset locations on page.
@since 2.0.0
@access protected | [
"Get",
"descriptions",
"of",
"asset",
"locations",
"on",
"page",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.messagecontroller.php#L172-L179 |
821 | bishopb/vanilla | applications/dashboard/controllers/class.messagecontroller.php | MessageController._GetLocationData | protected function _GetLocationData() {
$ControllerData = array();
$ControllerData['[Base]'] = T('All Pages');
$ControllerData['[NonAdmin]'] = T('All Forum Pages');
// 2011-09-09 - mosullivan - No longer allowing messages in dashboard
// $ControllerData['[Admin]'] = 'All Dashboard Pages';
$ControllerData['Dashboard/Profile/Index'] = T('Profile Page');
$ControllerData['Vanilla/Discussions/Index'] = T('Discussions Page');
$ControllerData['Vanilla/Discussion/Index'] = T('Comments Page');
$ControllerData['Dashboard/Entry/SignIn'] = T('Sign In');
// 2011-09-09 - mosullivan - No longer allowing messages in dashboard
// $ControllerData['Dashboard/Settings/Index'] = 'Dashboard Home';
$this->EventArguments['ControllerData'] = &$ControllerData;
$this->FireEvent('AfterGetLocationData');
return $ControllerData;
} | php | protected function _GetLocationData() {
$ControllerData = array();
$ControllerData['[Base]'] = T('All Pages');
$ControllerData['[NonAdmin]'] = T('All Forum Pages');
// 2011-09-09 - mosullivan - No longer allowing messages in dashboard
// $ControllerData['[Admin]'] = 'All Dashboard Pages';
$ControllerData['Dashboard/Profile/Index'] = T('Profile Page');
$ControllerData['Vanilla/Discussions/Index'] = T('Discussions Page');
$ControllerData['Vanilla/Discussion/Index'] = T('Comments Page');
$ControllerData['Dashboard/Entry/SignIn'] = T('Sign In');
// 2011-09-09 - mosullivan - No longer allowing messages in dashboard
// $ControllerData['Dashboard/Settings/Index'] = 'Dashboard Home';
$this->EventArguments['ControllerData'] = &$ControllerData;
$this->FireEvent('AfterGetLocationData');
return $ControllerData;
} | [
"protected",
"function",
"_GetLocationData",
"(",
")",
"{",
"$",
"ControllerData",
"=",
"array",
"(",
")",
";",
"$",
"ControllerData",
"[",
"'[Base]'",
"]",
"=",
"T",
"(",
"'All Pages'",
")",
";",
"$",
"ControllerData",
"[",
"'[NonAdmin]'",
"]",
"=",
"T",
"(",
"'All Forum Pages'",
")",
";",
"// 2011-09-09 - mosullivan - No longer allowing messages in dashboard",
"// $ControllerData['[Admin]'] = 'All Dashboard Pages';",
"$",
"ControllerData",
"[",
"'Dashboard/Profile/Index'",
"]",
"=",
"T",
"(",
"'Profile Page'",
")",
";",
"$",
"ControllerData",
"[",
"'Vanilla/Discussions/Index'",
"]",
"=",
"T",
"(",
"'Discussions Page'",
")",
";",
"$",
"ControllerData",
"[",
"'Vanilla/Discussion/Index'",
"]",
"=",
"T",
"(",
"'Comments Page'",
")",
";",
"$",
"ControllerData",
"[",
"'Dashboard/Entry/SignIn'",
"]",
"=",
"T",
"(",
"'Sign In'",
")",
";",
"// 2011-09-09 - mosullivan - No longer allowing messages in dashboard",
"// $ControllerData['Dashboard/Settings/Index'] = 'Dashboard Home';",
"$",
"this",
"->",
"EventArguments",
"[",
"'ControllerData'",
"]",
"=",
"&",
"$",
"ControllerData",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'AfterGetLocationData'",
")",
";",
"return",
"$",
"ControllerData",
";",
"}"
] | Get descriptions of asset locations across site.
@since 2.0.0
@access protected | [
"Get",
"descriptions",
"of",
"asset",
"locations",
"across",
"site",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.messagecontroller.php#L187-L202 |
822 | mszewcz/php-json-schema-validator | src/Validators/ArrayValidators/AdditionalItemsValidator.php | AdditionalItemsValidator.validate | public function validate($subject): bool
{
if (isset($this->schema['items']) && \is_array($this->schema['items'])) {
$schemaFirstKey = \array_keys($this->schema['items'])[0];
$schemaType = \is_int($schemaFirstKey) ? 'array' : 'object';
if ($schemaType === 'array') {
if (!$this->validateAdditionalItems($subject, $this->schema)) {
return false;
}
}
}
return true;
} | php | public function validate($subject): bool
{
if (isset($this->schema['items']) && \is_array($this->schema['items'])) {
$schemaFirstKey = \array_keys($this->schema['items'])[0];
$schemaType = \is_int($schemaFirstKey) ? 'array' : 'object';
if ($schemaType === 'array') {
if (!$this->validateAdditionalItems($subject, $this->schema)) {
return false;
}
}
}
return true;
} | [
"public",
"function",
"validate",
"(",
"$",
"subject",
")",
":",
"bool",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"schema",
"[",
"'items'",
"]",
")",
"&&",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"schema",
"[",
"'items'",
"]",
")",
")",
"{",
"$",
"schemaFirstKey",
"=",
"\\",
"array_keys",
"(",
"$",
"this",
"->",
"schema",
"[",
"'items'",
"]",
")",
"[",
"0",
"]",
";",
"$",
"schemaType",
"=",
"\\",
"is_int",
"(",
"$",
"schemaFirstKey",
")",
"?",
"'array'",
":",
"'object'",
";",
"if",
"(",
"$",
"schemaType",
"===",
"'array'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateAdditionalItems",
"(",
"$",
"subject",
",",
"$",
"this",
"->",
"schema",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Validates subject against additionalItems
@param $subject
@return bool | [
"Validates",
"subject",
"against",
"additionalItems"
] | f7768bfe07ce6508bb1ff36163560a5e5791de7d | https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ArrayValidators/AdditionalItemsValidator.php#L48-L61 |
823 | mszewcz/php-json-schema-validator | src/Validators/ArrayValidators/AdditionalItemsValidator.php | AdditionalItemsValidator.validateAdditionalItems | private function validateAdditionalItems(array $subject, array $schema): bool
{
$subject = \array_slice($subject, count($schema['items']));
if (\is_bool($schema['additionalItems'])) {
return $this->validateAdditionalItemsSchemaBoolean($subject, $schema);
}
if (\is_int(\array_keys($schema['additionalItems'])[0])) {
return $this->validateAdditionalItemsSchemaArray($subject, $schema);
}
return $this->validateAdditionalItemsSchemaObject($subject, $schema);
} | php | private function validateAdditionalItems(array $subject, array $schema): bool
{
$subject = \array_slice($subject, count($schema['items']));
if (\is_bool($schema['additionalItems'])) {
return $this->validateAdditionalItemsSchemaBoolean($subject, $schema);
}
if (\is_int(\array_keys($schema['additionalItems'])[0])) {
return $this->validateAdditionalItemsSchemaArray($subject, $schema);
}
return $this->validateAdditionalItemsSchemaObject($subject, $schema);
} | [
"private",
"function",
"validateAdditionalItems",
"(",
"array",
"$",
"subject",
",",
"array",
"$",
"schema",
")",
":",
"bool",
"{",
"$",
"subject",
"=",
"\\",
"array_slice",
"(",
"$",
"subject",
",",
"count",
"(",
"$",
"schema",
"[",
"'items'",
"]",
")",
")",
";",
"if",
"(",
"\\",
"is_bool",
"(",
"$",
"schema",
"[",
"'additionalItems'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"validateAdditionalItemsSchemaBoolean",
"(",
"$",
"subject",
",",
"$",
"schema",
")",
";",
"}",
"if",
"(",
"\\",
"is_int",
"(",
"\\",
"array_keys",
"(",
"$",
"schema",
"[",
"'additionalItems'",
"]",
")",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"validateAdditionalItemsSchemaArray",
"(",
"$",
"subject",
",",
"$",
"schema",
")",
";",
"}",
"return",
"$",
"this",
"->",
"validateAdditionalItemsSchemaObject",
"(",
"$",
"subject",
",",
"$",
"schema",
")",
";",
"}"
] | Validates against additionalItems
@param array $subject
@param array $schema
@return bool | [
"Validates",
"against",
"additionalItems"
] | f7768bfe07ce6508bb1ff36163560a5e5791de7d | https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ArrayValidators/AdditionalItemsValidator.php#L70-L81 |
824 | mszewcz/php-json-schema-validator | src/Validators/ArrayValidators/AdditionalItemsValidator.php | AdditionalItemsValidator.validateAdditionalItemsSchemaBoolean | private function validateAdditionalItemsSchemaBoolean(array $subject, array $schema): bool
{
if (($schema['additionalItems'] === false) && count($subject) > 0) {
return false;
}
return true;
} | php | private function validateAdditionalItemsSchemaBoolean(array $subject, array $schema): bool
{
if (($schema['additionalItems'] === false) && count($subject) > 0) {
return false;
}
return true;
} | [
"private",
"function",
"validateAdditionalItemsSchemaBoolean",
"(",
"array",
"$",
"subject",
",",
"array",
"$",
"schema",
")",
":",
"bool",
"{",
"if",
"(",
"(",
"$",
"schema",
"[",
"'additionalItems'",
"]",
"===",
"false",
")",
"&&",
"count",
"(",
"$",
"subject",
")",
">",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Validate against additionalItems for boolean-type schema
@param array $subject
@param array $schema
@return bool | [
"Validate",
"against",
"additionalItems",
"for",
"boolean",
"-",
"type",
"schema"
] | f7768bfe07ce6508bb1ff36163560a5e5791de7d | https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ArrayValidators/AdditionalItemsValidator.php#L90-L96 |
825 | mszewcz/php-json-schema-validator | src/Validators/ArrayValidators/AdditionalItemsValidator.php | AdditionalItemsValidator.validateAdditionalItemsSchemaObject | private function validateAdditionalItemsSchemaObject(array $subject, array $schema): bool
{
for ($i = 0; $i < count($subject); $i++) {
$nodeValidator = new NodeValidator($schema['additionalItems'], $this->rootSchema);
if (!$nodeValidator->validate($subject[$i])) {
return false;
}
}
return true;
} | php | private function validateAdditionalItemsSchemaObject(array $subject, array $schema): bool
{
for ($i = 0; $i < count($subject); $i++) {
$nodeValidator = new NodeValidator($schema['additionalItems'], $this->rootSchema);
if (!$nodeValidator->validate($subject[$i])) {
return false;
}
}
return true;
} | [
"private",
"function",
"validateAdditionalItemsSchemaObject",
"(",
"array",
"$",
"subject",
",",
"array",
"$",
"schema",
")",
":",
"bool",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"subject",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"nodeValidator",
"=",
"new",
"NodeValidator",
"(",
"$",
"schema",
"[",
"'additionalItems'",
"]",
",",
"$",
"this",
"->",
"rootSchema",
")",
";",
"if",
"(",
"!",
"$",
"nodeValidator",
"->",
"validate",
"(",
"$",
"subject",
"[",
"$",
"i",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Validate against additionalItems for object-type schema
@param array $subject
@param array $schema
@return bool | [
"Validate",
"against",
"additionalItems",
"for",
"object",
"-",
"type",
"schema"
] | f7768bfe07ce6508bb1ff36163560a5e5791de7d | https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ArrayValidators/AdditionalItemsValidator.php#L105-L114 |
826 | kevinbaubet/kss-php-markup | lib/Cache.php | Cache.set | public function set($key, $data)
{
$file = $this->getFilePath($key);
if ($handle = fopen($file, 'w')) {
fwrite($handle, $data);
fclose($handle);
}
} | php | public function set($key, $data)
{
$file = $this->getFilePath($key);
if ($handle = fopen($file, 'w')) {
fwrite($handle, $data);
fclose($handle);
}
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"data",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"file",
",",
"'w'",
")",
")",
"{",
"fwrite",
"(",
"$",
"handle",
",",
"$",
"data",
")",
";",
"fclose",
"(",
"$",
"handle",
")",
";",
"}",
"}"
] | Set cache data
@param string $key Cache key
@param string $data Store data | [
"Set",
"cache",
"data"
] | 41439701881b148f0d6058467be3877e5bd9a4cc | https://github.com/kevinbaubet/kss-php-markup/blob/41439701881b148f0d6058467be3877e5bd9a4cc/lib/Cache.php#L53-L61 |
827 | kevinbaubet/kss-php-markup | lib/Cache.php | Cache.clean | public function clean()
{
$directory = scandir($this->path);
if (!empty($directory)) {
foreach ($directory as $item) {
if ($item !== '.' && $item !== '..') {
$this->remove($item);
}
}
}
return $this;
} | php | public function clean()
{
$directory = scandir($this->path);
if (!empty($directory)) {
foreach ($directory as $item) {
if ($item !== '.' && $item !== '..') {
$this->remove($item);
}
}
}
return $this;
} | [
"public",
"function",
"clean",
"(",
")",
"{",
"$",
"directory",
"=",
"scandir",
"(",
"$",
"this",
"->",
"path",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"directory",
")",
")",
"{",
"foreach",
"(",
"$",
"directory",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"!==",
"'.'",
"&&",
"$",
"item",
"!==",
"'..'",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"item",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Clean all cache
@return $this | [
"Clean",
"all",
"cache"
] | 41439701881b148f0d6058467be3877e5bd9a4cc | https://github.com/kevinbaubet/kss-php-markup/blob/41439701881b148f0d6058467be3877e5bd9a4cc/lib/Cache.php#L100-L113 |
828 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/controllers/category.php | CategoriesControllerCategory.allowAdd | protected function allowAdd($data = array())
{
$user = JFactory::getUser();
return ($user->authorise('core.create', $this->extension) || count($user->getAuthorisedCategories($this->extension, 'core.create')));
} | php | protected function allowAdd($data = array())
{
$user = JFactory::getUser();
return ($user->authorise('core.create', $this->extension) || count($user->getAuthorisedCategories($this->extension, 'core.create')));
} | [
"protected",
"function",
"allowAdd",
"(",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"return",
"(",
"$",
"user",
"->",
"authorise",
"(",
"'core.create'",
",",
"$",
"this",
"->",
"extension",
")",
"||",
"count",
"(",
"$",
"user",
"->",
"getAuthorisedCategories",
"(",
"$",
"this",
"->",
"extension",
",",
"'core.create'",
")",
")",
")",
";",
"}"
] | Method to check if you can add a new record.
@param array $data An array of input data.
@return boolean
@since 1.6 | [
"Method",
"to",
"check",
"if",
"you",
"can",
"add",
"a",
"new",
"record",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/category.php#L57-L62 |
829 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/controllers/category.php | CategoriesControllerCategory.allowEdit | protected function allowEdit($data = array(), $key = 'parent_id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JFactory::getUser();
// Check "edit" permission on record asset (explicit or inherited)
if ($user->authorise('core.edit', $this->extension . '.category.' . $recordId))
{
return true;
}
// Check "edit own" permission on record asset (explicit or inherited)
if ($user->authorise('core.edit.own', $this->extension . '.category.' . $recordId))
{
// Need to do a lookup from the model to get the owner
$record = $this->getModel()->getItem($recordId);
if (empty($record))
{
return false;
}
$ownerId = $record->created_user_id;
// If the owner matches 'me' then do the test.
if ($ownerId == $user->id)
{
return true;
}
}
return false;
} | php | protected function allowEdit($data = array(), $key = 'parent_id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JFactory::getUser();
// Check "edit" permission on record asset (explicit or inherited)
if ($user->authorise('core.edit', $this->extension . '.category.' . $recordId))
{
return true;
}
// Check "edit own" permission on record asset (explicit or inherited)
if ($user->authorise('core.edit.own', $this->extension . '.category.' . $recordId))
{
// Need to do a lookup from the model to get the owner
$record = $this->getModel()->getItem($recordId);
if (empty($record))
{
return false;
}
$ownerId = $record->created_user_id;
// If the owner matches 'me' then do the test.
if ($ownerId == $user->id)
{
return true;
}
}
return false;
} | [
"protected",
"function",
"allowEdit",
"(",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"key",
"=",
"'parent_id'",
")",
"{",
"$",
"recordId",
"=",
"(",
"int",
")",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"key",
"]",
":",
"0",
";",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"// Check \"edit\" permission on record asset (explicit or inherited)",
"if",
"(",
"$",
"user",
"->",
"authorise",
"(",
"'core.edit'",
",",
"$",
"this",
"->",
"extension",
".",
"'.category.'",
".",
"$",
"recordId",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Check \"edit own\" permission on record asset (explicit or inherited)",
"if",
"(",
"$",
"user",
"->",
"authorise",
"(",
"'core.edit.own'",
",",
"$",
"this",
"->",
"extension",
".",
"'.category.'",
".",
"$",
"recordId",
")",
")",
"{",
"// Need to do a lookup from the model to get the owner",
"$",
"record",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getItem",
"(",
"$",
"recordId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"record",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"ownerId",
"=",
"$",
"record",
"->",
"created_user_id",
";",
"// If the owner matches 'me' then do the test.",
"if",
"(",
"$",
"ownerId",
"==",
"$",
"user",
"->",
"id",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Method to check if you can edit a record.
@param array $data An array of input data.
@param string $key The name of the key for the primary key.
@return boolean
@since 1.6 | [
"Method",
"to",
"check",
"if",
"you",
"can",
"edit",
"a",
"record",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/category.php#L74-L106 |
830 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/controllers/category.php | CategoriesControllerCategory.batch | public function batch($model = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
/** @var CategoriesModelCategory $model */
$model = $this->getModel('Category');
// Preset the redirect
$this->setRedirect('index.php?option=com_categories&view=categories&extension=' . $this->extension);
return parent::batch($model);
} | php | public function batch($model = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
/** @var CategoriesModelCategory $model */
$model = $this->getModel('Category');
// Preset the redirect
$this->setRedirect('index.php?option=com_categories&view=categories&extension=' . $this->extension);
return parent::batch($model);
} | [
"public",
"function",
"batch",
"(",
"$",
"model",
"=",
"null",
")",
"{",
"JSession",
"::",
"checkToken",
"(",
")",
"or",
"jexit",
"(",
"JText",
"::",
"_",
"(",
"'JINVALID_TOKEN'",
")",
")",
";",
"// Set the model",
"/** @var CategoriesModelCategory $model */",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
"'Category'",
")",
";",
"// Preset the redirect",
"$",
"this",
"->",
"setRedirect",
"(",
"'index.php?option=com_categories&view=categories&extension='",
".",
"$",
"this",
"->",
"extension",
")",
";",
"return",
"parent",
"::",
"batch",
"(",
"$",
"model",
")",
";",
"}"
] | Method to run batch operations.
@param object $model The model.
@return boolean True if successful, false otherwise and internal error is set.
@since 1.6 | [
"Method",
"to",
"run",
"batch",
"operations",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/category.php#L117-L129 |
831 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/controllers/category.php | CategoriesControllerCategory.getRedirectToItemAppend | protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
$append = parent::getRedirectToItemAppend($recordId);
$append .= '&extension=' . $this->extension;
return $append;
} | php | protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
{
$append = parent::getRedirectToItemAppend($recordId);
$append .= '&extension=' . $this->extension;
return $append;
} | [
"protected",
"function",
"getRedirectToItemAppend",
"(",
"$",
"recordId",
"=",
"null",
",",
"$",
"urlVar",
"=",
"'id'",
")",
"{",
"$",
"append",
"=",
"parent",
"::",
"getRedirectToItemAppend",
"(",
"$",
"recordId",
")",
";",
"$",
"append",
".=",
"'&extension='",
".",
"$",
"this",
"->",
"extension",
";",
"return",
"$",
"append",
";",
"}"
] | Gets the URL arguments to append to an item redirect.
@param integer $recordId The primary key id for the item.
@param string $urlVar The name of the URL variable for the id.
@return string The arguments to append to the redirect URL.
@since 1.6 | [
"Gets",
"the",
"URL",
"arguments",
"to",
"append",
"to",
"an",
"item",
"redirect",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/category.php#L141-L147 |
832 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/controllers/category.php | CategoriesControllerCategory.postSaveHook | protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
if (isset($item->params) && is_array($item->params))
{
$registry = new Registry;
$registry->loadArray($item->params);
$item->params = (string) $registry;
}
if (isset($item->metadata) && is_array($item->metadata))
{
$registry = new Registry;
$registry->loadArray($item->metadata);
$item->metadata = (string) $registry;
}
} | php | protected function postSaveHook(JModelLegacy $model, $validData = array())
{
$item = $model->getItem();
if (isset($item->params) && is_array($item->params))
{
$registry = new Registry;
$registry->loadArray($item->params);
$item->params = (string) $registry;
}
if (isset($item->metadata) && is_array($item->metadata))
{
$registry = new Registry;
$registry->loadArray($item->metadata);
$item->metadata = (string) $registry;
}
} | [
"protected",
"function",
"postSaveHook",
"(",
"JModelLegacy",
"$",
"model",
",",
"$",
"validData",
"=",
"array",
"(",
")",
")",
"{",
"$",
"item",
"=",
"$",
"model",
"->",
"getItem",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"item",
"->",
"params",
")",
"&&",
"is_array",
"(",
"$",
"item",
"->",
"params",
")",
")",
"{",
"$",
"registry",
"=",
"new",
"Registry",
";",
"$",
"registry",
"->",
"loadArray",
"(",
"$",
"item",
"->",
"params",
")",
";",
"$",
"item",
"->",
"params",
"=",
"(",
"string",
")",
"$",
"registry",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"item",
"->",
"metadata",
")",
"&&",
"is_array",
"(",
"$",
"item",
"->",
"metadata",
")",
")",
"{",
"$",
"registry",
"=",
"new",
"Registry",
";",
"$",
"registry",
"->",
"loadArray",
"(",
"$",
"item",
"->",
"metadata",
")",
";",
"$",
"item",
"->",
"metadata",
"=",
"(",
"string",
")",
"$",
"registry",
";",
"}",
"}"
] | Function that allows child controller access to model data after the data has been saved.
@param JModelLegacy $model The data model object.
@param array $validData The validated data.
@return void
@since 3.1 | [
"Function",
"that",
"allows",
"child",
"controller",
"access",
"to",
"model",
"data",
"after",
"the",
"data",
"has",
"been",
"saved",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/controllers/category.php#L174-L191 |
833 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-stdlib/src/Guard/EmptyGuardTrait.php | EmptyGuardTrait.guardAgainstEmpty | protected function guardAgainstEmpty(
$data,
$dataName = 'Argument',
$exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException'
) {
if (empty($data)) {
$message = sprintf('%s cannot be empty', $dataName);
throw new $exceptionClass($message);
}
} | php | protected function guardAgainstEmpty(
$data,
$dataName = 'Argument',
$exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException'
) {
if (empty($data)) {
$message = sprintf('%s cannot be empty', $dataName);
throw new $exceptionClass($message);
}
} | [
"protected",
"function",
"guardAgainstEmpty",
"(",
"$",
"data",
",",
"$",
"dataName",
"=",
"'Argument'",
",",
"$",
"exceptionClass",
"=",
"'Zend\\Stdlib\\Exception\\InvalidArgumentException'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'%s cannot be empty'",
",",
"$",
"dataName",
")",
";",
"throw",
"new",
"$",
"exceptionClass",
"(",
"$",
"message",
")",
";",
"}",
"}"
] | Verify that the data is not empty
@param mixed $data the data to verify
@param string $dataName the data name
@param string $exceptionClass FQCN for the exception
@throws \Exception | [
"Verify",
"that",
"the",
"data",
"is",
"not",
"empty"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/Guard/EmptyGuardTrait.php#L25-L34 |
834 | slickframework/orm | src/Descriptor/RelationsMap.php | RelationsMap.set | public function set($key, $value)
{
if (! $value instanceof RelationInterface) {
throw new InvalidArgumentException(
"Only RelationInterface objects can be putted in a ".
"RelationsMap."
);
}
return parent::set($key, $value);
} | php | public function set($key, $value)
{
if (! $value instanceof RelationInterface) {
throw new InvalidArgumentException(
"Only RelationInterface objects can be putted in a ".
"RelationsMap."
);
}
return parent::set($key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"RelationInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Only RelationInterface objects can be putted in a \"",
".",
"\"RelationsMap.\"",
")",
";",
"}",
"return",
"parent",
"::",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Puts a new relation in the map.
@param mixed $key
@param mixed $value
@return RelationsMap | [
"Puts",
"a",
"new",
"relation",
"in",
"the",
"map",
"."
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Descriptor/RelationsMap.php#L34-L43 |
835 | circle314/type | src/Primitive/AbstractPrimitiveStringType.php | AbstractPrimitiveStringType.valueInBounds | final protected function valueInBounds($value)
{
return is_null($value) || (
(is_null($this->getMinLength()) || strlen($value) >= $this->getMinLength())
&&
(is_null($this->getMaxLength()) || strlen($value) <= $this->getMaxLength())
);
} | php | final protected function valueInBounds($value)
{
return is_null($value) || (
(is_null($this->getMinLength()) || strlen($value) >= $this->getMinLength())
&&
(is_null($this->getMaxLength()) || strlen($value) <= $this->getMaxLength())
);
} | [
"final",
"protected",
"function",
"valueInBounds",
"(",
"$",
"value",
")",
"{",
"return",
"is_null",
"(",
"$",
"value",
")",
"||",
"(",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getMinLength",
"(",
")",
")",
"||",
"strlen",
"(",
"$",
"value",
")",
">=",
"$",
"this",
"->",
"getMinLength",
"(",
")",
")",
"&&",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getMaxLength",
"(",
")",
")",
"||",
"strlen",
"(",
"$",
"value",
")",
"<=",
"$",
"this",
"->",
"getMaxLength",
"(",
")",
")",
")",
";",
"}"
] | Checks if the length of the string is within bounds
@param $value mixed The string value
@return bool | [
"Checks",
"if",
"the",
"length",
"of",
"the",
"string",
"is",
"within",
"bounds"
] | 4048d57efad65f043b549c3c4b48b1d0e6c09a3f | https://github.com/circle314/type/blob/4048d57efad65f043b549c3c4b48b1d0e6c09a3f/src/Primitive/AbstractPrimitiveStringType.php#L131-L138 |
836 | AlexHowansky/ork-base | src/String/Entropy.php | Entropy.bitsPerCharacter | public function bitsPerCharacter($string)
{
if (is_string($string) === false) {
throw new \InvalidArgumentException('Argument must be a string.');
}
$sum = 0;
$length = strlen($string);
foreach (array_values(array_count_values(str_split($string))) as $count) {
$freq = $count / $length;
$sum += $freq * log($freq, 2);
}
return (int) ceil(- $sum);
} | php | public function bitsPerCharacter($string)
{
if (is_string($string) === false) {
throw new \InvalidArgumentException('Argument must be a string.');
}
$sum = 0;
$length = strlen($string);
foreach (array_values(array_count_values(str_split($string))) as $count) {
$freq = $count / $length;
$sum += $freq * log($freq, 2);
}
return (int) ceil(- $sum);
} | [
"public",
"function",
"bitsPerCharacter",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"string",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Argument must be a string.'",
")",
";",
"}",
"$",
"sum",
"=",
"0",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"foreach",
"(",
"array_values",
"(",
"array_count_values",
"(",
"str_split",
"(",
"$",
"string",
")",
")",
")",
"as",
"$",
"count",
")",
"{",
"$",
"freq",
"=",
"$",
"count",
"/",
"$",
"length",
";",
"$",
"sum",
"+=",
"$",
"freq",
"*",
"log",
"(",
"$",
"freq",
",",
"2",
")",
";",
"}",
"return",
"(",
"int",
")",
"ceil",
"(",
"-",
"$",
"sum",
")",
";",
"}"
] | Calculate the number of bits needed to encode a single character of the given string.
@param string $string The string to calculate the entropy of.
@return int The number of bits of entropy needed to encode a single character of the given string. | [
"Calculate",
"the",
"number",
"of",
"bits",
"needed",
"to",
"encode",
"a",
"single",
"character",
"of",
"the",
"given",
"string",
"."
] | 5f4ab14e63bbc8b17898639fd1fff86ee6659bb0 | https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/String/Entropy.php#L41-L53 |
837 | tenside/core | src/Composer/Search/CompositeSearch.php | CompositeSearch.addSearcher | public function addSearcher(SearchInterface $searcher)
{
if ($searcher instanceof self && count($searcher->getSearchers())) {
foreach ($searcher->getSearchers() as $compositeSearcher) {
$this->addSearcher($compositeSearcher);
}
return $this;
}
$this->searchers[] = $searcher;
return $this;
} | php | public function addSearcher(SearchInterface $searcher)
{
if ($searcher instanceof self && count($searcher->getSearchers())) {
foreach ($searcher->getSearchers() as $compositeSearcher) {
$this->addSearcher($compositeSearcher);
}
return $this;
}
$this->searchers[] = $searcher;
return $this;
} | [
"public",
"function",
"addSearcher",
"(",
"SearchInterface",
"$",
"searcher",
")",
"{",
"if",
"(",
"$",
"searcher",
"instanceof",
"self",
"&&",
"count",
"(",
"$",
"searcher",
"->",
"getSearchers",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"searcher",
"->",
"getSearchers",
"(",
")",
"as",
"$",
"compositeSearcher",
")",
"{",
"$",
"this",
"->",
"addSearcher",
"(",
"$",
"compositeSearcher",
")",
";",
"}",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"searchers",
"[",
"]",
"=",
"$",
"searcher",
";",
"return",
"$",
"this",
";",
"}"
] | Add a search providers,
@param SearchInterface $searcher The provider to add.
@return $this | [
"Add",
"a",
"search",
"providers"
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Composer/Search/CompositeSearch.php#L124-L137 |
838 | traq/installer | src/Controllers/AppController.php | AppController.loadMigrations | protected function loadMigrations()
{
$migrationsDir = $this->docRoot . '/src/Database/Migrations';
foreach (scandir($migrationsDir) as $file) {
if ($file !== '.' && $file !== '..') {
require "{$migrationsDir}/{$file}";
}
}
} | php | protected function loadMigrations()
{
$migrationsDir = $this->docRoot . '/src/Database/Migrations';
foreach (scandir($migrationsDir) as $file) {
if ($file !== '.' && $file !== '..') {
require "{$migrationsDir}/{$file}";
}
}
} | [
"protected",
"function",
"loadMigrations",
"(",
")",
"{",
"$",
"migrationsDir",
"=",
"$",
"this",
"->",
"docRoot",
".",
"'/src/Database/Migrations'",
";",
"foreach",
"(",
"scandir",
"(",
"$",
"migrationsDir",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"!==",
"'.'",
"&&",
"$",
"file",
"!==",
"'..'",
")",
"{",
"require",
"\"{$migrationsDir}/{$file}\"",
";",
"}",
"}",
"}"
] | Load migrations. | [
"Load",
"migrations",
"."
] | 7d82ee13d11c59cb63bcb7739962c85a994271ef | https://github.com/traq/installer/blob/7d82ee13d11c59cb63bcb7739962c85a994271ef/src/Controllers/AppController.php#L82-L90 |
839 | traq/installer | src/Controllers/AppController.php | AppController.checkDatabaseInformation | protected function checkDatabaseInformation()
{
$this->title("Database Information");
$errors = [];
$driver = Request::$post->get('driver');
// Check fields
if ($driver == "pdo_pgsql" || $driver == "pdo_mysql") {
if (!Request::$post->get('host')) {
$errors[] = "Server is required";
}
if (!Request::$post->get('user')) {
$errors[] = "Username is required";
}
if (!Request::$post->get('dbname')) {
$errors[] = "Database name is required";
}
} elseif ($driver == "pdo_sqlite") {
if (!Request::$post->get('path')) {
$errors[] = "Database path is required";
}
}
// Check connection
if (!count($errors)) {
$info = [
'driver' => $driver,
];
switch ($driver) {
case "pdo_pgsql":
case "pdo_mysql":
$info = $info + [
'host' => Request::$post->get('host'),
'user' => Request::$post->get('user'),
'password' => Request::$post->get('password'),
'dbname' => Request::$post->get('dbname')
];
break;
case "pdo_sqlite":
$info['path'] = Request::$post->get('path');
break;
}
try {
// Lets try to do a few things with the database to confirm a connection.
$db = ConnectionManager::create($info);
$sm = $db->getSchemaManager();
$sm->listTables();
} catch (DBALException $e) {
$errors[] = "Unable to connect to database: " . $e->getMessage();
}
}
if (count($errors)) {
$this->title("Database Information");
return $this->render("steps/database_information.phtml", [
'errors' => $errors
]);
}
$_SESSION['db'] = $info;
} | php | protected function checkDatabaseInformation()
{
$this->title("Database Information");
$errors = [];
$driver = Request::$post->get('driver');
// Check fields
if ($driver == "pdo_pgsql" || $driver == "pdo_mysql") {
if (!Request::$post->get('host')) {
$errors[] = "Server is required";
}
if (!Request::$post->get('user')) {
$errors[] = "Username is required";
}
if (!Request::$post->get('dbname')) {
$errors[] = "Database name is required";
}
} elseif ($driver == "pdo_sqlite") {
if (!Request::$post->get('path')) {
$errors[] = "Database path is required";
}
}
// Check connection
if (!count($errors)) {
$info = [
'driver' => $driver,
];
switch ($driver) {
case "pdo_pgsql":
case "pdo_mysql":
$info = $info + [
'host' => Request::$post->get('host'),
'user' => Request::$post->get('user'),
'password' => Request::$post->get('password'),
'dbname' => Request::$post->get('dbname')
];
break;
case "pdo_sqlite":
$info['path'] = Request::$post->get('path');
break;
}
try {
// Lets try to do a few things with the database to confirm a connection.
$db = ConnectionManager::create($info);
$sm = $db->getSchemaManager();
$sm->listTables();
} catch (DBALException $e) {
$errors[] = "Unable to connect to database: " . $e->getMessage();
}
}
if (count($errors)) {
$this->title("Database Information");
return $this->render("steps/database_information.phtml", [
'errors' => $errors
]);
}
$_SESSION['db'] = $info;
} | [
"protected",
"function",
"checkDatabaseInformation",
"(",
")",
"{",
"$",
"this",
"->",
"title",
"(",
"\"Database Information\"",
")",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"$",
"driver",
"=",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'driver'",
")",
";",
"// Check fields",
"if",
"(",
"$",
"driver",
"==",
"\"pdo_pgsql\"",
"||",
"$",
"driver",
"==",
"\"pdo_mysql\"",
")",
"{",
"if",
"(",
"!",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'host'",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Server is required\"",
";",
"}",
"if",
"(",
"!",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'user'",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Username is required\"",
";",
"}",
"if",
"(",
"!",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'dbname'",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Database name is required\"",
";",
"}",
"}",
"elseif",
"(",
"$",
"driver",
"==",
"\"pdo_sqlite\"",
")",
"{",
"if",
"(",
"!",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'path'",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Database path is required\"",
";",
"}",
"}",
"// Check connection",
"if",
"(",
"!",
"count",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"info",
"=",
"[",
"'driver'",
"=>",
"$",
"driver",
",",
"]",
";",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"\"pdo_pgsql\"",
":",
"case",
"\"pdo_mysql\"",
":",
"$",
"info",
"=",
"$",
"info",
"+",
"[",
"'host'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'host'",
")",
",",
"'user'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'user'",
")",
",",
"'password'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'password'",
")",
",",
"'dbname'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'dbname'",
")",
"]",
";",
"break",
";",
"case",
"\"pdo_sqlite\"",
":",
"$",
"info",
"[",
"'path'",
"]",
"=",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'path'",
")",
";",
"break",
";",
"}",
"try",
"{",
"// Lets try to do a few things with the database to confirm a connection.",
"$",
"db",
"=",
"ConnectionManager",
"::",
"create",
"(",
"$",
"info",
")",
";",
"$",
"sm",
"=",
"$",
"db",
"->",
"getSchemaManager",
"(",
")",
";",
"$",
"sm",
"->",
"listTables",
"(",
")",
";",
"}",
"catch",
"(",
"DBALException",
"$",
"e",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Unable to connect to database: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"this",
"->",
"title",
"(",
"\"Database Information\"",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"\"steps/database_information.phtml\"",
",",
"[",
"'errors'",
"=>",
"$",
"errors",
"]",
")",
";",
"}",
"$",
"_SESSION",
"[",
"'db'",
"]",
"=",
"$",
"info",
";",
"}"
] | Check the database form fields and connection.
@access protected | [
"Check",
"the",
"database",
"form",
"fields",
"and",
"connection",
"."
] | 7d82ee13d11c59cb63bcb7739962c85a994271ef | https://github.com/traq/installer/blob/7d82ee13d11c59cb63bcb7739962c85a994271ef/src/Controllers/AppController.php#L97-L163 |
840 | traq/installer | src/Controllers/AppController.php | AppController.checkAccountInformation | protected function checkAccountInformation()
{
$errors = [];
if (!Request::$post->get('username')) {
$errors[] = "Username is required";
}
if (strlen(Request::$post->get('username')) < 3) {
$errors[] = "Username must be at least 3 characters long";
}
if (!Request::$post->get('password')) {
$errors[] = "Password is required";
}
if (strlen(Request::$post->get('password')) < 6) {
$errors[] = "Password must be at least 6 characters long";
}
if (!Request::$post->get('email')) {
$errors[] = "Email is required";
}
if (count($errors)) {
$this->title("Admin Account");
return $this->render("steps/account_information.phtml", [
'errors' => $errors
]);
}
$_SESSION['admin'] = [
'username' => Request::$post->get('username'),
'password' => Request::$post->get('password'),
'confirm_password' => Request::$post->get('password'),
'email' => Request::$post->get('email')
];
} | php | protected function checkAccountInformation()
{
$errors = [];
if (!Request::$post->get('username')) {
$errors[] = "Username is required";
}
if (strlen(Request::$post->get('username')) < 3) {
$errors[] = "Username must be at least 3 characters long";
}
if (!Request::$post->get('password')) {
$errors[] = "Password is required";
}
if (strlen(Request::$post->get('password')) < 6) {
$errors[] = "Password must be at least 6 characters long";
}
if (!Request::$post->get('email')) {
$errors[] = "Email is required";
}
if (count($errors)) {
$this->title("Admin Account");
return $this->render("steps/account_information.phtml", [
'errors' => $errors
]);
}
$_SESSION['admin'] = [
'username' => Request::$post->get('username'),
'password' => Request::$post->get('password'),
'confirm_password' => Request::$post->get('password'),
'email' => Request::$post->get('email')
];
} | [
"protected",
"function",
"checkAccountInformation",
"(",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'username'",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Username is required\"",
";",
"}",
"if",
"(",
"strlen",
"(",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'username'",
")",
")",
"<",
"3",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Username must be at least 3 characters long\"",
";",
"}",
"if",
"(",
"!",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'password'",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Password is required\"",
";",
"}",
"if",
"(",
"strlen",
"(",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'password'",
")",
")",
"<",
"6",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Password must be at least 6 characters long\"",
";",
"}",
"if",
"(",
"!",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'email'",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Email is required\"",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"this",
"->",
"title",
"(",
"\"Admin Account\"",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"\"steps/account_information.phtml\"",
",",
"[",
"'errors'",
"=>",
"$",
"errors",
"]",
")",
";",
"}",
"$",
"_SESSION",
"[",
"'admin'",
"]",
"=",
"[",
"'username'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'username'",
")",
",",
"'password'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'password'",
")",
",",
"'confirm_password'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'password'",
")",
",",
"'email'",
"=>",
"Request",
"::",
"$",
"post",
"->",
"get",
"(",
"'email'",
")",
"]",
";",
"}"
] | Check admin account information.
@access protected | [
"Check",
"admin",
"account",
"information",
"."
] | 7d82ee13d11c59cb63bcb7739962c85a994271ef | https://github.com/traq/installer/blob/7d82ee13d11c59cb63bcb7739962c85a994271ef/src/Controllers/AppController.php#L170-L207 |
841 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior.beforeFind | public function beforeFind(Model $model, $query) {
$runtime = $this->runtime[$model->alias];
if ($runtime) {
if (!is_array($query['conditions'])) {
$query['conditions'] = array();
}
$conditions = array_filter(array_keys($query['conditions']));
$fields = $this->_normalizeFields($model);
foreach ($fields as $flag => $date) {
if (true === $runtime || $flag === $runtime) {
if (!in_array($flag, $conditions) && !in_array($model->name . '.' . $flag, $conditions)) {
$query['conditions'][$model->alias . '.' . $flag] = false;
}
if ($flag === $runtime) {
break;
}
}
}
return $query;
}
} | php | public function beforeFind(Model $model, $query) {
$runtime = $this->runtime[$model->alias];
if ($runtime) {
if (!is_array($query['conditions'])) {
$query['conditions'] = array();
}
$conditions = array_filter(array_keys($query['conditions']));
$fields = $this->_normalizeFields($model);
foreach ($fields as $flag => $date) {
if (true === $runtime || $flag === $runtime) {
if (!in_array($flag, $conditions) && !in_array($model->name . '.' . $flag, $conditions)) {
$query['conditions'][$model->alias . '.' . $flag] = false;
}
if ($flag === $runtime) {
break;
}
}
}
return $query;
}
} | [
"public",
"function",
"beforeFind",
"(",
"Model",
"$",
"model",
",",
"$",
"query",
")",
"{",
"$",
"runtime",
"=",
"$",
"this",
"->",
"runtime",
"[",
"$",
"model",
"->",
"alias",
"]",
";",
"if",
"(",
"$",
"runtime",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"query",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"query",
"[",
"'conditions'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"conditions",
"=",
"array_filter",
"(",
"array_keys",
"(",
"$",
"query",
"[",
"'conditions'",
"]",
")",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"_normalizeFields",
"(",
"$",
"model",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"flag",
"=>",
"$",
"date",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"runtime",
"||",
"$",
"flag",
"===",
"$",
"runtime",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"flag",
",",
"$",
"conditions",
")",
"&&",
"!",
"in_array",
"(",
"$",
"model",
"->",
"name",
".",
"'.'",
".",
"$",
"flag",
",",
"$",
"conditions",
")",
")",
"{",
"$",
"query",
"[",
"'conditions'",
"]",
"[",
"$",
"model",
"->",
"alias",
".",
"'.'",
".",
"$",
"flag",
"]",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"flag",
"===",
"$",
"runtime",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"query",
";",
"}",
"}"
] | Before find callback
@param Model $model
@param array $query
@return array | [
"Before",
"find",
"callback"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L77-L101 |
842 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior.existsAndNotDeleted | public function existsAndNotDeleted(Model $model, $id) {
if ($id === null) {
$id = $model->getID();
}
if ($id === false) {
return false;
}
$exists = $model->find('count', array('conditions' => array($model->alias . '.' . $model->primaryKey => $id)));
return ($exists ? true : false);
} | php | public function existsAndNotDeleted(Model $model, $id) {
if ($id === null) {
$id = $model->getID();
}
if ($id === false) {
return false;
}
$exists = $model->find('count', array('conditions' => array($model->alias . '.' . $model->primaryKey => $id)));
return ($exists ? true : false);
} | [
"public",
"function",
"existsAndNotDeleted",
"(",
"Model",
"$",
"model",
",",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"$",
"id",
"=",
"$",
"model",
"->",
"getID",
"(",
")",
";",
"}",
"if",
"(",
"$",
"id",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"exists",
"=",
"$",
"model",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"$",
"model",
"->",
"alias",
".",
"'.'",
".",
"$",
"model",
"->",
"primaryKey",
"=>",
"$",
"id",
")",
")",
")",
";",
"return",
"(",
"$",
"exists",
"?",
"true",
":",
"false",
")",
";",
"}"
] | Check if a record exists for the given id
@param Model $model
@param id
@return mixed | [
"Check",
"if",
"a",
"record",
"exists",
"for",
"the",
"given",
"id"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L110-L119 |
843 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior.beforeDelete | public function beforeDelete(Model $model, $cascade = true) {
$runtime = $this->runtime[$model->alias];
if ($runtime) {
if ($model->beforeDelete($cascade)) {
return $this->delete($model, $model->id);
}
return false;
}
return true;
} | php | public function beforeDelete(Model $model, $cascade = true) {
$runtime = $this->runtime[$model->alias];
if ($runtime) {
if ($model->beforeDelete($cascade)) {
return $this->delete($model, $model->id);
}
return false;
}
return true;
} | [
"public",
"function",
"beforeDelete",
"(",
"Model",
"$",
"model",
",",
"$",
"cascade",
"=",
"true",
")",
"{",
"$",
"runtime",
"=",
"$",
"this",
"->",
"runtime",
"[",
"$",
"model",
"->",
"alias",
"]",
";",
"if",
"(",
"$",
"runtime",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"beforeDelete",
"(",
"$",
"cascade",
")",
")",
"{",
"return",
"$",
"this",
"->",
"delete",
"(",
"$",
"model",
",",
"$",
"model",
"->",
"id",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Before delete callback
@param Model $model
@param boolean $cascade
@return boolean | [
"Before",
"delete",
"callback"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L128-L137 |
844 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior.delete | public function delete($model, $id) {
$runtime = $this->runtime[$model->alias];
$data = array();
$fields = $this->_normalizeFields($model);
foreach ($fields as $flag => $date) {
if (true === $runtime || $flag === $runtime) {
$data[$flag] = true;
if ($date) {
$data[$date] = date('Y-m-d H:i:s');
}
if ($flag === $runtime) {
break;
}
}
}
$record = $model->find('first', array(
'fields' => $model->primaryKey,
'conditions' => array($model->primaryKey => $id),
'recursive' => -1
));
if (!empty($record)) {
$model->set($model->primaryKey, $id);
unset($model->data[$model->alias]['modified']);
unset($model->data[$model->alias]['updated']);
return $model->save(array($model->alias => $data), false, array_keys($data));
}
return true;
} | php | public function delete($model, $id) {
$runtime = $this->runtime[$model->alias];
$data = array();
$fields = $this->_normalizeFields($model);
foreach ($fields as $flag => $date) {
if (true === $runtime || $flag === $runtime) {
$data[$flag] = true;
if ($date) {
$data[$date] = date('Y-m-d H:i:s');
}
if ($flag === $runtime) {
break;
}
}
}
$record = $model->find('first', array(
'fields' => $model->primaryKey,
'conditions' => array($model->primaryKey => $id),
'recursive' => -1
));
if (!empty($record)) {
$model->set($model->primaryKey, $id);
unset($model->data[$model->alias]['modified']);
unset($model->data[$model->alias]['updated']);
return $model->save(array($model->alias => $data), false, array_keys($data));
}
return true;
} | [
"public",
"function",
"delete",
"(",
"$",
"model",
",",
"$",
"id",
")",
"{",
"$",
"runtime",
"=",
"$",
"this",
"->",
"runtime",
"[",
"$",
"model",
"->",
"alias",
"]",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"_normalizeFields",
"(",
"$",
"model",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"flag",
"=>",
"$",
"date",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"runtime",
"||",
"$",
"flag",
"===",
"$",
"runtime",
")",
"{",
"$",
"data",
"[",
"$",
"flag",
"]",
"=",
"true",
";",
"if",
"(",
"$",
"date",
")",
"{",
"$",
"data",
"[",
"$",
"date",
"]",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"if",
"(",
"$",
"flag",
"===",
"$",
"runtime",
")",
"{",
"break",
";",
"}",
"}",
"}",
"$",
"record",
"=",
"$",
"model",
"->",
"find",
"(",
"'first'",
",",
"array",
"(",
"'fields'",
"=>",
"$",
"model",
"->",
"primaryKey",
",",
"'conditions'",
"=>",
"array",
"(",
"$",
"model",
"->",
"primaryKey",
"=>",
"$",
"id",
")",
",",
"'recursive'",
"=>",
"-",
"1",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"record",
")",
")",
"{",
"$",
"model",
"->",
"set",
"(",
"$",
"model",
"->",
"primaryKey",
",",
"$",
"id",
")",
";",
"unset",
"(",
"$",
"model",
"->",
"data",
"[",
"$",
"model",
"->",
"alias",
"]",
"[",
"'modified'",
"]",
")",
";",
"unset",
"(",
"$",
"model",
"->",
"data",
"[",
"$",
"model",
"->",
"alias",
"]",
"[",
"'updated'",
"]",
")",
";",
"return",
"$",
"model",
"->",
"save",
"(",
"array",
"(",
"$",
"model",
"->",
"alias",
"=>",
"$",
"data",
")",
",",
"false",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Mark record as deleted
@param object $model
@param integer $id
@return boolean | [
"Mark",
"record",
"as",
"deleted"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L146-L177 |
845 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior.undelete | public function undelete($model, $id) {
$runtime = $this->runtime[$model->alias];
$this->softDelete($model, false);
$data = array();
$fields = $this->_normalizeFields($model);
foreach ($fields as $flag => $date) {
if (true === $runtime || $flag === $runtime) {
$data[$flag] = false;
if ($date) {
$data[$date] = null;
}
if ($flag === $runtime) {
break;
}
}
}
$model->create();
$model->set($model->primaryKey, $id);
$result = $model->save(array($model->alias => $data), false, array_keys($data));
$this->softDelete($model, $runtime);
return $result;
} | php | public function undelete($model, $id) {
$runtime = $this->runtime[$model->alias];
$this->softDelete($model, false);
$data = array();
$fields = $this->_normalizeFields($model);
foreach ($fields as $flag => $date) {
if (true === $runtime || $flag === $runtime) {
$data[$flag] = false;
if ($date) {
$data[$date] = null;
}
if ($flag === $runtime) {
break;
}
}
}
$model->create();
$model->set($model->primaryKey, $id);
$result = $model->save(array($model->alias => $data), false, array_keys($data));
$this->softDelete($model, $runtime);
return $result;
} | [
"public",
"function",
"undelete",
"(",
"$",
"model",
",",
"$",
"id",
")",
"{",
"$",
"runtime",
"=",
"$",
"this",
"->",
"runtime",
"[",
"$",
"model",
"->",
"alias",
"]",
";",
"$",
"this",
"->",
"softDelete",
"(",
"$",
"model",
",",
"false",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"_normalizeFields",
"(",
"$",
"model",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"flag",
"=>",
"$",
"date",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"runtime",
"||",
"$",
"flag",
"===",
"$",
"runtime",
")",
"{",
"$",
"data",
"[",
"$",
"flag",
"]",
"=",
"false",
";",
"if",
"(",
"$",
"date",
")",
"{",
"$",
"data",
"[",
"$",
"date",
"]",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"flag",
"===",
"$",
"runtime",
")",
"{",
"break",
";",
"}",
"}",
"}",
"$",
"model",
"->",
"create",
"(",
")",
";",
"$",
"model",
"->",
"set",
"(",
"$",
"model",
"->",
"primaryKey",
",",
"$",
"id",
")",
";",
"$",
"result",
"=",
"$",
"model",
"->",
"save",
"(",
"array",
"(",
"$",
"model",
"->",
"alias",
"=>",
"$",
"data",
")",
",",
"false",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"softDelete",
"(",
"$",
"model",
",",
"$",
"runtime",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Mark record as not deleted
@param object $model
@param integer $id
@return boolean | [
"Mark",
"record",
"as",
"not",
"deleted"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L186-L209 |
846 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior.purgeDeletedCount | public function purgeDeletedCount($model, $expiration = '-90 days') {
$this->softDelete($model, false);
return $model->find('count', array(
'conditions' => $this->_purgeDeletedConditions($model, $expiration),
'recursive' => -1,
'contain' => array()
)
);
} | php | public function purgeDeletedCount($model, $expiration = '-90 days') {
$this->softDelete($model, false);
return $model->find('count', array(
'conditions' => $this->_purgeDeletedConditions($model, $expiration),
'recursive' => -1,
'contain' => array()
)
);
} | [
"public",
"function",
"purgeDeletedCount",
"(",
"$",
"model",
",",
"$",
"expiration",
"=",
"'-90 days'",
")",
"{",
"$",
"this",
"->",
"softDelete",
"(",
"$",
"model",
",",
"false",
")",
";",
"return",
"$",
"model",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"$",
"this",
"->",
"_purgeDeletedConditions",
"(",
"$",
"model",
",",
"$",
"expiration",
")",
",",
"'recursive'",
"=>",
"-",
"1",
",",
"'contain'",
"=>",
"array",
"(",
")",
")",
")",
";",
"}"
] | Returns number of outdated softdeleted records prepared for purge
@param object $model
@param mixed $expiration anything parseable by strtotime(), by default '-90 days'
@return integer | [
"Returns",
"number",
"of",
"outdated",
"softdeleted",
"records",
"prepared",
"for",
"purge"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L242-L250 |
847 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior._purgeDeletedConditions | protected function _purgeDeletedConditions($model, $expiration = '-90 days') {
$purgeDate = date('Y-m-d H:i:s', strtotime($expiration));
$conditions = array();
foreach ($this->settings[$model->alias] as $flag => $date) {
$conditions[$model->alias . '.' . $flag] = true;
if ($date) {
$conditions[$model->alias . '.' . $date . ' <'] = $purgeDate;
}
}
return $conditions;
} | php | protected function _purgeDeletedConditions($model, $expiration = '-90 days') {
$purgeDate = date('Y-m-d H:i:s', strtotime($expiration));
$conditions = array();
foreach ($this->settings[$model->alias] as $flag => $date) {
$conditions[$model->alias . '.' . $flag] = true;
if ($date) {
$conditions[$model->alias . '.' . $date . ' <'] = $purgeDate;
}
}
return $conditions;
} | [
"protected",
"function",
"_purgeDeletedConditions",
"(",
"$",
"model",
",",
"$",
"expiration",
"=",
"'-90 days'",
")",
"{",
"$",
"purgeDate",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"strtotime",
"(",
"$",
"expiration",
")",
")",
";",
"$",
"conditions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"model",
"->",
"alias",
"]",
"as",
"$",
"flag",
"=>",
"$",
"date",
")",
"{",
"$",
"conditions",
"[",
"$",
"model",
"->",
"alias",
".",
"'.'",
".",
"$",
"flag",
"]",
"=",
"true",
";",
"if",
"(",
"$",
"date",
")",
"{",
"$",
"conditions",
"[",
"$",
"model",
"->",
"alias",
".",
"'.'",
".",
"$",
"date",
".",
"' <'",
"]",
"=",
"$",
"purgeDate",
";",
"}",
"}",
"return",
"$",
"conditions",
";",
"}"
] | Returns conditions for finding outdated records
@param object $model
@param mixed $expiration anything parseable by strtotime(), by default '-90 days'
@return array | [
"Returns",
"conditions",
"for",
"finding",
"outdated",
"records"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L281-L291 |
848 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior._normalizeFields | protected function _normalizeFields($model, $settings = array()) {
if (empty($settings)) {
$settings = $this->settings[$model->alias];
}
$result = array();
foreach ($settings as $flag => $date) {
if (is_numeric($flag)) {
$flag = $date;
$date = false;
}
$result[$flag] = $date;
}
return $result;
} | php | protected function _normalizeFields($model, $settings = array()) {
if (empty($settings)) {
$settings = $this->settings[$model->alias];
}
$result = array();
foreach ($settings as $flag => $date) {
if (is_numeric($flag)) {
$flag = $date;
$date = false;
}
$result[$flag] = $date;
}
return $result;
} | [
"protected",
"function",
"_normalizeFields",
"(",
"$",
"model",
",",
"$",
"settings",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"settings",
")",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"settings",
"[",
"$",
"model",
"->",
"alias",
"]",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"flag",
"=>",
"$",
"date",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"flag",
")",
")",
"{",
"$",
"flag",
"=",
"$",
"date",
";",
"$",
"date",
"=",
"false",
";",
"}",
"$",
"result",
"[",
"$",
"flag",
"]",
"=",
"$",
"date",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Return normalized field array
@param object $model
@param array $settings
@return array | [
"Return",
"normalized",
"field",
"array"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L300-L313 |
849 | RitaCo/cakephp-tools-plugin | Model/Behavior/SoftDeleteBehavior.php | SoftDeleteBehavior._softDeleteAssociations | protected function _softDeleteAssociations($model, $active) {
if (empty($model->belongsTo)) {
return;
}
$fields = array_keys($this->_normalizeFields($model));
$parentModels = array_keys($model->belongsTo);
foreach ($parentModels as $parentModel) {
foreach (array('hasOne', 'hasMany') as $assocType) {
if (empty($model->{$parentModel}->{$assocType})) {
continue;
}
foreach ($model->{$parentModel}->{$assocType} as $assoc => $assocConfig) {
$modelName = empty($assocConfig['className']) ? $assoc : @$assocConfig['className'];
if ((!empty($model->plugin) && strstr($model->plugin . '.', $model->alias) === false ? $model->plugin . '.' : '') . $model->alias !== $modelName) {
continue;
}
$conditions =& $model->{$parentModel}->{$assocType}[$assoc]['conditions'];
if (!is_array($conditions)) {
$model->{$parentModel}->{$assocType}[$assoc]['conditions'] = array();
}
$multiFields = 1 < count($fields);
foreach ($fields as $field) {
if ($active) {
if (!isset($conditions[$field]) && !isset($conditions[$assoc . '.' . $field])) {
if (is_string($active)) {
if ($field == $active) {
$conditions[$assoc . '.' . $field] = false;
} elseif (isset($conditions[$assoc . '.' . $field])) {
unset($conditions[$assoc . '.' . $field]);
}
} elseif (!$multiFields) {
$conditions[$assoc . '.' . $field] = false;
}
}
} elseif (isset($conditions[$assoc . '.' . $field])) {
unset($conditions[$assoc . '.' . $field]);
}
}
}
}
}
} | php | protected function _softDeleteAssociations($model, $active) {
if (empty($model->belongsTo)) {
return;
}
$fields = array_keys($this->_normalizeFields($model));
$parentModels = array_keys($model->belongsTo);
foreach ($parentModels as $parentModel) {
foreach (array('hasOne', 'hasMany') as $assocType) {
if (empty($model->{$parentModel}->{$assocType})) {
continue;
}
foreach ($model->{$parentModel}->{$assocType} as $assoc => $assocConfig) {
$modelName = empty($assocConfig['className']) ? $assoc : @$assocConfig['className'];
if ((!empty($model->plugin) && strstr($model->plugin . '.', $model->alias) === false ? $model->plugin . '.' : '') . $model->alias !== $modelName) {
continue;
}
$conditions =& $model->{$parentModel}->{$assocType}[$assoc]['conditions'];
if (!is_array($conditions)) {
$model->{$parentModel}->{$assocType}[$assoc]['conditions'] = array();
}
$multiFields = 1 < count($fields);
foreach ($fields as $field) {
if ($active) {
if (!isset($conditions[$field]) && !isset($conditions[$assoc . '.' . $field])) {
if (is_string($active)) {
if ($field == $active) {
$conditions[$assoc . '.' . $field] = false;
} elseif (isset($conditions[$assoc . '.' . $field])) {
unset($conditions[$assoc . '.' . $field]);
}
} elseif (!$multiFields) {
$conditions[$assoc . '.' . $field] = false;
}
}
} elseif (isset($conditions[$assoc . '.' . $field])) {
unset($conditions[$assoc . '.' . $field]);
}
}
}
}
}
} | [
"protected",
"function",
"_softDeleteAssociations",
"(",
"$",
"model",
",",
"$",
"active",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"model",
"->",
"belongsTo",
")",
")",
"{",
"return",
";",
"}",
"$",
"fields",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"_normalizeFields",
"(",
"$",
"model",
")",
")",
";",
"$",
"parentModels",
"=",
"array_keys",
"(",
"$",
"model",
"->",
"belongsTo",
")",
";",
"foreach",
"(",
"$",
"parentModels",
"as",
"$",
"parentModel",
")",
"{",
"foreach",
"(",
"array",
"(",
"'hasOne'",
",",
"'hasMany'",
")",
"as",
"$",
"assocType",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"model",
"->",
"{",
"$",
"parentModel",
"}",
"->",
"{",
"$",
"assocType",
"}",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"model",
"->",
"{",
"$",
"parentModel",
"}",
"->",
"{",
"$",
"assocType",
"}",
"as",
"$",
"assoc",
"=>",
"$",
"assocConfig",
")",
"{",
"$",
"modelName",
"=",
"empty",
"(",
"$",
"assocConfig",
"[",
"'className'",
"]",
")",
"?",
"$",
"assoc",
":",
"@",
"$",
"assocConfig",
"[",
"'className'",
"]",
";",
"if",
"(",
"(",
"!",
"empty",
"(",
"$",
"model",
"->",
"plugin",
")",
"&&",
"strstr",
"(",
"$",
"model",
"->",
"plugin",
".",
"'.'",
",",
"$",
"model",
"->",
"alias",
")",
"===",
"false",
"?",
"$",
"model",
"->",
"plugin",
".",
"'.'",
":",
"''",
")",
".",
"$",
"model",
"->",
"alias",
"!==",
"$",
"modelName",
")",
"{",
"continue",
";",
"}",
"$",
"conditions",
"=",
"&",
"$",
"model",
"->",
"{",
"$",
"parentModel",
"}",
"->",
"{",
"$",
"assocType",
"}",
"[",
"$",
"assoc",
"]",
"[",
"'conditions'",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"conditions",
")",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"parentModel",
"}",
"->",
"{",
"$",
"assocType",
"}",
"[",
"$",
"assoc",
"]",
"[",
"'conditions'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"multiFields",
"=",
"1",
"<",
"count",
"(",
"$",
"fields",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"active",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"conditions",
"[",
"$",
"field",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"conditions",
"[",
"$",
"assoc",
".",
"'.'",
".",
"$",
"field",
"]",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"active",
")",
")",
"{",
"if",
"(",
"$",
"field",
"==",
"$",
"active",
")",
"{",
"$",
"conditions",
"[",
"$",
"assoc",
".",
"'.'",
".",
"$",
"field",
"]",
"=",
"false",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"conditions",
"[",
"$",
"assoc",
".",
"'.'",
".",
"$",
"field",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"conditions",
"[",
"$",
"assoc",
".",
"'.'",
".",
"$",
"field",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"multiFields",
")",
"{",
"$",
"conditions",
"[",
"$",
"assoc",
".",
"'.'",
".",
"$",
"field",
"]",
"=",
"false",
";",
"}",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"conditions",
"[",
"$",
"assoc",
".",
"'.'",
".",
"$",
"field",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"conditions",
"[",
"$",
"assoc",
".",
"'.'",
".",
"$",
"field",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | Modifies conditions of hasOne and hasMany associations
If multiple delete flags are configured for model, then $active=true doesn't
do anything - you have to alter conditions in association definition
@param object $model
@param mixed $active | [
"Modifies",
"conditions",
"of",
"hasOne",
"and",
"hasMany",
"associations"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/SoftDeleteBehavior.php#L324-L370 |
850 | dan-har/presentit | src/Present.php | Present.with | public function with($transformer)
{
$concrete = self::getTransformerFactory()->make($transformer);
$this->resource->setTransformer($concrete);
return Presentation::of($this->resource);
} | php | public function with($transformer)
{
$concrete = self::getTransformerFactory()->make($transformer);
$this->resource->setTransformer($concrete);
return Presentation::of($this->resource);
} | [
"public",
"function",
"with",
"(",
"$",
"transformer",
")",
"{",
"$",
"concrete",
"=",
"self",
"::",
"getTransformerFactory",
"(",
")",
"->",
"make",
"(",
"$",
"transformer",
")",
";",
"$",
"this",
"->",
"resource",
"->",
"setTransformer",
"(",
"$",
"concrete",
")",
";",
"return",
"Presentation",
"::",
"of",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"}"
] | Set a transformer on the resource.
@param mixed|callable $transformer
@return \Presentit\Presentation | [
"Set",
"a",
"transformer",
"on",
"the",
"resource",
"."
] | 283db977d5b6d91bc2c139ec377c05010935682d | https://github.com/dan-har/presentit/blob/283db977d5b6d91bc2c139ec377c05010935682d/src/Present.php#L109-L116 |
851 | tomvlk/sweet-orm | src/SweetORM/Database/QueryGenerator.php | QueryGenerator.generateWhere | public function generateWhere($conditions, &$where, &$values, &$types)
{
$where = "";
// When empty where, no conditions, return and set where empty.
if (count($conditions) == 0) {
return;
}
$idx = 0;
$max = count($conditions);
foreach ($conditions as $criteria) {
$column = $criteria['column'];
$operator = $criteria['operator'];
$value = $criteria['value'];
// Prepare where clause
$where .= "$column ";
// Check our operator
if ($operator === "IN") {
// Prepare and loop
$where .= "IN (";
$subIdx = 0;
$subMax = count($value);
foreach ($value as $subValue) {
$where .= "?";
$values[] = $this->prepareData($subValue);
$types[] = $this->determinateType($subValue);
if (($subIdx+1) < $subMax) {
$where .= ",";
}
$subIdx++;
}
$where .= ")";
} else {
// Will add a normal operator
$where .= "$operator ";
$where .= "?";
$values[] = $this->prepareData($value);
$types[] = $this->determinateType($value);
}
// Adding AND if not last
if (($idx + 1) < $max) {
$where .= " AND ";
}
$idx++;
}
} | php | public function generateWhere($conditions, &$where, &$values, &$types)
{
$where = "";
// When empty where, no conditions, return and set where empty.
if (count($conditions) == 0) {
return;
}
$idx = 0;
$max = count($conditions);
foreach ($conditions as $criteria) {
$column = $criteria['column'];
$operator = $criteria['operator'];
$value = $criteria['value'];
// Prepare where clause
$where .= "$column ";
// Check our operator
if ($operator === "IN") {
// Prepare and loop
$where .= "IN (";
$subIdx = 0;
$subMax = count($value);
foreach ($value as $subValue) {
$where .= "?";
$values[] = $this->prepareData($subValue);
$types[] = $this->determinateType($subValue);
if (($subIdx+1) < $subMax) {
$where .= ",";
}
$subIdx++;
}
$where .= ")";
} else {
// Will add a normal operator
$where .= "$operator ";
$where .= "?";
$values[] = $this->prepareData($value);
$types[] = $this->determinateType($value);
}
// Adding AND if not last
if (($idx + 1) < $max) {
$where .= " AND ";
}
$idx++;
}
} | [
"public",
"function",
"generateWhere",
"(",
"$",
"conditions",
",",
"&",
"$",
"where",
",",
"&",
"$",
"values",
",",
"&",
"$",
"types",
")",
"{",
"$",
"where",
"=",
"\"\"",
";",
"// When empty where, no conditions, return and set where empty.",
"if",
"(",
"count",
"(",
"$",
"conditions",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"idx",
"=",
"0",
";",
"$",
"max",
"=",
"count",
"(",
"$",
"conditions",
")",
";",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"criteria",
")",
"{",
"$",
"column",
"=",
"$",
"criteria",
"[",
"'column'",
"]",
";",
"$",
"operator",
"=",
"$",
"criteria",
"[",
"'operator'",
"]",
";",
"$",
"value",
"=",
"$",
"criteria",
"[",
"'value'",
"]",
";",
"// Prepare where clause",
"$",
"where",
".=",
"\"$column \"",
";",
"// Check our operator",
"if",
"(",
"$",
"operator",
"===",
"\"IN\"",
")",
"{",
"// Prepare and loop",
"$",
"where",
".=",
"\"IN (\"",
";",
"$",
"subIdx",
"=",
"0",
";",
"$",
"subMax",
"=",
"count",
"(",
"$",
"value",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"subValue",
")",
"{",
"$",
"where",
".=",
"\"?\"",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"prepareData",
"(",
"$",
"subValue",
")",
";",
"$",
"types",
"[",
"]",
"=",
"$",
"this",
"->",
"determinateType",
"(",
"$",
"subValue",
")",
";",
"if",
"(",
"(",
"$",
"subIdx",
"+",
"1",
")",
"<",
"$",
"subMax",
")",
"{",
"$",
"where",
".=",
"\",\"",
";",
"}",
"$",
"subIdx",
"++",
";",
"}",
"$",
"where",
".=",
"\")\"",
";",
"}",
"else",
"{",
"// Will add a normal operator",
"$",
"where",
".=",
"\"$operator \"",
";",
"$",
"where",
".=",
"\"?\"",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"prepareData",
"(",
"$",
"value",
")",
";",
"$",
"types",
"[",
"]",
"=",
"$",
"this",
"->",
"determinateType",
"(",
"$",
"value",
")",
";",
"}",
"// Adding AND if not last",
"if",
"(",
"(",
"$",
"idx",
"+",
"1",
")",
"<",
"$",
"max",
")",
"{",
"$",
"where",
".=",
"\" AND \"",
";",
"}",
"$",
"idx",
"++",
";",
"}",
"}"
] | Generate Where clause
@param array $conditions
@param string $where Reference of where string
@param array $values Reference of binding values to append
@param array $types Reference of binding value types to append | [
"Generate",
"Where",
"clause"
] | bca014a9f83be34c87b14d6c8a36156e24577374 | https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/QueryGenerator.php#L73-L127 |
852 | tomvlk/sweet-orm | src/SweetORM/Database/QueryGenerator.php | QueryGenerator.generateOrder | public function generateOrder($sortBy, $sortOrder, &$order)
{
if (! empty($sortBy)) {
if (empty($sortOrder)) { // @codeCoverageIgnore
$sortOrder = "ASC"; // @codeCoverageIgnore
} // @codeCoverageIgnore
$order = "$sortBy $sortOrder";
}
} | php | public function generateOrder($sortBy, $sortOrder, &$order)
{
if (! empty($sortBy)) {
if (empty($sortOrder)) { // @codeCoverageIgnore
$sortOrder = "ASC"; // @codeCoverageIgnore
} // @codeCoverageIgnore
$order = "$sortBy $sortOrder";
}
} | [
"public",
"function",
"generateOrder",
"(",
"$",
"sortBy",
",",
"$",
"sortOrder",
",",
"&",
"$",
"order",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"sortBy",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"sortOrder",
")",
")",
"{",
"// @codeCoverageIgnore",
"$",
"sortOrder",
"=",
"\"ASC\"",
";",
"// @codeCoverageIgnore",
"}",
"// @codeCoverageIgnore",
"$",
"order",
"=",
"\"$sortBy $sortOrder\"",
";",
"}",
"}"
] | Generate Order By
@param string $sortBy Column name
@param string $sortOrder Type of order
@param string $order Reference to Order result | [
"Generate",
"Order",
"By"
] | bca014a9f83be34c87b14d6c8a36156e24577374 | https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/QueryGenerator.php#L136-L145 |
853 | tomvlk/sweet-orm | src/SweetORM/Database/QueryGenerator.php | QueryGenerator.generateLimit | public function generateLimit($limitCount, $limitOffset, &$limit)
{
$limit = "";
if (empty($limitCount)) {
return;
}
$limit = "$limitCount";
if (! empty($limitOffset)) {
$limit .= ",$limitOffset";
}
} | php | public function generateLimit($limitCount, $limitOffset, &$limit)
{
$limit = "";
if (empty($limitCount)) {
return;
}
$limit = "$limitCount";
if (! empty($limitOffset)) {
$limit .= ",$limitOffset";
}
} | [
"public",
"function",
"generateLimit",
"(",
"$",
"limitCount",
",",
"$",
"limitOffset",
",",
"&",
"$",
"limit",
")",
"{",
"$",
"limit",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"limitCount",
")",
")",
"{",
"return",
";",
"}",
"$",
"limit",
"=",
"\"$limitCount\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"limitOffset",
")",
")",
"{",
"$",
"limit",
".=",
"\",$limitOffset\"",
";",
"}",
"}"
] | Generate Limit part
@param int $limitCount
@param int $limitOffset
@param string $limit Reference for the resulting query part | [
"Generate",
"Limit",
"part"
] | bca014a9f83be34c87b14d6c8a36156e24577374 | https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/QueryGenerator.php#L155-L168 |
854 | tomvlk/sweet-orm | src/SweetORM/Database/QueryGenerator.php | QueryGenerator.generateInsert | public function generateInsert($columnOrder, $changeData, &$start, &$data, &$values, &$types)
{
// Prepare
$start = "(";
$data = "(";
// Generate the column definition
$idx = 0;
$max = count($columnOrder);
foreach ($columnOrder as $column) {
// Get value for column
$value = null;
if (isset($changeData[$column->name])) {
$value = $changeData[$column->name];
}
// Add to the definition line
$start .= "`".$column->name."`";
// Add to the values line
$data .= "?";
$values[] = $this->prepareData($changeData[$column->name]);
$types[] = $this->determinateType($changeData[$column->name]);
// Adding ,
if (($idx + 1) < $max) {
$start .= ",";
$data .= ",";
}
$idx++;
}
// Finish start and data
$start .= ")";
$data .= ")";
} | php | public function generateInsert($columnOrder, $changeData, &$start, &$data, &$values, &$types)
{
// Prepare
$start = "(";
$data = "(";
// Generate the column definition
$idx = 0;
$max = count($columnOrder);
foreach ($columnOrder as $column) {
// Get value for column
$value = null;
if (isset($changeData[$column->name])) {
$value = $changeData[$column->name];
}
// Add to the definition line
$start .= "`".$column->name."`";
// Add to the values line
$data .= "?";
$values[] = $this->prepareData($changeData[$column->name]);
$types[] = $this->determinateType($changeData[$column->name]);
// Adding ,
if (($idx + 1) < $max) {
$start .= ",";
$data .= ",";
}
$idx++;
}
// Finish start and data
$start .= ")";
$data .= ")";
} | [
"public",
"function",
"generateInsert",
"(",
"$",
"columnOrder",
",",
"$",
"changeData",
",",
"&",
"$",
"start",
",",
"&",
"$",
"data",
",",
"&",
"$",
"values",
",",
"&",
"$",
"types",
")",
"{",
"// Prepare",
"$",
"start",
"=",
"\"(\"",
";",
"$",
"data",
"=",
"\"(\"",
";",
"// Generate the column definition",
"$",
"idx",
"=",
"0",
";",
"$",
"max",
"=",
"count",
"(",
"$",
"columnOrder",
")",
";",
"foreach",
"(",
"$",
"columnOrder",
"as",
"$",
"column",
")",
"{",
"// Get value for column",
"$",
"value",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"changeData",
"[",
"$",
"column",
"->",
"name",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"changeData",
"[",
"$",
"column",
"->",
"name",
"]",
";",
"}",
"// Add to the definition line",
"$",
"start",
".=",
"\"`\"",
".",
"$",
"column",
"->",
"name",
".",
"\"`\"",
";",
"// Add to the values line",
"$",
"data",
".=",
"\"?\"",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"prepareData",
"(",
"$",
"changeData",
"[",
"$",
"column",
"->",
"name",
"]",
")",
";",
"$",
"types",
"[",
"]",
"=",
"$",
"this",
"->",
"determinateType",
"(",
"$",
"changeData",
"[",
"$",
"column",
"->",
"name",
"]",
")",
";",
"// Adding ,",
"if",
"(",
"(",
"$",
"idx",
"+",
"1",
")",
"<",
"$",
"max",
")",
"{",
"$",
"start",
".=",
"\",\"",
";",
"$",
"data",
".=",
"\",\"",
";",
"}",
"$",
"idx",
"++",
";",
"}",
"// Finish start and data",
"$",
"start",
".=",
"\")\"",
";",
"$",
"data",
".=",
"\")\"",
";",
"}"
] | Generate Insert parts
@param Column[] $columnOrder
@param array $changeData
@param string $start Reference: COLUMN definition part
@param string $data Reference: VALUES () part
@param array $values Reference: binding values
@param array $types Reference: binding types | [
"Generate",
"Insert",
"parts"
] | bca014a9f83be34c87b14d6c8a36156e24577374 | https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/QueryGenerator.php#L181-L217 |
855 | tomvlk/sweet-orm | src/SweetORM/Database/QueryGenerator.php | QueryGenerator.generateUpdate | public function generateUpdate($changeData, &$data, &$values, &$types)
{
// Prepare
$data = "";
// Generate the column definition
$idx = 0;
$max = count($changeData);
foreach ($changeData as $column => $value) {
// Prepare set part
$data .= "$column = ?";
$values[] = $this->prepareData($value);
$types[] = $this->determinateType($value);
// Adding ,
if (($idx + 1) < $max) {
$data .= ",";
}
$idx++;
}
} | php | public function generateUpdate($changeData, &$data, &$values, &$types)
{
// Prepare
$data = "";
// Generate the column definition
$idx = 0;
$max = count($changeData);
foreach ($changeData as $column => $value) {
// Prepare set part
$data .= "$column = ?";
$values[] = $this->prepareData($value);
$types[] = $this->determinateType($value);
// Adding ,
if (($idx + 1) < $max) {
$data .= ",";
}
$idx++;
}
} | [
"public",
"function",
"generateUpdate",
"(",
"$",
"changeData",
",",
"&",
"$",
"data",
",",
"&",
"$",
"values",
",",
"&",
"$",
"types",
")",
"{",
"// Prepare",
"$",
"data",
"=",
"\"\"",
";",
"// Generate the column definition",
"$",
"idx",
"=",
"0",
";",
"$",
"max",
"=",
"count",
"(",
"$",
"changeData",
")",
";",
"foreach",
"(",
"$",
"changeData",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"// Prepare set part",
"$",
"data",
".=",
"\"$column = ?\"",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"prepareData",
"(",
"$",
"value",
")",
";",
"$",
"types",
"[",
"]",
"=",
"$",
"this",
"->",
"determinateType",
"(",
"$",
"value",
")",
";",
"// Adding ,",
"if",
"(",
"(",
"$",
"idx",
"+",
"1",
")",
"<",
"$",
"max",
")",
"{",
"$",
"data",
".=",
"\",\"",
";",
"}",
"$",
"idx",
"++",
";",
"}",
"}"
] | Generate Update Lines
@param array $changeData
@param string $data Reference: Data (set) line
@param array $values Reference: Bind values
@param array $types Reference: Bind types | [
"Generate",
"Update",
"Lines"
] | bca014a9f83be34c87b14d6c8a36156e24577374 | https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Database/QueryGenerator.php#L227-L248 |
856 | newmythmedia/timer | src/Timer.php | Timer.start | public function start($key)
{
$key = strtolower($key);
$this->benchmarks[$key] = [
'start_time' => microtime(true),
'stop_time' => 0.0,
'avg_time' => 0.0,
'start_memory' => memory_get_usage(true),
'stop_memory' => 0,
'avg_memory' => 0,
'peak_memory' => 0,
'running' => true
];
} | php | public function start($key)
{
$key = strtolower($key);
$this->benchmarks[$key] = [
'start_time' => microtime(true),
'stop_time' => 0.0,
'avg_time' => 0.0,
'start_memory' => memory_get_usage(true),
'stop_memory' => 0,
'avg_memory' => 0,
'peak_memory' => 0,
'running' => true
];
} | [
"public",
"function",
"start",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"benchmarks",
"[",
"$",
"key",
"]",
"=",
"[",
"'start_time'",
"=>",
"microtime",
"(",
"true",
")",
",",
"'stop_time'",
"=>",
"0.0",
",",
"'avg_time'",
"=>",
"0.0",
",",
"'start_memory'",
"=>",
"memory_get_usage",
"(",
"true",
")",
",",
"'stop_memory'",
"=>",
"0",
",",
"'avg_memory'",
"=>",
"0",
",",
"'peak_memory'",
"=>",
"0",
",",
"'running'",
"=>",
"true",
"]",
";",
"}"
] | Starts a benchmark running.
@param $key | [
"Starts",
"a",
"benchmark",
"running",
"."
] | 1363fcd674b75e5ebdbc0b65f18b66689008c247 | https://github.com/newmythmedia/timer/blob/1363fcd674b75e5ebdbc0b65f18b66689008c247/src/Timer.php#L19-L33 |
857 | newmythmedia/timer | src/Timer.php | Timer.stop | public function stop($key)
{
$benchmark = $this->get($key);
$benchmark['stop_time'] = microtime(true);
$benchmark['avg_time'] = $benchmark['stop_time'] - $benchmark['start_time'];
$benchmark['stop_memory'] = memory_get_usage(true);
$benchmark['avg_memory'] = ( ($benchmark['stop_memory'] - $benchmark['start_memory']) / 1024 ) / 1024;
$benchmark['peak_memory'] = memory_get_peak_usage(true) / 1024 / 1024;
$benchmark['running'] = false;
$this->benchmarks[$key] = $benchmark;
} | php | public function stop($key)
{
$benchmark = $this->get($key);
$benchmark['stop_time'] = microtime(true);
$benchmark['avg_time'] = $benchmark['stop_time'] - $benchmark['start_time'];
$benchmark['stop_memory'] = memory_get_usage(true);
$benchmark['avg_memory'] = ( ($benchmark['stop_memory'] - $benchmark['start_memory']) / 1024 ) / 1024;
$benchmark['peak_memory'] = memory_get_peak_usage(true) / 1024 / 1024;
$benchmark['running'] = false;
$this->benchmarks[$key] = $benchmark;
} | [
"public",
"function",
"stop",
"(",
"$",
"key",
")",
"{",
"$",
"benchmark",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"benchmark",
"[",
"'stop_time'",
"]",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"benchmark",
"[",
"'avg_time'",
"]",
"=",
"$",
"benchmark",
"[",
"'stop_time'",
"]",
"-",
"$",
"benchmark",
"[",
"'start_time'",
"]",
";",
"$",
"benchmark",
"[",
"'stop_memory'",
"]",
"=",
"memory_get_usage",
"(",
"true",
")",
";",
"$",
"benchmark",
"[",
"'avg_memory'",
"]",
"=",
"(",
"(",
"$",
"benchmark",
"[",
"'stop_memory'",
"]",
"-",
"$",
"benchmark",
"[",
"'start_memory'",
"]",
")",
"/",
"1024",
")",
"/",
"1024",
";",
"$",
"benchmark",
"[",
"'peak_memory'",
"]",
"=",
"memory_get_peak_usage",
"(",
"true",
")",
"/",
"1024",
"/",
"1024",
";",
"$",
"benchmark",
"[",
"'running'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"benchmarks",
"[",
"$",
"key",
"]",
"=",
"$",
"benchmark",
";",
"}"
] | Stops a timer running and calculates the statistics.
@param $key | [
"Stops",
"a",
"timer",
"running",
"and",
"calculates",
"the",
"statistics",
"."
] | 1363fcd674b75e5ebdbc0b65f18b66689008c247 | https://github.com/newmythmedia/timer/blob/1363fcd674b75e5ebdbc0b65f18b66689008c247/src/Timer.php#L42-L54 |
858 | newmythmedia/timer | src/Timer.php | Timer.get | public function get($key)
{
$key = strtolower($key);
if (! array_key_exists($key, $this->benchmarks))
{
throw new \RuntimeException('No Benchmark exists for: '. $key);
}
return $this->benchmarks[$key];
} | php | public function get($key)
{
$key = strtolower($key);
if (! array_key_exists($key, $this->benchmarks))
{
throw new \RuntimeException('No Benchmark exists for: '. $key);
}
return $this->benchmarks[$key];
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"benchmarks",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No Benchmark exists for: '",
".",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
"->",
"benchmarks",
"[",
"$",
"key",
"]",
";",
"}"
] | Returns a single benchmark item.
@param $key
@return mixed | [
"Returns",
"a",
"single",
"benchmark",
"item",
"."
] | 1363fcd674b75e5ebdbc0b65f18b66689008c247 | https://github.com/newmythmedia/timer/blob/1363fcd674b75e5ebdbc0b65f18b66689008c247/src/Timer.php#L76-L86 |
859 | newmythmedia/timer | src/Timer.php | Timer.output | public function output($key)
{
$key = strtolower($key);
$benchmark = $this->get($key);
return sprintf('[%s] %s seconds, %sMB memory (%sMB peak)',
$key,
number_format($benchmark['avg_time'], 4),
number_format($benchmark['avg_memory'], 2),
number_format($benchmark['peak_memory'], 2)
);
} | php | public function output($key)
{
$key = strtolower($key);
$benchmark = $this->get($key);
return sprintf('[%s] %s seconds, %sMB memory (%sMB peak)',
$key,
number_format($benchmark['avg_time'], 4),
number_format($benchmark['avg_memory'], 2),
number_format($benchmark['peak_memory'], 2)
);
} | [
"public",
"function",
"output",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"$",
"benchmark",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"return",
"sprintf",
"(",
"'[%s] %s seconds, %sMB memory (%sMB peak)'",
",",
"$",
"key",
",",
"number_format",
"(",
"$",
"benchmark",
"[",
"'avg_time'",
"]",
",",
"4",
")",
",",
"number_format",
"(",
"$",
"benchmark",
"[",
"'avg_memory'",
"]",
",",
"2",
")",
",",
"number_format",
"(",
"$",
"benchmark",
"[",
"'peak_memory'",
"]",
",",
"2",
")",
")",
";",
"}"
] | Returns a single benchmark formatted as a string.
@param $key
@return string | [
"Returns",
"a",
"single",
"benchmark",
"formatted",
"as",
"a",
"string",
"."
] | 1363fcd674b75e5ebdbc0b65f18b66689008c247 | https://github.com/newmythmedia/timer/blob/1363fcd674b75e5ebdbc0b65f18b66689008c247/src/Timer.php#L96-L108 |
860 | lucifurious/kisma | src/Kisma/Core/Utility/Sql.php | Sql.createStatement | public static function createStatement( $sql, &$connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
$_db = self::_checkConnection( $connection );
/** @var $_statement \PDOStatement */
$_statement = $_db->prepare( $sql );
if ( false !== $fetchMode )
{
$_statement->setFetchMode( $fetchMode );
}
return $_statement;
} | php | public static function createStatement( $sql, &$connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
$_db = self::_checkConnection( $connection );
/** @var $_statement \PDOStatement */
$_statement = $_db->prepare( $sql );
if ( false !== $fetchMode )
{
$_statement->setFetchMode( $fetchMode );
}
return $_statement;
} | [
"public",
"static",
"function",
"createStatement",
"(",
"$",
"sql",
",",
"&",
"$",
"connection",
"=",
"null",
",",
"$",
"fetchMode",
"=",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
"{",
"$",
"_db",
"=",
"self",
"::",
"_checkConnection",
"(",
"$",
"connection",
")",
";",
"/** @var $_statement \\PDOStatement */",
"$",
"_statement",
"=",
"$",
"_db",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"fetchMode",
")",
"{",
"$",
"_statement",
"->",
"setFetchMode",
"(",
"$",
"fetchMode",
")",
";",
"}",
"return",
"$",
"_statement",
";",
"}"
] | Creates and returns an optionally parameter-bound \PDOStatement object
@param string $sql
@param \PDO $connection
@param int $fetchMode Set to false to not touch fetch mode
@return \PDOStatement | [
"Creates",
"and",
"returns",
"an",
"optionally",
"parameter",
"-",
"bound",
"\\",
"PDOStatement",
"object"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Sql.php#L75-L88 |
861 | lucifurious/kisma | src/Kisma/Core/Utility/Sql.php | Sql.query | public static function query( $sql, $parameters = null, &$connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
return DataReader::create( $sql, $parameters, $connection, $fetchMode );
} | php | public static function query( $sql, $parameters = null, &$connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
return DataReader::create( $sql, $parameters, $connection, $fetchMode );
} | [
"public",
"static",
"function",
"query",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"null",
",",
"&",
"$",
"connection",
"=",
"null",
",",
"$",
"fetchMode",
"=",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
"{",
"return",
"DataReader",
"::",
"create",
"(",
"$",
"sql",
",",
"$",
"parameters",
",",
"$",
"connection",
",",
"$",
"fetchMode",
")",
";",
"}"
] | Creates and returns an optionally parameter-bound \PDOStatement object suitable for iteration
@param string $sql
@param array $parameters
@param \PDO $connection
@param int $fetchMode Set to false to not touch fetch mode
@return \Kisma\Core\Tools\DataReader | [
"Creates",
"and",
"returns",
"an",
"optionally",
"parameter",
"-",
"bound",
"\\",
"PDOStatement",
"object",
"suitable",
"for",
"iteration"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Sql.php#L100-L103 |
862 | lucifurious/kisma | src/Kisma/Core/Utility/Sql.php | Sql.execute | public static function execute( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
self::$_statement = self::createStatement( $sql, $connection, $fetchMode );
if ( empty( $parameters ) )
{
return self::$_statement->execute();
}
return self::$_statement->execute( $parameters );
} | php | public static function execute( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
self::$_statement = self::createStatement( $sql, $connection, $fetchMode );
if ( empty( $parameters ) )
{
return self::$_statement->execute();
}
return self::$_statement->execute( $parameters );
} | [
"public",
"static",
"function",
"execute",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"null",
",",
"$",
"connection",
"=",
"null",
",",
"$",
"fetchMode",
"=",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
"{",
"self",
"::",
"$",
"_statement",
"=",
"self",
"::",
"createStatement",
"(",
"$",
"sql",
",",
"$",
"connection",
",",
"$",
"fetchMode",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"return",
"self",
"::",
"$",
"_statement",
"->",
"execute",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_statement",
"->",
"execute",
"(",
"$",
"parameters",
")",
";",
"}"
] | Executes a SQL statement
@param string $sql
@param array $parameters
@param \PDO $connection
@param int $fetchMode
@return int The number of affected rows | [
"Executes",
"a",
"SQL",
"statement"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Sql.php#L115-L125 |
863 | lucifurious/kisma | src/Kisma/Core/Utility/Sql.php | Sql.find | public static function find( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
if ( false === ( $_reader = self::query( $sql, $parameters, $connection, $fetchMode ) ) )
{
return null;
}
return $_reader->fetch();
} | php | public static function find( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
if ( false === ( $_reader = self::query( $sql, $parameters, $connection, $fetchMode ) ) )
{
return null;
}
return $_reader->fetch();
} | [
"public",
"static",
"function",
"find",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"null",
",",
"$",
"connection",
"=",
"null",
",",
"$",
"fetchMode",
"=",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"_reader",
"=",
"self",
"::",
"query",
"(",
"$",
"sql",
",",
"$",
"parameters",
",",
"$",
"connection",
",",
"$",
"fetchMode",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"_reader",
"->",
"fetch",
"(",
")",
";",
"}"
] | Executes a SQL query
@param string $sql
@param array $parameters
@param \PDO $connection
@param int $fetchMode
@return null|array | [
"Executes",
"a",
"SQL",
"query"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Sql.php#L137-L145 |
864 | lucifurious/kisma | src/Kisma/Core/Utility/Sql.php | Sql.findAll | public static function findAll( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
if ( false === ( $_reader = self::query( $sql, $parameters, $connection, $fetchMode ) ) )
{
return null;
}
return $_reader->fetchAll();
} | php | public static function findAll( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
if ( false === ( $_reader = self::query( $sql, $parameters, $connection, $fetchMode ) ) )
{
return null;
}
return $_reader->fetchAll();
} | [
"public",
"static",
"function",
"findAll",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"null",
",",
"$",
"connection",
"=",
"null",
",",
"$",
"fetchMode",
"=",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"_reader",
"=",
"self",
"::",
"query",
"(",
"$",
"sql",
",",
"$",
"parameters",
",",
"$",
"connection",
",",
"$",
"fetchMode",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"_reader",
"->",
"fetchAll",
"(",
")",
";",
"}"
] | Executes the given sql statement and returns all results
@param string $sql
@param array $parameters
@param \PDO $connection
@param int $fetchMode
@return array|bool | [
"Executes",
"the",
"given",
"sql",
"statement",
"and",
"returns",
"all",
"results"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Sql.php#L157-L165 |
865 | lucifurious/kisma | src/Kisma/Core/Utility/Sql.php | Sql.scalar | public static function scalar( $sql, $columnNumber = 0, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
if ( false === ( $_reader = self::query( $sql, $parameters, $connection, $fetchMode ) ) )
{
return null;
}
return $_reader->fetchColumn( $columnNumber );
} | php | public static function scalar( $sql, $columnNumber = 0, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
{
if ( false === ( $_reader = self::query( $sql, $parameters, $connection, $fetchMode ) ) )
{
return null;
}
return $_reader->fetchColumn( $columnNumber );
} | [
"public",
"static",
"function",
"scalar",
"(",
"$",
"sql",
",",
"$",
"columnNumber",
"=",
"0",
",",
"$",
"parameters",
"=",
"null",
",",
"$",
"connection",
"=",
"null",
",",
"$",
"fetchMode",
"=",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"_reader",
"=",
"self",
"::",
"query",
"(",
"$",
"sql",
",",
"$",
"parameters",
",",
"$",
"connection",
",",
"$",
"fetchMode",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"_reader",
"->",
"fetchColumn",
"(",
"$",
"columnNumber",
")",
";",
"}"
] | Returns the first column of the first row or null
@param string $sql
@param int $columnNumber
@param array $parameters
@param \PDO $connection
@param int $fetchMode
@return mixed | [
"Returns",
"the",
"first",
"column",
"of",
"the",
"first",
"row",
"or",
"null"
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Sql.php#L179-L187 |
866 | Dhii/state-machine-abstract | src/StateMachineAwareTrait.php | StateMachineAwareTrait._setStateMachine | protected function _setStateMachine($stateMachine)
{
if ($stateMachine !== null && !($stateMachine instanceof StateMachineInterface)) {
throw $this->_createInvalidArgumentException(
$this->__('Argument is not a valid state machine instance'),
null,
null,
$stateMachine
);
}
$this->stateMachine = $stateMachine;
} | php | protected function _setStateMachine($stateMachine)
{
if ($stateMachine !== null && !($stateMachine instanceof StateMachineInterface)) {
throw $this->_createInvalidArgumentException(
$this->__('Argument is not a valid state machine instance'),
null,
null,
$stateMachine
);
}
$this->stateMachine = $stateMachine;
} | [
"protected",
"function",
"_setStateMachine",
"(",
"$",
"stateMachine",
")",
"{",
"if",
"(",
"$",
"stateMachine",
"!==",
"null",
"&&",
"!",
"(",
"$",
"stateMachine",
"instanceof",
"StateMachineInterface",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Argument is not a valid state machine instance'",
")",
",",
"null",
",",
"null",
",",
"$",
"stateMachine",
")",
";",
"}",
"$",
"this",
"->",
"stateMachine",
"=",
"$",
"stateMachine",
";",
"}"
] | Sets the state machine for this instance.
@since [*next-version*]
@param StateMachineInterface|null $stateMachine The state machine instance or null | [
"Sets",
"the",
"state",
"machine",
"for",
"this",
"instance",
"."
] | cb5f706edd74d1c747f09f505b859255b13a5b27 | https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/StateMachineAwareTrait.php#L44-L56 |
867 | vtardia/cli-parser | src/CLIParser.php | CLIParser.setEnv | public function setEnv($shortOptions = '', array $longOptions = array(), array $argv = array())
{
if (!empty($argv)) {
$this->argv = $argv;
$this->argc = count($argv);
}
$this->shortOptions = $shortOptions;
$this->longOptions = $longOptions;
$this->program = $this->argv[0];
} | php | public function setEnv($shortOptions = '', array $longOptions = array(), array $argv = array())
{
if (!empty($argv)) {
$this->argv = $argv;
$this->argc = count($argv);
}
$this->shortOptions = $shortOptions;
$this->longOptions = $longOptions;
$this->program = $this->argv[0];
} | [
"public",
"function",
"setEnv",
"(",
"$",
"shortOptions",
"=",
"''",
",",
"array",
"$",
"longOptions",
"=",
"array",
"(",
")",
",",
"array",
"$",
"argv",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"argv",
")",
")",
"{",
"$",
"this",
"->",
"argv",
"=",
"$",
"argv",
";",
"$",
"this",
"->",
"argc",
"=",
"count",
"(",
"$",
"argv",
")",
";",
"}",
"$",
"this",
"->",
"shortOptions",
"=",
"$",
"shortOptions",
";",
"$",
"this",
"->",
"longOptions",
"=",
"$",
"longOptions",
";",
"$",
"this",
"->",
"program",
"=",
"$",
"this",
"->",
"argv",
"[",
"0",
"]",
";",
"}"
] | Sets the working environment for the program
Creates local copies of global $argv and $argc and allows to rewrite the $argv array
@param string $shortOptions A string of allowed single-char options.
Parametrized options are followed by the ':' character
@param array $longOptions An array of allowed long options which contains:
name (string), parameter need (boolean TRUE/FALSE) and
optional short-option equivalent (char)
@param array $argv An array of arguments formatted as the real $argv
@return void | [
"Sets",
"the",
"working",
"environment",
"for",
"the",
"program"
] | 29a1de575f5759d28f3bc920a69ec883ceeba1e8 | https://github.com/vtardia/cli-parser/blob/29a1de575f5759d28f3bc920a69ec883ceeba1e8/src/CLIParser.php#L144-L157 |
868 | vtardia/cli-parser | src/CLIParser.php | CLIParser.options | public function options($start = 1)
{
// Init index
$this->optind = (0 == ($start)) ? 1 : (int) $start;
// Loop the arguments until there is no option (-1)
// At the end of the loop $this->optind points to the first non-option
// parameter
do {
$nextOption = $this->getopt();
// If the option is an option (!== -1) and is valid (not null)
// set it's value and put it in the options array to return
if (null !== $nextOption && -1 !== $nextOption) {
$this->options[$nextOption] = (null !== $this->optarg) ? $this->optarg : true;
}
} while ($nextOption !== -1);
return $this->options;
} | php | public function options($start = 1)
{
// Init index
$this->optind = (0 == ($start)) ? 1 : (int) $start;
// Loop the arguments until there is no option (-1)
// At the end of the loop $this->optind points to the first non-option
// parameter
do {
$nextOption = $this->getopt();
// If the option is an option (!== -1) and is valid (not null)
// set it's value and put it in the options array to return
if (null !== $nextOption && -1 !== $nextOption) {
$this->options[$nextOption] = (null !== $this->optarg) ? $this->optarg : true;
}
} while ($nextOption !== -1);
return $this->options;
} | [
"public",
"function",
"options",
"(",
"$",
"start",
"=",
"1",
")",
"{",
"// Init index",
"$",
"this",
"->",
"optind",
"=",
"(",
"0",
"==",
"(",
"$",
"start",
")",
")",
"?",
"1",
":",
"(",
"int",
")",
"$",
"start",
";",
"// Loop the arguments until there is no option (-1)",
"// At the end of the loop $this->optind points to the first non-option",
"// parameter",
"do",
"{",
"$",
"nextOption",
"=",
"$",
"this",
"->",
"getopt",
"(",
")",
";",
"// If the option is an option (!== -1) and is valid (not null)",
"// set it's value and put it in the options array to return",
"if",
"(",
"null",
"!==",
"$",
"nextOption",
"&&",
"-",
"1",
"!==",
"$",
"nextOption",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"nextOption",
"]",
"=",
"(",
"null",
"!==",
"$",
"this",
"->",
"optarg",
")",
"?",
"$",
"this",
"->",
"optarg",
":",
"true",
";",
"}",
"}",
"while",
"(",
"$",
"nextOption",
"!==",
"-",
"1",
")",
";",
"return",
"$",
"this",
"->",
"options",
";",
"}"
] | Return all the options in an associative array where the key is the option's name
For options that act like switches (eg. -v) the array value is TRUE
($options['v'] => true)
For options that require a parameter (eg. -o filename) the array value is the
parameter value ($options['o'] => "filename")
@param int $start Initial index to start with, in order to allow the syntax
'program command [options] [arguments]'
@return array | [
"Return",
"all",
"the",
"options",
"in",
"an",
"associative",
"array",
"where",
"the",
"key",
"is",
"the",
"option",
"s",
"name"
] | 29a1de575f5759d28f3bc920a69ec883ceeba1e8 | https://github.com/vtardia/cli-parser/blob/29a1de575f5759d28f3bc920a69ec883ceeba1e8/src/CLIParser.php#L174-L195 |
869 | vtardia/cli-parser | src/CLIParser.php | CLIParser.arguments | public function arguments()
{
if ($this->optind < $this->argc) {
for ($i = $this->optind; $i < $this->argc; $i++) {
$this->arguments[] = $this->argv[$i];
}
}
return $this->arguments;
} | php | public function arguments()
{
if ($this->optind < $this->argc) {
for ($i = $this->optind; $i < $this->argc; $i++) {
$this->arguments[] = $this->argv[$i];
}
}
return $this->arguments;
} | [
"public",
"function",
"arguments",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"optind",
"<",
"$",
"this",
"->",
"argc",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"optind",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"argc",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"arguments",
"[",
"]",
"=",
"$",
"this",
"->",
"argv",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"arguments",
";",
"}"
] | Returns program's arguments
An argument is everything that is not an option, for example a file path
@return array | [
"Returns",
"program",
"s",
"arguments"
] | 29a1de575f5759d28f3bc920a69ec883ceeba1e8 | https://github.com/vtardia/cli-parser/blob/29a1de575f5759d28f3bc920a69ec883ceeba1e8/src/CLIParser.php#L205-L216 |
870 | vtardia/cli-parser | src/CLIParser.php | CLIParser.getopt | private function getopt()
{
// Reset option argument
$this->optarg = null;
// Check for index validity
if ($this->optind >= $this->argc) {
return -1;
}
// Get a copy of the current option to examine
$arg = $this->argv[$this->optind];
if ($this->isLongOption($arg)) {
return $this->parseLongOption($arg);
}
if ($this->isShortOption($arg)) {
return $this->parseShortOption($arg);
}
// If it's not an option, it's an argument,
// so we stop parsing at the first non-option string
// and $this->optind points to the first argument
// Default: no options found
return -1;
} | php | private function getopt()
{
// Reset option argument
$this->optarg = null;
// Check for index validity
if ($this->optind >= $this->argc) {
return -1;
}
// Get a copy of the current option to examine
$arg = $this->argv[$this->optind];
if ($this->isLongOption($arg)) {
return $this->parseLongOption($arg);
}
if ($this->isShortOption($arg)) {
return $this->parseShortOption($arg);
}
// If it's not an option, it's an argument,
// so we stop parsing at the first non-option string
// and $this->optind points to the first argument
// Default: no options found
return -1;
} | [
"private",
"function",
"getopt",
"(",
")",
"{",
"// Reset option argument",
"$",
"this",
"->",
"optarg",
"=",
"null",
";",
"// Check for index validity",
"if",
"(",
"$",
"this",
"->",
"optind",
">=",
"$",
"this",
"->",
"argc",
")",
"{",
"return",
"-",
"1",
";",
"}",
"// Get a copy of the current option to examine",
"$",
"arg",
"=",
"$",
"this",
"->",
"argv",
"[",
"$",
"this",
"->",
"optind",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isLongOption",
"(",
"$",
"arg",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parseLongOption",
"(",
"$",
"arg",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isShortOption",
"(",
"$",
"arg",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parseShortOption",
"(",
"$",
"arg",
")",
";",
"}",
"// If it's not an option, it's an argument,",
"// so we stop parsing at the first non-option string",
"// and $this->optind points to the first argument",
"// Default: no options found",
"return",
"-",
"1",
";",
"}"
] | Searches for a valid next option
If the option is not valid returns NULL, if there is no option returns -1
@return mixed | NULL | [
"Searches",
"for",
"a",
"valid",
"next",
"option"
] | 29a1de575f5759d28f3bc920a69ec883ceeba1e8 | https://github.com/vtardia/cli-parser/blob/29a1de575f5759d28f3bc920a69ec883ceeba1e8/src/CLIParser.php#L237-L265 |
871 | vtardia/cli-parser | src/CLIParser.php | CLIParser.getLongOptionKey | private function getLongOptionKey($arg)
{
$key = (false !== ($eqPos = strpos($arg, '='))) ?
substr($arg, 2, $eqPos - 2) : // --key=value
substr($arg, 2); // --key value
return $key;
} | php | private function getLongOptionKey($arg)
{
$key = (false !== ($eqPos = strpos($arg, '='))) ?
substr($arg, 2, $eqPos - 2) : // --key=value
substr($arg, 2); // --key value
return $key;
} | [
"private",
"function",
"getLongOptionKey",
"(",
"$",
"arg",
")",
"{",
"$",
"key",
"=",
"(",
"false",
"!==",
"(",
"$",
"eqPos",
"=",
"strpos",
"(",
"$",
"arg",
",",
"'='",
")",
")",
")",
"?",
"substr",
"(",
"$",
"arg",
",",
"2",
",",
"$",
"eqPos",
"-",
"2",
")",
":",
"// --key=value",
"substr",
"(",
"$",
"arg",
",",
"2",
")",
";",
"// --key value",
"return",
"$",
"key",
";",
"}"
] | Extracts the key from a long option
Two syntax are allowed: '--key=value' and '--key value'
@param string $arg The argument to parse
@return string | [
"Extracts",
"the",
"key",
"from",
"a",
"long",
"option"
] | 29a1de575f5759d28f3bc920a69ec883ceeba1e8 | https://github.com/vtardia/cli-parser/blob/29a1de575f5759d28f3bc920a69ec883ceeba1e8/src/CLIParser.php#L307-L315 |
872 | vtardia/cli-parser | src/CLIParser.php | CLIParser.parseShortOptionGroup | private function parseShortOptionGroup($key)
{
$shortOptions = $this->shortOptions;
// We parse every single character, remove it from the current argument
// and wd DO NOT update index counter, unless we are parsing the last option
$chars = str_split($key);
foreach ($chars as $char) {
// Test if is a valid option
$cpos = strpos($shortOptions, $char);
if (false === $cpos) {
$this->optind++;
return null;
}
// Is Valid option: set return value
$option = $char;
// Check if option accept a parameter
if (isset($shortOptions[$cpos+1]) && $shortOptions[$cpos+1] === ':') {
// Ok, current option accept a parameter, start parsing
// Check n.1: if an option accepts a parameter, to be valid must be the last
// in an option-group, for example:
// YES: tar -cvzf filename.tar.gz
// NO: tar -cvfz filename.tar.gz
if (strpos($key, $char) < (strlen($key)-1)) {
// Current option is not the last, so the parameter is invalid
// return option with FALSE as argument
$this->optarg = false;
// Remove current option from $this->argv[$this->optind]
// so it's not counted on next loop
$this->argv[$this->optind] = str_replace($char, '', $this->argv[$this->optind]);
return $option;
}
// Our option is the last, so check for a valid parameter
if ($this->optind < $this->argc -1) {
// Get next argument from our copy of $argv
$optarg = (string) $this->argv[$this->optind + 1];
// If the argument is not an option (should not begin with - or --)
if (!($this->isLongOption($optarg)) && !($this->isShortOption($optarg))) {
// Option value is ok, set it and update index by 2 steps
$this->optarg = $optarg;
$this->optind += 2;
return $option;
}
}
// Option value missing, set it to FALSE and update index by 1 step only
$this->optarg = false;
$this->optind++;
return $option;
}
// Current option do not accept parameters
$this->optarg = true;
// Remove current option from $this->argv[$this->optind]
// so it's not counted on next loop
$this->argv[$this->optind] = str_replace($char, '', $this->argv[$this->optind]);
// Return the option value
// Option index is updated (by 1) only if this is the last option
if (strpos($key, $char) == (strlen($key)-1)) {
$this->optind++;
}
return $option;
}
// If we reach here the chance is we didn't find any allowed option
// so we return null
if (strpos($key, $char) == (strlen($key)-1)) {
$this->optind++;
}
return null;
} | php | private function parseShortOptionGroup($key)
{
$shortOptions = $this->shortOptions;
// We parse every single character, remove it from the current argument
// and wd DO NOT update index counter, unless we are parsing the last option
$chars = str_split($key);
foreach ($chars as $char) {
// Test if is a valid option
$cpos = strpos($shortOptions, $char);
if (false === $cpos) {
$this->optind++;
return null;
}
// Is Valid option: set return value
$option = $char;
// Check if option accept a parameter
if (isset($shortOptions[$cpos+1]) && $shortOptions[$cpos+1] === ':') {
// Ok, current option accept a parameter, start parsing
// Check n.1: if an option accepts a parameter, to be valid must be the last
// in an option-group, for example:
// YES: tar -cvzf filename.tar.gz
// NO: tar -cvfz filename.tar.gz
if (strpos($key, $char) < (strlen($key)-1)) {
// Current option is not the last, so the parameter is invalid
// return option with FALSE as argument
$this->optarg = false;
// Remove current option from $this->argv[$this->optind]
// so it's not counted on next loop
$this->argv[$this->optind] = str_replace($char, '', $this->argv[$this->optind]);
return $option;
}
// Our option is the last, so check for a valid parameter
if ($this->optind < $this->argc -1) {
// Get next argument from our copy of $argv
$optarg = (string) $this->argv[$this->optind + 1];
// If the argument is not an option (should not begin with - or --)
if (!($this->isLongOption($optarg)) && !($this->isShortOption($optarg))) {
// Option value is ok, set it and update index by 2 steps
$this->optarg = $optarg;
$this->optind += 2;
return $option;
}
}
// Option value missing, set it to FALSE and update index by 1 step only
$this->optarg = false;
$this->optind++;
return $option;
}
// Current option do not accept parameters
$this->optarg = true;
// Remove current option from $this->argv[$this->optind]
// so it's not counted on next loop
$this->argv[$this->optind] = str_replace($char, '', $this->argv[$this->optind]);
// Return the option value
// Option index is updated (by 1) only if this is the last option
if (strpos($key, $char) == (strlen($key)-1)) {
$this->optind++;
}
return $option;
}
// If we reach here the chance is we didn't find any allowed option
// so we return null
if (strpos($key, $char) == (strlen($key)-1)) {
$this->optind++;
}
return null;
} | [
"private",
"function",
"parseShortOptionGroup",
"(",
"$",
"key",
")",
"{",
"$",
"shortOptions",
"=",
"$",
"this",
"->",
"shortOptions",
";",
"// We parse every single character, remove it from the current argument",
"// and wd DO NOT update index counter, unless we are parsing the last option",
"$",
"chars",
"=",
"str_split",
"(",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"chars",
"as",
"$",
"char",
")",
"{",
"// Test if is a valid option",
"$",
"cpos",
"=",
"strpos",
"(",
"$",
"shortOptions",
",",
"$",
"char",
")",
";",
"if",
"(",
"false",
"===",
"$",
"cpos",
")",
"{",
"$",
"this",
"->",
"optind",
"++",
";",
"return",
"null",
";",
"}",
"// Is Valid option: set return value",
"$",
"option",
"=",
"$",
"char",
";",
"// Check if option accept a parameter",
"if",
"(",
"isset",
"(",
"$",
"shortOptions",
"[",
"$",
"cpos",
"+",
"1",
"]",
")",
"&&",
"$",
"shortOptions",
"[",
"$",
"cpos",
"+",
"1",
"]",
"===",
"':'",
")",
"{",
"// Ok, current option accept a parameter, start parsing",
"// Check n.1: if an option accepts a parameter, to be valid must be the last",
"// in an option-group, for example:",
"// YES: tar -cvzf filename.tar.gz",
"// NO: tar -cvfz filename.tar.gz",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"char",
")",
"<",
"(",
"strlen",
"(",
"$",
"key",
")",
"-",
"1",
")",
")",
"{",
"// Current option is not the last, so the parameter is invalid",
"// return option with FALSE as argument",
"$",
"this",
"->",
"optarg",
"=",
"false",
";",
"// Remove current option from $this->argv[$this->optind]",
"// so it's not counted on next loop",
"$",
"this",
"->",
"argv",
"[",
"$",
"this",
"->",
"optind",
"]",
"=",
"str_replace",
"(",
"$",
"char",
",",
"''",
",",
"$",
"this",
"->",
"argv",
"[",
"$",
"this",
"->",
"optind",
"]",
")",
";",
"return",
"$",
"option",
";",
"}",
"// Our option is the last, so check for a valid parameter",
"if",
"(",
"$",
"this",
"->",
"optind",
"<",
"$",
"this",
"->",
"argc",
"-",
"1",
")",
"{",
"// Get next argument from our copy of $argv",
"$",
"optarg",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"argv",
"[",
"$",
"this",
"->",
"optind",
"+",
"1",
"]",
";",
"// If the argument is not an option (should not begin with - or --)",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"isLongOption",
"(",
"$",
"optarg",
")",
")",
"&&",
"!",
"(",
"$",
"this",
"->",
"isShortOption",
"(",
"$",
"optarg",
")",
")",
")",
"{",
"// Option value is ok, set it and update index by 2 steps",
"$",
"this",
"->",
"optarg",
"=",
"$",
"optarg",
";",
"$",
"this",
"->",
"optind",
"+=",
"2",
";",
"return",
"$",
"option",
";",
"}",
"}",
"// Option value missing, set it to FALSE and update index by 1 step only",
"$",
"this",
"->",
"optarg",
"=",
"false",
";",
"$",
"this",
"->",
"optind",
"++",
";",
"return",
"$",
"option",
";",
"}",
"// Current option do not accept parameters",
"$",
"this",
"->",
"optarg",
"=",
"true",
";",
"// Remove current option from $this->argv[$this->optind]",
"// so it's not counted on next loop",
"$",
"this",
"->",
"argv",
"[",
"$",
"this",
"->",
"optind",
"]",
"=",
"str_replace",
"(",
"$",
"char",
",",
"''",
",",
"$",
"this",
"->",
"argv",
"[",
"$",
"this",
"->",
"optind",
"]",
")",
";",
"// Return the option value",
"// Option index is updated (by 1) only if this is the last option",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"char",
")",
"==",
"(",
"strlen",
"(",
"$",
"key",
")",
"-",
"1",
")",
")",
"{",
"$",
"this",
"->",
"optind",
"++",
";",
"}",
"return",
"$",
"option",
";",
"}",
"// If we reach here the chance is we didn't find any allowed option",
"// so we return null",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"char",
")",
"==",
"(",
"strlen",
"(",
"$",
"key",
")",
"-",
"1",
")",
")",
"{",
"$",
"this",
"->",
"optind",
"++",
";",
"}",
"return",
"null",
";",
"}"
] | Parse and extract the keys and values of a short options group
Only the last option in the group can have a value
@param string $key The options group string
@return string | NULL | [
"Parse",
"and",
"extract",
"the",
"keys",
"and",
"values",
"of",
"a",
"short",
"options",
"group"
] | 29a1de575f5759d28f3bc920a69ec883ceeba1e8 | https://github.com/vtardia/cli-parser/blob/29a1de575f5759d28f3bc920a69ec883ceeba1e8/src/CLIParser.php#L407-L492 |
873 | cundd/test-flight | src/Autoload/Finder.php | Finder.find | public function find($basePath)
{
if (is_file($basePath)) {
$basePath = dirname($basePath);
} elseif (!is_dir($basePath)) {
throw new \InvalidArgumentException('Base path must be either a file path or directory');
}
$basePath = realpath($basePath) ?: $basePath;
do {
$autoloaderPath = $this->containsKnownAutoloader($basePath);
if ($autoloaderPath !== '') {
return $autoloaderPath;
}
$basePath = dirname($basePath);
} while ($basePath && $basePath !== '/');
return '';
} | php | public function find($basePath)
{
if (is_file($basePath)) {
$basePath = dirname($basePath);
} elseif (!is_dir($basePath)) {
throw new \InvalidArgumentException('Base path must be either a file path or directory');
}
$basePath = realpath($basePath) ?: $basePath;
do {
$autoloaderPath = $this->containsKnownAutoloader($basePath);
if ($autoloaderPath !== '') {
return $autoloaderPath;
}
$basePath = dirname($basePath);
} while ($basePath && $basePath !== '/');
return '';
} | [
"public",
"function",
"find",
"(",
"$",
"basePath",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"basePath",
")",
")",
"{",
"$",
"basePath",
"=",
"dirname",
"(",
"$",
"basePath",
")",
";",
"}",
"elseif",
"(",
"!",
"is_dir",
"(",
"$",
"basePath",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Base path must be either a file path or directory'",
")",
";",
"}",
"$",
"basePath",
"=",
"realpath",
"(",
"$",
"basePath",
")",
"?",
":",
"$",
"basePath",
";",
"do",
"{",
"$",
"autoloaderPath",
"=",
"$",
"this",
"->",
"containsKnownAutoloader",
"(",
"$",
"basePath",
")",
";",
"if",
"(",
"$",
"autoloaderPath",
"!==",
"''",
")",
"{",
"return",
"$",
"autoloaderPath",
";",
"}",
"$",
"basePath",
"=",
"dirname",
"(",
"$",
"basePath",
")",
";",
"}",
"while",
"(",
"$",
"basePath",
"&&",
"$",
"basePath",
"!==",
"'/'",
")",
";",
"return",
"''",
";",
"}"
] | Find the best autoloader for the current project
@example
$finder = new \Cundd\TestFlight\Autoload\Finder();
$foundAutoloaderPath = $finder->find(__DIR__);
assert(substr($foundAutoloaderPath, -19) === 'vendor/autoload.php');
@param string $basePath
@return string | [
"Find",
"the",
"best",
"autoloader",
"for",
"the",
"current",
"project"
] | 9d8424dfb586f823f9dad2dcb81ff3986e255d56 | https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Autoload/Finder.php#L30-L49 |
874 | euskadi31/PaginatorServiceProvider | src/Paginator/Paginator.php | Paginator.setItemCountPerPage | public function setItemCountPerPage($itemCountPerPage = -1)
{
$this->itemCountPerPage = (int) $itemCountPerPage;
if ($this->itemCountPerPage < 1) {
$this->itemCountPerPage = $this->getTotalItemCount();
}
$this->pageCount = $this->_calculatePageCount();
$this->currentItems = null;
$this->currentItemCount = null;
return $this;
} | php | public function setItemCountPerPage($itemCountPerPage = -1)
{
$this->itemCountPerPage = (int) $itemCountPerPage;
if ($this->itemCountPerPage < 1) {
$this->itemCountPerPage = $this->getTotalItemCount();
}
$this->pageCount = $this->_calculatePageCount();
$this->currentItems = null;
$this->currentItemCount = null;
return $this;
} | [
"public",
"function",
"setItemCountPerPage",
"(",
"$",
"itemCountPerPage",
"=",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"itemCountPerPage",
"=",
"(",
"int",
")",
"$",
"itemCountPerPage",
";",
"if",
"(",
"$",
"this",
"->",
"itemCountPerPage",
"<",
"1",
")",
"{",
"$",
"this",
"->",
"itemCountPerPage",
"=",
"$",
"this",
"->",
"getTotalItemCount",
"(",
")",
";",
"}",
"$",
"this",
"->",
"pageCount",
"=",
"$",
"this",
"->",
"_calculatePageCount",
"(",
")",
";",
"$",
"this",
"->",
"currentItems",
"=",
"null",
";",
"$",
"this",
"->",
"currentItemCount",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the number of items per page.
@param int $itemCountPerPage
@return Paginator $this | [
"Sets",
"the",
"number",
"of",
"items",
"per",
"page",
"."
] | 2643eea9f1074ed67413100307a0d462e2e9e11c | https://github.com/euskadi31/PaginatorServiceProvider/blob/2643eea9f1074ed67413100307a0d462e2e9e11c/src/Paginator/Paginator.php#L198-L209 |
875 | euskadi31/PaginatorServiceProvider | src/Paginator/Paginator.php | Paginator.getPages | public function getPages($scrollingStyle = null)
{
if ($this->pages === null) {
$this->pages = $this->_createPages($scrollingStyle);
}
return $this->pages;
} | php | public function getPages($scrollingStyle = null)
{
if ($this->pages === null) {
$this->pages = $this->_createPages($scrollingStyle);
}
return $this->pages;
} | [
"public",
"function",
"getPages",
"(",
"$",
"scrollingStyle",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pages",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"pages",
"=",
"$",
"this",
"->",
"_createPages",
"(",
"$",
"scrollingStyle",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pages",
";",
"}"
] | Returns the page collection.
@param string $scrollingStyle Scrolling style
@return array | [
"Returns",
"the",
"page",
"collection",
"."
] | 2643eea9f1074ed67413100307a0d462e2e9e11c | https://github.com/euskadi31/PaginatorServiceProvider/blob/2643eea9f1074ed67413100307a0d462e2e9e11c/src/Paginator/Paginator.php#L240-L247 |
876 | euskadi31/PaginatorServiceProvider | src/Paginator/Paginator.php | Paginator.getPagesInRange | public function getPagesInRange($lowerBound, $upperBound)
{
$lowerBound = $this->normalizePageNumber($lowerBound);
$upperBound = $this->normalizePageNumber($upperBound);
$pages = array();
for ($pageNumber = $lowerBound; $pageNumber <= $upperBound; $pageNumber++) {
$pages[$pageNumber] = $pageNumber;
}
return $pages;
} | php | public function getPagesInRange($lowerBound, $upperBound)
{
$lowerBound = $this->normalizePageNumber($lowerBound);
$upperBound = $this->normalizePageNumber($upperBound);
$pages = array();
for ($pageNumber = $lowerBound; $pageNumber <= $upperBound; $pageNumber++) {
$pages[$pageNumber] = $pageNumber;
}
return $pages;
} | [
"public",
"function",
"getPagesInRange",
"(",
"$",
"lowerBound",
",",
"$",
"upperBound",
")",
"{",
"$",
"lowerBound",
"=",
"$",
"this",
"->",
"normalizePageNumber",
"(",
"$",
"lowerBound",
")",
";",
"$",
"upperBound",
"=",
"$",
"this",
"->",
"normalizePageNumber",
"(",
"$",
"upperBound",
")",
";",
"$",
"pages",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"pageNumber",
"=",
"$",
"lowerBound",
";",
"$",
"pageNumber",
"<=",
"$",
"upperBound",
";",
"$",
"pageNumber",
"++",
")",
"{",
"$",
"pages",
"[",
"$",
"pageNumber",
"]",
"=",
"$",
"pageNumber",
";",
"}",
"return",
"$",
"pages",
";",
"}"
] | Returns a subset of pages within a given range.
@param int $lowerBound Lower bound of the range
@param int $upperBound Upper bound of the range
@return array | [
"Returns",
"a",
"subset",
"of",
"pages",
"within",
"a",
"given",
"range",
"."
] | 2643eea9f1074ed67413100307a0d462e2e9e11c | https://github.com/euskadi31/PaginatorServiceProvider/blob/2643eea9f1074ed67413100307a0d462e2e9e11c/src/Paginator/Paginator.php#L256-L268 |
877 | euskadi31/PaginatorServiceProvider | src/Paginator/Paginator.php | Paginator.normalizeItemNumber | public function normalizeItemNumber($itemNumber)
{
$itemNumber = (int) $itemNumber;
if ($itemNumber < 1) {
$itemNumber = 1;
}
if ($itemNumber > $this->getItemCountPerPage()) {
$itemNumber = $this->getItemCountPerPage();
}
return $itemNumber;
} | php | public function normalizeItemNumber($itemNumber)
{
$itemNumber = (int) $itemNumber;
if ($itemNumber < 1) {
$itemNumber = 1;
}
if ($itemNumber > $this->getItemCountPerPage()) {
$itemNumber = $this->getItemCountPerPage();
}
return $itemNumber;
} | [
"public",
"function",
"normalizeItemNumber",
"(",
"$",
"itemNumber",
")",
"{",
"$",
"itemNumber",
"=",
"(",
"int",
")",
"$",
"itemNumber",
";",
"if",
"(",
"$",
"itemNumber",
"<",
"1",
")",
"{",
"$",
"itemNumber",
"=",
"1",
";",
"}",
"if",
"(",
"$",
"itemNumber",
">",
"$",
"this",
"->",
"getItemCountPerPage",
"(",
")",
")",
"{",
"$",
"itemNumber",
"=",
"$",
"this",
"->",
"getItemCountPerPage",
"(",
")",
";",
"}",
"return",
"$",
"itemNumber",
";",
"}"
] | Brings the item number in range of the page.
@param int $itemNumber
@return int | [
"Brings",
"the",
"item",
"number",
"in",
"range",
"of",
"the",
"page",
"."
] | 2643eea9f1074ed67413100307a0d462e2e9e11c | https://github.com/euskadi31/PaginatorServiceProvider/blob/2643eea9f1074ed67413100307a0d462e2e9e11c/src/Paginator/Paginator.php#L276-L289 |
878 | euskadi31/PaginatorServiceProvider | src/Paginator/Paginator.php | Paginator.normalizePageNumber | public function normalizePageNumber($pageNumber)
{
$pageNumber = (int) $pageNumber;
if ($pageNumber < 1) {
$pageNumber = 1;
}
$pageCount = $this->count();
if ($pageCount > 0 && $pageNumber > $pageCount) {
$pageNumber = $pageCount;
}
return $pageNumber;
} | php | public function normalizePageNumber($pageNumber)
{
$pageNumber = (int) $pageNumber;
if ($pageNumber < 1) {
$pageNumber = 1;
}
$pageCount = $this->count();
if ($pageCount > 0 && $pageNumber > $pageCount) {
$pageNumber = $pageCount;
}
return $pageNumber;
} | [
"public",
"function",
"normalizePageNumber",
"(",
"$",
"pageNumber",
")",
"{",
"$",
"pageNumber",
"=",
"(",
"int",
")",
"$",
"pageNumber",
";",
"if",
"(",
"$",
"pageNumber",
"<",
"1",
")",
"{",
"$",
"pageNumber",
"=",
"1",
";",
"}",
"$",
"pageCount",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"pageCount",
">",
"0",
"&&",
"$",
"pageNumber",
">",
"$",
"pageCount",
")",
"{",
"$",
"pageNumber",
"=",
"$",
"pageCount",
";",
"}",
"return",
"$",
"pageNumber",
";",
"}"
] | Brings the page number in range of the paginator.
@param int $pageNumber
@return int | [
"Brings",
"the",
"page",
"number",
"in",
"range",
"of",
"the",
"paginator",
"."
] | 2643eea9f1074ed67413100307a0d462e2e9e11c | https://github.com/euskadi31/PaginatorServiceProvider/blob/2643eea9f1074ed67413100307a0d462e2e9e11c/src/Paginator/Paginator.php#L297-L312 |
879 | euskadi31/PaginatorServiceProvider | src/Paginator/Paginator.php | Paginator._createPages | protected function _createPages($scrollingStyle = null)
{
$pageCount = $this->count();
$currentPageNumber = $this->getCurrentPageNumber();
$pages = array(
'pageCount' => $pageCount,
'itemCountPerPage' => $this->getItemCountPerPage(),
'first' => 1,
'current' => $currentPageNumber,
'last' => $pageCount
);
// Previous and next
if ($currentPageNumber - 1 > 0) {
$pages['previous'] = $currentPageNumber - 1;
}
if ($currentPageNumber + 1 <= $pageCount) {
$pages['next'] = $currentPageNumber + 1;
}
// Pages in range
$scrollingStyle = $this->_loadScrollingStyle($scrollingStyle);
$pages['pagesInRange'] = $scrollingStyle->getPages($this);
$pages['firstPageInRange'] = min($pages['pagesInRange']);
$pages['lastPageInRange'] = max($pages['pagesInRange']);
return $pages;
} | php | protected function _createPages($scrollingStyle = null)
{
$pageCount = $this->count();
$currentPageNumber = $this->getCurrentPageNumber();
$pages = array(
'pageCount' => $pageCount,
'itemCountPerPage' => $this->getItemCountPerPage(),
'first' => 1,
'current' => $currentPageNumber,
'last' => $pageCount
);
// Previous and next
if ($currentPageNumber - 1 > 0) {
$pages['previous'] = $currentPageNumber - 1;
}
if ($currentPageNumber + 1 <= $pageCount) {
$pages['next'] = $currentPageNumber + 1;
}
// Pages in range
$scrollingStyle = $this->_loadScrollingStyle($scrollingStyle);
$pages['pagesInRange'] = $scrollingStyle->getPages($this);
$pages['firstPageInRange'] = min($pages['pagesInRange']);
$pages['lastPageInRange'] = max($pages['pagesInRange']);
return $pages;
} | [
"protected",
"function",
"_createPages",
"(",
"$",
"scrollingStyle",
"=",
"null",
")",
"{",
"$",
"pageCount",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"$",
"currentPageNumber",
"=",
"$",
"this",
"->",
"getCurrentPageNumber",
"(",
")",
";",
"$",
"pages",
"=",
"array",
"(",
"'pageCount'",
"=>",
"$",
"pageCount",
",",
"'itemCountPerPage'",
"=>",
"$",
"this",
"->",
"getItemCountPerPage",
"(",
")",
",",
"'first'",
"=>",
"1",
",",
"'current'",
"=>",
"$",
"currentPageNumber",
",",
"'last'",
"=>",
"$",
"pageCount",
")",
";",
"// Previous and next",
"if",
"(",
"$",
"currentPageNumber",
"-",
"1",
">",
"0",
")",
"{",
"$",
"pages",
"[",
"'previous'",
"]",
"=",
"$",
"currentPageNumber",
"-",
"1",
";",
"}",
"if",
"(",
"$",
"currentPageNumber",
"+",
"1",
"<=",
"$",
"pageCount",
")",
"{",
"$",
"pages",
"[",
"'next'",
"]",
"=",
"$",
"currentPageNumber",
"+",
"1",
";",
"}",
"// Pages in range",
"$",
"scrollingStyle",
"=",
"$",
"this",
"->",
"_loadScrollingStyle",
"(",
"$",
"scrollingStyle",
")",
";",
"$",
"pages",
"[",
"'pagesInRange'",
"]",
"=",
"$",
"scrollingStyle",
"->",
"getPages",
"(",
"$",
"this",
")",
";",
"$",
"pages",
"[",
"'firstPageInRange'",
"]",
"=",
"min",
"(",
"$",
"pages",
"[",
"'pagesInRange'",
"]",
")",
";",
"$",
"pages",
"[",
"'lastPageInRange'",
"]",
"=",
"max",
"(",
"$",
"pages",
"[",
"'pagesInRange'",
"]",
")",
";",
"return",
"$",
"pages",
";",
"}"
] | Creates the page collection.
@param string $scrollingStyle Scrolling style
@return array | [
"Creates",
"the",
"page",
"collection",
"."
] | 2643eea9f1074ed67413100307a0d462e2e9e11c | https://github.com/euskadi31/PaginatorServiceProvider/blob/2643eea9f1074ed67413100307a0d462e2e9e11c/src/Paginator/Paginator.php#L347-L377 |
880 | coolms/doctrine | src/Form/Annotation/ElementResolverListener.php | ElementResolverListener.resolveComposedTargetObject | public function resolveComposedTargetObject($e)
{
$annotation = $e->getParam('annotation');
if (!$annotation instanceof ComposedObject) {
return;
}
$formSpec = $e->getParam('formSpec');
if (!isset($formSpec['object'])) {
return;
}
$metadata = $this->objectManager->getClassMetadata($formSpec['object']);
$fieldName = $e->getParam('elementSpec')['spec']['name'];
if ($metadata->hasAssociation($fieldName)) {
$e->setParam('annotation', new ComposedObject([
'value' => [
'target_object' => $metadata->getAssociationTargetClass($fieldName),
'is_collection' => $annotation->isCollection(),
'options' => $annotation->getOptions(),
],
]));
return;
}
if (!empty($metadata->embeddedClasses[$fieldName])) {
$class = $metadata->embeddedClasses[$fieldName]['class'];
if (!is_object($class)) {
$class = $this->objectManager->getClassMetadata($class)->getName();
}
$e->setParam('annotation', new ComposedObject([
'value' => [
'target_object' => $class,
'is_collection' => $annotation->isCollection(),
'options' => $annotation->getOptions(),
],
]));
}
} | php | public function resolveComposedTargetObject($e)
{
$annotation = $e->getParam('annotation');
if (!$annotation instanceof ComposedObject) {
return;
}
$formSpec = $e->getParam('formSpec');
if (!isset($formSpec['object'])) {
return;
}
$metadata = $this->objectManager->getClassMetadata($formSpec['object']);
$fieldName = $e->getParam('elementSpec')['spec']['name'];
if ($metadata->hasAssociation($fieldName)) {
$e->setParam('annotation', new ComposedObject([
'value' => [
'target_object' => $metadata->getAssociationTargetClass($fieldName),
'is_collection' => $annotation->isCollection(),
'options' => $annotation->getOptions(),
],
]));
return;
}
if (!empty($metadata->embeddedClasses[$fieldName])) {
$class = $metadata->embeddedClasses[$fieldName]['class'];
if (!is_object($class)) {
$class = $this->objectManager->getClassMetadata($class)->getName();
}
$e->setParam('annotation', new ComposedObject([
'value' => [
'target_object' => $class,
'is_collection' => $annotation->isCollection(),
'options' => $annotation->getOptions(),
],
]));
}
} | [
"public",
"function",
"resolveComposedTargetObject",
"(",
"$",
"e",
")",
"{",
"$",
"annotation",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'annotation'",
")",
";",
"if",
"(",
"!",
"$",
"annotation",
"instanceof",
"ComposedObject",
")",
"{",
"return",
";",
"}",
"$",
"formSpec",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'formSpec'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"formSpec",
"[",
"'object'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"metadata",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"getClassMetadata",
"(",
"$",
"formSpec",
"[",
"'object'",
"]",
")",
";",
"$",
"fieldName",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'elementSpec'",
")",
"[",
"'spec'",
"]",
"[",
"'name'",
"]",
";",
"if",
"(",
"$",
"metadata",
"->",
"hasAssociation",
"(",
"$",
"fieldName",
")",
")",
"{",
"$",
"e",
"->",
"setParam",
"(",
"'annotation'",
",",
"new",
"ComposedObject",
"(",
"[",
"'value'",
"=>",
"[",
"'target_object'",
"=>",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"fieldName",
")",
",",
"'is_collection'",
"=>",
"$",
"annotation",
"->",
"isCollection",
"(",
")",
",",
"'options'",
"=>",
"$",
"annotation",
"->",
"getOptions",
"(",
")",
",",
"]",
",",
"]",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"metadata",
"->",
"embeddedClasses",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"metadata",
"->",
"embeddedClasses",
"[",
"$",
"fieldName",
"]",
"[",
"'class'",
"]",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"getClassMetadata",
"(",
"$",
"class",
")",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"e",
"->",
"setParam",
"(",
"'annotation'",
",",
"new",
"ComposedObject",
"(",
"[",
"'value'",
"=>",
"[",
"'target_object'",
"=>",
"$",
"class",
",",
"'is_collection'",
"=>",
"$",
"annotation",
"->",
"isCollection",
"(",
")",
",",
"'options'",
"=>",
"$",
"annotation",
"->",
"getOptions",
"(",
")",
",",
"]",
",",
"]",
")",
")",
";",
"}",
"}"
] | ComposedObject target object resolver
Resolves the interface (specification) into entity object class
@param \Zend\EventManager\EventInterface $e | [
"ComposedObject",
"target",
"object",
"resolver"
] | d7d233594b37cd0c3abc37a46e4e4b965767c3b4 | https://github.com/coolms/doctrine/blob/d7d233594b37cd0c3abc37a46e4e4b965767c3b4/src/Form/Annotation/ElementResolverListener.php#L49-L90 |
881 | coolms/doctrine | src/Form/Annotation/ElementResolverListener.php | ElementResolverListener.handleHydratorAnnotation | public function handleHydratorAnnotation($e)
{
$annotation = $e->getParam('annotation');
if (!($annotation instanceof ComposedObject && $annotation->isCollection())) {
return;
}
$elementSpec = $e->getParam('elementSpec');
if (isset($elementSpec['spec']['hydrator'])) {
unset($elementSpec['spec']['hydrator']);
}
} | php | public function handleHydratorAnnotation($e)
{
$annotation = $e->getParam('annotation');
if (!($annotation instanceof ComposedObject && $annotation->isCollection())) {
return;
}
$elementSpec = $e->getParam('elementSpec');
if (isset($elementSpec['spec']['hydrator'])) {
unset($elementSpec['spec']['hydrator']);
}
} | [
"public",
"function",
"handleHydratorAnnotation",
"(",
"$",
"e",
")",
"{",
"$",
"annotation",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'annotation'",
")",
";",
"if",
"(",
"!",
"(",
"$",
"annotation",
"instanceof",
"ComposedObject",
"&&",
"$",
"annotation",
"->",
"isCollection",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"elementSpec",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'elementSpec'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'hydrator'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'hydrator'",
"]",
")",
";",
"}",
"}"
] | Handle the Hydrator annotation
Removes the hydrator class from collection specification.
@todo remove this callback
@param \Zend\EventManager\EventInterface $e
@return void | [
"Handle",
"the",
"Hydrator",
"annotation"
] | d7d233594b37cd0c3abc37a46e4e4b965767c3b4 | https://github.com/coolms/doctrine/blob/d7d233594b37cd0c3abc37a46e4e4b965767c3b4/src/Form/Annotation/ElementResolverListener.php#L101-L112 |
882 | coolms/doctrine | src/Form/Annotation/ElementResolverListener.php | ElementResolverListener.resolveObjectSelectTargetClass | public function resolveObjectSelectTargetClass($e)
{
$elementSpec = $e->getParam('elementSpec');
if (!isset($elementSpec['spec']['type'])) {
return;
}
$type = $elementSpec['spec']['type'];
if (strtolower($type) !== 'objectselect' && !$type instanceof ObjectSelect) {
return;
}
if (isset($elementSpec['spec']['options']['target_class']) &&
class_exists($elementSpec['spec']['options']['target_class']) ||
empty($formSpec['object'])
) {
return;
}
$formSpec = $e->getParam('formSpec');
$metadata = $this->objectManager->getClassMetadata($formSpec['object']);
if ($metadata->hasAssociation($elementSpec['spec']['name'])) {
$elementSpec['spec']['options']['target_class'] =
$metadata->getAssociationTargetClass($elementSpec['spec']['name']);
}
} | php | public function resolveObjectSelectTargetClass($e)
{
$elementSpec = $e->getParam('elementSpec');
if (!isset($elementSpec['spec']['type'])) {
return;
}
$type = $elementSpec['spec']['type'];
if (strtolower($type) !== 'objectselect' && !$type instanceof ObjectSelect) {
return;
}
if (isset($elementSpec['spec']['options']['target_class']) &&
class_exists($elementSpec['spec']['options']['target_class']) ||
empty($formSpec['object'])
) {
return;
}
$formSpec = $e->getParam('formSpec');
$metadata = $this->objectManager->getClassMetadata($formSpec['object']);
if ($metadata->hasAssociation($elementSpec['spec']['name'])) {
$elementSpec['spec']['options']['target_class'] =
$metadata->getAssociationTargetClass($elementSpec['spec']['name']);
}
} | [
"public",
"function",
"resolveObjectSelectTargetClass",
"(",
"$",
"e",
")",
"{",
"$",
"elementSpec",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'elementSpec'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'type'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"type",
"=",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'type'",
"]",
";",
"if",
"(",
"strtolower",
"(",
"$",
"type",
")",
"!==",
"'objectselect'",
"&&",
"!",
"$",
"type",
"instanceof",
"ObjectSelect",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'options'",
"]",
"[",
"'target_class'",
"]",
")",
"&&",
"class_exists",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'options'",
"]",
"[",
"'target_class'",
"]",
")",
"||",
"empty",
"(",
"$",
"formSpec",
"[",
"'object'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"formSpec",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'formSpec'",
")",
";",
"$",
"metadata",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"getClassMetadata",
"(",
"$",
"formSpec",
"[",
"'object'",
"]",
")",
";",
"if",
"(",
"$",
"metadata",
"->",
"hasAssociation",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'options'",
"]",
"[",
"'target_class'",
"]",
"=",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"elementSpec",
"[",
"'spec'",
"]",
"[",
"'name'",
"]",
")",
";",
"}",
"}"
] | ObjectSelect target class resolver
Resolves the interface (specification) into entity object class
@param \Zend\EventManager\EventInterface $e | [
"ObjectSelect",
"target",
"class",
"resolver"
] | d7d233594b37cd0c3abc37a46e4e4b965767c3b4 | https://github.com/coolms/doctrine/blob/d7d233594b37cd0c3abc37a46e4e4b965767c3b4/src/Form/Annotation/ElementResolverListener.php#L121-L147 |
883 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.newAction | public function newAction()
{
$entity = new Product();
$entity = $this->addProductItemFieldData($entity);
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | php | public function newAction()
{
$entity = new Product();
$entity = $this->addProductItemFieldData($entity);
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"entity",
"=",
"new",
"Product",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"addProductItemFieldData",
"(",
"$",
"entity",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"entity",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to create a new Product entity.
@Route("/new", name="admin_product_new")
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Product",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L138-L151 |
884 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.copyAction | public function copyAction(Product $product)
{
$productCopy = new Product();
$copyName = $this->get('translator')->trans('Copy of') . " " . $product->getName();
$productCopy->setName($copyName);
$productCopy->setCostPrice($product->getCostPrice());
$productCopy->setDescription($product->getDescription()??$copyName);
$productCopy->setCode($product->getCode());
$productCopy->setImage($product->getImage());
$productCopy->setPlace($product->getPlace());
$productCopy->setSalePrice($product->getSalePrice());
$productCopy->setSupplier($product->getSupplier());
$productCopy->setWarehouse($product->getWarehouse());
// boleans
$productCopy->setEnabled($product->getEnabled());
$productCopy->setForSale($product->getForSale());
$productCopy->setCompositionOnDemand($product->isCompositionOnDemand());
$productCopy->setPack($product->isPack());
$productCopy->setManualPackPricing($product->isManualPackPricing());
$productCopy->setRawMaterial($product->getRawMaterial());
$em = $this->getDoctrine()->getManager();
$em->persist($productCopy);
// relations
/* @var ProductRawMaterial $rawMaterial */
foreach ($product->getRawMaterials() as $rawMaterial) {
$rawMaterialCopy = new ProductRawMaterial();
$rawMaterialCopy->setRawMaterial($rawMaterial->getRawMaterial());
$rawMaterialCopy->setProduct($productCopy);
$rawMaterialCopy->setMeasureUnit($rawMaterial->getMeasureUnit());
$rawMaterialCopy->setQuantity($rawMaterial->getQuantity());
$em->persist($rawMaterialCopy);
$productCopy->addRawMaterial($rawMaterialCopy);
}
/* @var ProductCategory $category */
foreach ($product->getCategories() as $category) {
$productCopy->addCategory($category);
}
/* @var ProductCustomField $customField */
foreach ($product->getCustomFields() as $customField) {
$customFieldCopy = new ProductCustomField();
$customFieldCopy->setProduct($productCopy);
$customFieldCopy->setSettingField($customField->getSettingField());
$customFieldCopy->setValue($customField->getValue());
$em->persist($customFieldCopy);
$productCopy->addCustomField($customFieldCopy);
}
$em->flush();
return $this->redirect($this->generateUrl('product_show', array("id" => $productCopy->getId())));
} | php | public function copyAction(Product $product)
{
$productCopy = new Product();
$copyName = $this->get('translator')->trans('Copy of') . " " . $product->getName();
$productCopy->setName($copyName);
$productCopy->setCostPrice($product->getCostPrice());
$productCopy->setDescription($product->getDescription()??$copyName);
$productCopy->setCode($product->getCode());
$productCopy->setImage($product->getImage());
$productCopy->setPlace($product->getPlace());
$productCopy->setSalePrice($product->getSalePrice());
$productCopy->setSupplier($product->getSupplier());
$productCopy->setWarehouse($product->getWarehouse());
// boleans
$productCopy->setEnabled($product->getEnabled());
$productCopy->setForSale($product->getForSale());
$productCopy->setCompositionOnDemand($product->isCompositionOnDemand());
$productCopy->setPack($product->isPack());
$productCopy->setManualPackPricing($product->isManualPackPricing());
$productCopy->setRawMaterial($product->getRawMaterial());
$em = $this->getDoctrine()->getManager();
$em->persist($productCopy);
// relations
/* @var ProductRawMaterial $rawMaterial */
foreach ($product->getRawMaterials() as $rawMaterial) {
$rawMaterialCopy = new ProductRawMaterial();
$rawMaterialCopy->setRawMaterial($rawMaterial->getRawMaterial());
$rawMaterialCopy->setProduct($productCopy);
$rawMaterialCopy->setMeasureUnit($rawMaterial->getMeasureUnit());
$rawMaterialCopy->setQuantity($rawMaterial->getQuantity());
$em->persist($rawMaterialCopy);
$productCopy->addRawMaterial($rawMaterialCopy);
}
/* @var ProductCategory $category */
foreach ($product->getCategories() as $category) {
$productCopy->addCategory($category);
}
/* @var ProductCustomField $customField */
foreach ($product->getCustomFields() as $customField) {
$customFieldCopy = new ProductCustomField();
$customFieldCopy->setProduct($productCopy);
$customFieldCopy->setSettingField($customField->getSettingField());
$customFieldCopy->setValue($customField->getValue());
$em->persist($customFieldCopy);
$productCopy->addCustomField($customFieldCopy);
}
$em->flush();
return $this->redirect($this->generateUrl('product_show', array("id" => $productCopy->getId())));
} | [
"public",
"function",
"copyAction",
"(",
"Product",
"$",
"product",
")",
"{",
"$",
"productCopy",
"=",
"new",
"Product",
"(",
")",
";",
"$",
"copyName",
"=",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'Copy of'",
")",
".",
"\" \"",
".",
"$",
"product",
"->",
"getName",
"(",
")",
";",
"$",
"productCopy",
"->",
"setName",
"(",
"$",
"copyName",
")",
";",
"$",
"productCopy",
"->",
"setCostPrice",
"(",
"$",
"product",
"->",
"getCostPrice",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setDescription",
"(",
"$",
"product",
"->",
"getDescription",
"(",
")",
"??",
"$",
"copyName",
")",
";",
"$",
"productCopy",
"->",
"setCode",
"(",
"$",
"product",
"->",
"getCode",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setImage",
"(",
"$",
"product",
"->",
"getImage",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setPlace",
"(",
"$",
"product",
"->",
"getPlace",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setSalePrice",
"(",
"$",
"product",
"->",
"getSalePrice",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setSupplier",
"(",
"$",
"product",
"->",
"getSupplier",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setWarehouse",
"(",
"$",
"product",
"->",
"getWarehouse",
"(",
")",
")",
";",
"// boleans",
"$",
"productCopy",
"->",
"setEnabled",
"(",
"$",
"product",
"->",
"getEnabled",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setForSale",
"(",
"$",
"product",
"->",
"getForSale",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setCompositionOnDemand",
"(",
"$",
"product",
"->",
"isCompositionOnDemand",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setPack",
"(",
"$",
"product",
"->",
"isPack",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setManualPackPricing",
"(",
"$",
"product",
"->",
"isManualPackPricing",
"(",
")",
")",
";",
"$",
"productCopy",
"->",
"setRawMaterial",
"(",
"$",
"product",
"->",
"getRawMaterial",
"(",
")",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"productCopy",
")",
";",
"// relations",
"/* @var ProductRawMaterial $rawMaterial */",
"foreach",
"(",
"$",
"product",
"->",
"getRawMaterials",
"(",
")",
"as",
"$",
"rawMaterial",
")",
"{",
"$",
"rawMaterialCopy",
"=",
"new",
"ProductRawMaterial",
"(",
")",
";",
"$",
"rawMaterialCopy",
"->",
"setRawMaterial",
"(",
"$",
"rawMaterial",
"->",
"getRawMaterial",
"(",
")",
")",
";",
"$",
"rawMaterialCopy",
"->",
"setProduct",
"(",
"$",
"productCopy",
")",
";",
"$",
"rawMaterialCopy",
"->",
"setMeasureUnit",
"(",
"$",
"rawMaterial",
"->",
"getMeasureUnit",
"(",
")",
")",
";",
"$",
"rawMaterialCopy",
"->",
"setQuantity",
"(",
"$",
"rawMaterial",
"->",
"getQuantity",
"(",
")",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"rawMaterialCopy",
")",
";",
"$",
"productCopy",
"->",
"addRawMaterial",
"(",
"$",
"rawMaterialCopy",
")",
";",
"}",
"/* @var ProductCategory $category */",
"foreach",
"(",
"$",
"product",
"->",
"getCategories",
"(",
")",
"as",
"$",
"category",
")",
"{",
"$",
"productCopy",
"->",
"addCategory",
"(",
"$",
"category",
")",
";",
"}",
"/* @var ProductCustomField $customField */",
"foreach",
"(",
"$",
"product",
"->",
"getCustomFields",
"(",
")",
"as",
"$",
"customField",
")",
"{",
"$",
"customFieldCopy",
"=",
"new",
"ProductCustomField",
"(",
")",
";",
"$",
"customFieldCopy",
"->",
"setProduct",
"(",
"$",
"productCopy",
")",
";",
"$",
"customFieldCopy",
"->",
"setSettingField",
"(",
"$",
"customField",
"->",
"getSettingField",
"(",
")",
")",
";",
"$",
"customFieldCopy",
"->",
"setValue",
"(",
"$",
"customField",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"customFieldCopy",
")",
";",
"$",
"productCopy",
"->",
"addCustomField",
"(",
"$",
"customFieldCopy",
")",
";",
"}",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'product_show'",
",",
"array",
"(",
"\"id\"",
"=>",
"$",
"productCopy",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}"
] | Displays a form to edit an existing CampaignMail entity.
@Route("/{id}/copy", name="product_copy", requirements={"id"="\d+"})
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"CampaignMail",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L331-L396 |
885 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.updateAction | public function updateAction(Request $request, Product $entity)
{
$em = $this->getDoctrine()->getManager();
$entity = $this->addProductItemFieldData($entity);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Product entity.');
}
$deleteForm = $this->createDeleteForm($entity->getId());
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
/* @var ProductRawMaterial $productRawMaterial */
foreach ($entity->getRawMaterials() as $productRawMaterial) {
$productRawMaterial->setProduct($entity);
}
$em->flush();
return $this->redirect($this->generateUrl('admin_product_show', array('id' => $entity->getId())));
}
return array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function updateAction(Request $request, Product $entity)
{
$em = $this->getDoctrine()->getManager();
$entity = $this->addProductItemFieldData($entity);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Product entity.');
}
$deleteForm = $this->createDeleteForm($entity->getId());
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
/* @var ProductRawMaterial $productRawMaterial */
foreach ($entity->getRawMaterials() as $productRawMaterial) {
$productRawMaterial->setProduct($entity);
}
$em->flush();
return $this->redirect($this->generateUrl('admin_product_show', array('id' => $entity->getId())));
}
return array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"updateAction",
"(",
"Request",
"$",
"request",
",",
"Product",
"$",
"entity",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"addProductItemFieldData",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Product entity.'",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"entity",
"->",
"getId",
"(",
")",
")",
";",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createEditForm",
"(",
"$",
"entity",
")",
";",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"isValid",
"(",
")",
")",
"{",
"/* @var ProductRawMaterial $productRawMaterial */",
"foreach",
"(",
"$",
"entity",
"->",
"getRawMaterials",
"(",
")",
"as",
"$",
"productRawMaterial",
")",
"{",
"$",
"productRawMaterial",
"->",
"setProduct",
"(",
"$",
"entity",
")",
";",
"}",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_product_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"entity",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Edits an existing Product entity.
@Route("/{id}", name="admin_product_update")
@Method("PUT")
@Template("FlowcodeShopBundle:AdminProduct:edit.html.twig") | [
"Edits",
"an",
"existing",
"Product",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L405-L434 |
886 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.showGalleryItemAction | public function showGalleryItemAction(Product $product)
{
$entity = $product->getMediaGallery();
if (!$entity) {
throw $this->createNotFoundException('Unable to find Gallery entity.');
}
$deleteForm = $this->createDeleteForm($product->getId());
return array(
'entity' => $entity,
'product' => $product,
'delete_form' => $deleteForm->createView(),
);
} | php | public function showGalleryItemAction(Product $product)
{
$entity = $product->getMediaGallery();
if (!$entity) {
throw $this->createNotFoundException('Unable to find Gallery entity.');
}
$deleteForm = $this->createDeleteForm($product->getId());
return array(
'entity' => $entity,
'product' => $product,
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"showGalleryItemAction",
"(",
"Product",
"$",
"product",
")",
"{",
"$",
"entity",
"=",
"$",
"product",
"->",
"getMediaGallery",
"(",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Gallery entity.'",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"product",
"->",
"getId",
"(",
")",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'product'",
"=>",
"$",
"product",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Finds and displays a Gallery entity.
@Route("/{id}/gallery", name="admin_product_gallery_show")
@Method("GET")
@Template("FlowcodeShopBundle:AdminProduct:gallery_show.html.twig") | [
"Finds",
"and",
"displays",
"a",
"Gallery",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L590-L605 |
887 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.deleteGalleryItemAction | public function deleteGalleryItemAction(Request $request, GalleryItem $entity)
{
$form = $this->createDeleteForm($entity->getId());
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
if (!$entity) {
throw $this->createNotFoundException('Unable to find GalleryItem entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('admin_product'));
} | php | public function deleteGalleryItemAction(Request $request, GalleryItem $entity)
{
$form = $this->createDeleteForm($entity->getId());
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
if (!$entity) {
throw $this->createNotFoundException('Unable to find GalleryItem entity.');
}
$em->remove($entity);
$em->flush();
}
return $this->redirect($this->generateUrl('admin_product'));
} | [
"public",
"function",
"deleteGalleryItemAction",
"(",
"Request",
"$",
"request",
",",
"GalleryItem",
"$",
"entity",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"entity",
"->",
"getId",
"(",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find GalleryItem entity.'",
")",
";",
"}",
"$",
"em",
"->",
"remove",
"(",
"$",
"entity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_product'",
")",
")",
";",
"}"
] | Deletes a GalleryItem entity.
@Route("/galleryitem/{id}", name="admin_product_gallery_delete")
@Method("DELETE") | [
"Deletes",
"a",
"GalleryItem",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L670-L687 |
888 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.updateGalleryItemPosition | public function updateGalleryItemPosition(Request $request)
{
$em = $this->getDoctrine()->getManager();
$posArray = $request->get('data');
$i = 0;
foreach ($posArray as $item) {
$entity = $em->getRepository('AmulenMediaBundle:GalleryItem')->find($item);
$entity->setPosition($i);
$i++;
}
$em->flush();
return new Response('ok');
} | php | public function updateGalleryItemPosition(Request $request)
{
$em = $this->getDoctrine()->getManager();
$posArray = $request->get('data');
$i = 0;
foreach ($posArray as $item) {
$entity = $em->getRepository('AmulenMediaBundle:GalleryItem')->find($item);
$entity->setPosition($i);
$i++;
}
$em->flush();
return new Response('ok');
} | [
"public",
"function",
"updateGalleryItemPosition",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"posArray",
"=",
"$",
"request",
"->",
"get",
"(",
"'data'",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"posArray",
"as",
"$",
"item",
")",
"{",
"$",
"entity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'AmulenMediaBundle:GalleryItem'",
")",
"->",
"find",
"(",
"$",
"item",
")",
";",
"$",
"entity",
"->",
"setPosition",
"(",
"$",
"i",
")",
";",
"$",
"i",
"++",
";",
"}",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"new",
"Response",
"(",
"'ok'",
")",
";",
"}"
] | Actualizar la posicion de cada imagen.
@Route("/updatePosItem", name="admin_product_gallery_update_drag_drop")
@Method("POST") | [
"Actualizar",
"la",
"posicion",
"de",
"cada",
"imagen",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L756-L770 |
889 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.addMediaProductAction | public function addMediaProductAction(Product $product, $type = null)
{
if ($type == 'type_image_file') {
return $this->redirectToRoute('admin_product_new_image', array('id' => $product->getId()));
}
$entity = new Media();
$entity->setMediaType($type);
$form = $this->mediaCreateCreateForm($entity, $product);
return array(
'type' => $type,
'entity' => $entity,
'product' => $product,
'form' => $form->createView(),
);
} | php | public function addMediaProductAction(Product $product, $type = null)
{
if ($type == 'type_image_file') {
return $this->redirectToRoute('admin_product_new_image', array('id' => $product->getId()));
}
$entity = new Media();
$entity->setMediaType($type);
$form = $this->mediaCreateCreateForm($entity, $product);
return array(
'type' => $type,
'entity' => $entity,
'product' => $product,
'form' => $form->createView(),
);
} | [
"public",
"function",
"addMediaProductAction",
"(",
"Product",
"$",
"product",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'type_image_file'",
")",
"{",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'admin_product_new_image'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"product",
"->",
"getId",
"(",
")",
")",
")",
";",
"}",
"$",
"entity",
"=",
"new",
"Media",
"(",
")",
";",
"$",
"entity",
"->",
"setMediaType",
"(",
"$",
"type",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"mediaCreateCreateForm",
"(",
"$",
"entity",
",",
"$",
"product",
")",
";",
"return",
"array",
"(",
"'type'",
"=>",
"$",
"type",
",",
"'entity'",
"=>",
"$",
"entity",
",",
"'product'",
"=>",
"$",
"product",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Add media.
@Route("/{id}/addmedia/{type}", name="admin_product_new_media")
@Method("GET")
@Template("FlowcodeShopBundle:AdminProduct:media_new.html.twig") | [
"Add",
"media",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L836-L851 |
890 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.editMediaAction | public function editMediaAction(Product $product, Media $entity, $type, Request $request)
{
if (!$entity) {
throw $this->createNotFoundException('Unable to find Media entity.');
}
$editForm = $this->mediaCreateEditForm($entity, $product, $type);
return array(
'entity' => $entity,
'type' => $type,
'product' => $product,
'edit_form' => $editForm->createView(),
);
} | php | public function editMediaAction(Product $product, Media $entity, $type, Request $request)
{
if (!$entity) {
throw $this->createNotFoundException('Unable to find Media entity.');
}
$editForm = $this->mediaCreateEditForm($entity, $product, $type);
return array(
'entity' => $entity,
'type' => $type,
'product' => $product,
'edit_form' => $editForm->createView(),
);
} | [
"public",
"function",
"editMediaAction",
"(",
"Product",
"$",
"product",
",",
"Media",
"$",
"entity",
",",
"$",
"type",
",",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Media entity.'",
")",
";",
"}",
"$",
"editForm",
"=",
"$",
"this",
"->",
"mediaCreateEditForm",
"(",
"$",
"entity",
",",
"$",
"product",
",",
"$",
"type",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'type'",
"=>",
"$",
"type",
",",
"'product'",
"=>",
"$",
"product",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to edit an existing Media entity.
@Route("/{product}/media/{id}/{type}/edit", name="admin_product_media_edit")
@Method("GET")
@Template("FlowcodeShopBundle:AdminProduct:media_edit.html.twig") | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"Media",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L936-L950 |
891 | flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductController.php | AdminProductController.mediaCreateEditForm | private function mediaCreateEditForm(Media $entity, $product, $type)
{
$types = $this->container->getParameter('flowcode_media.media_types');
$class = $types[$entity->getMediaType()]["class_type"];
$form = $this->createForm(new $class(), $entity, array(
'action' => $this->generateUrl('admin_product_media_update', array("product" => $product->getId(), 'entity' => $entity->getId(), "type" => $entity->getMediaType())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | php | private function mediaCreateEditForm(Media $entity, $product, $type)
{
$types = $this->container->getParameter('flowcode_media.media_types');
$class = $types[$entity->getMediaType()]["class_type"];
$form = $this->createForm(new $class(), $entity, array(
'action' => $this->generateUrl('admin_product_media_update', array("product" => $product->getId(), 'entity' => $entity->getId(), "type" => $entity->getMediaType())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
} | [
"private",
"function",
"mediaCreateEditForm",
"(",
"Media",
"$",
"entity",
",",
"$",
"product",
",",
"$",
"type",
")",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'flowcode_media.media_types'",
")",
";",
"$",
"class",
"=",
"$",
"types",
"[",
"$",
"entity",
"->",
"getMediaType",
"(",
")",
"]",
"[",
"\"class_type\"",
"]",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"$",
"class",
"(",
")",
",",
"$",
"entity",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_product_media_update'",
",",
"array",
"(",
"\"product\"",
"=>",
"$",
"product",
"->",
"getId",
"(",
")",
",",
"'entity'",
"=>",
"$",
"entity",
"->",
"getId",
"(",
")",
",",
"\"type\"",
"=>",
"$",
"entity",
"->",
"getMediaType",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'submit'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"'Update'",
")",
")",
";",
"return",
"$",
"form",
";",
"}"
] | Creates a form to edit a Media entity.
@param Media $entity The entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"edit",
"a",
"Media",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductController.php#L959-L972 |
892 | marando/phpSOFA | src/Marando/IAU/iauRxpv.php | iauRxpv.Rxpv | public static function Rxpv(array $r, array $pv, array &$rpv) {
IAU::Rxp($r, $pv[0], $rpv[0]);
IAU::Rxp($r, $pv[1], $rpv[1]);
return;
} | php | public static function Rxpv(array $r, array $pv, array &$rpv) {
IAU::Rxp($r, $pv[0], $rpv[0]);
IAU::Rxp($r, $pv[1], $rpv[1]);
return;
} | [
"public",
"static",
"function",
"Rxpv",
"(",
"array",
"$",
"r",
",",
"array",
"$",
"pv",
",",
"array",
"&",
"$",
"rpv",
")",
"{",
"IAU",
"::",
"Rxp",
"(",
"$",
"r",
",",
"$",
"pv",
"[",
"0",
"]",
",",
"$",
"rpv",
"[",
"0",
"]",
")",
";",
"IAU",
"::",
"Rxp",
"(",
"$",
"r",
",",
"$",
"pv",
"[",
"1",
"]",
",",
"$",
"rpv",
"[",
"1",
"]",
")",
";",
"return",
";",
"}"
] | - - - - - - - -
i a u R x p v
- - - - - - - -
Multiply a pv-vector by an r-matrix.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: vector/matrix support function.
Given:
r double[3][3] r-matrix
pv double[2][3] pv-vector
Returned:
rpv double[2][3] r * pv
Note:
It is permissible for pv and rpv to be the same array.
Called:
iauRxp product of r-matrix and p-vector
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"R",
"x",
"p",
"v",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauRxpv.php#L38-L43 |
893 | colorium/text | src/Colorium/Text/Lang.php | Lang.load | public static function load(array $langs, $lang = null)
{
static::$langs = $langs;
static::$lang = $lang ?: key($langs);
} | php | public static function load(array $langs, $lang = null)
{
static::$langs = $langs;
static::$lang = $lang ?: key($langs);
} | [
"public",
"static",
"function",
"load",
"(",
"array",
"$",
"langs",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"static",
"::",
"$",
"langs",
"=",
"$",
"langs",
";",
"static",
"::",
"$",
"lang",
"=",
"$",
"lang",
"?",
":",
"key",
"(",
"$",
"langs",
")",
";",
"}"
] | Load langs array
@param array $langs
@param string $lang | [
"Load",
"langs",
"array"
] | a403b7bfe01f421a6ae124f1eac37a6db69d60db | https://github.com/colorium/text/blob/a403b7bfe01f421a6ae124f1eac37a6db69d60db/src/Colorium/Text/Lang.php#L20-L24 |
894 | FiveLab/ResourceBundle | src/Resource/EventListener/SymfonyGrantedActionListener.php | SymfonyGrantedActionListener.onBeforeNormalization | public function onBeforeNormalization(BeforeNormalizationEvent $event): void
{
$resource = $event->getResource();
if (!$resource instanceof ActionedResourceInterface) {
return;
}
$actions = $resource->getActions();
foreach ($actions as $action) {
if (!$action instanceof SymfonyGrantedAction) {
continue;
}
if (!$this->authorizationChecker->isGranted($action->getAttribute(), $action->getObject())) {
$resource->removeAction($action);
}
}
} | php | public function onBeforeNormalization(BeforeNormalizationEvent $event): void
{
$resource = $event->getResource();
if (!$resource instanceof ActionedResourceInterface) {
return;
}
$actions = $resource->getActions();
foreach ($actions as $action) {
if (!$action instanceof SymfonyGrantedAction) {
continue;
}
if (!$this->authorizationChecker->isGranted($action->getAttribute(), $action->getObject())) {
$resource->removeAction($action);
}
}
} | [
"public",
"function",
"onBeforeNormalization",
"(",
"BeforeNormalizationEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"resource",
"=",
"$",
"event",
"->",
"getResource",
"(",
")",
";",
"if",
"(",
"!",
"$",
"resource",
"instanceof",
"ActionedResourceInterface",
")",
"{",
"return",
";",
"}",
"$",
"actions",
"=",
"$",
"resource",
"->",
"getActions",
"(",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"$",
"action",
"instanceof",
"SymfonyGrantedAction",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"authorizationChecker",
"->",
"isGranted",
"(",
"$",
"action",
"->",
"getAttribute",
"(",
")",
",",
"$",
"action",
"->",
"getObject",
"(",
")",
")",
")",
"{",
"$",
"resource",
"->",
"removeAction",
"(",
"$",
"action",
")",
";",
"}",
"}",
"}"
] | Check the grants to actions
@param BeforeNormalizationEvent $event | [
"Check",
"the",
"grants",
"to",
"actions"
] | 048fce7be5357dc23fef1402ef8ca213489e8154 | https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/Resource/EventListener/SymfonyGrantedActionListener.php#L48-L67 |
895 | fabsgc/framework | Core/General/Errors.php | Errors.addError | public function addError($error, $file = __FILE__, $line = __LINE__, $type = ERROR_INFORMATION, $log = LOG_SYSTEM) {
if ($log != LOG_HISTORY && $log != LOG_CRONS && $log != LOG_EVENT) {
if (Config::config()['user']['debug']['log']) {
if ($log == LOG_SQL) {
$error = preg_replace('#([\t]{2,})#isU', "", $error);
}
$data = date("d/m/Y H:i:s : ", time()) . '[' . $type . '] file ' . $file . ' / line ' . $line . ' / ' . $error;
file_put_contents(APP_LOG_PATH . $log . '.log', $data . "\n", FILE_APPEND | LOCK_EX);
if ((Config::config()['user']['debug']['error']['error'] && $type == ERROR_FATAL) || (Config::config()['user']['debug']['error']['exception'] == true && $type == ERROR_EXCEPTION) || preg_match('#Exception#isU', $type) || (Config::config()['user']['debug']['error']['fatal'] == true && $type == ERROR_ERROR)) {
if (CONSOLE_ENABLED == MODE_HTTP) {
echo $data . "\n<br />";
}
else {
echo $data . "\n";
}
}
}
}
else {
file_put_contents(APP_LOG_PATH . $log . '.log', $error . "\n", FILE_APPEND | LOCK_EX);
}
} | php | public function addError($error, $file = __FILE__, $line = __LINE__, $type = ERROR_INFORMATION, $log = LOG_SYSTEM) {
if ($log != LOG_HISTORY && $log != LOG_CRONS && $log != LOG_EVENT) {
if (Config::config()['user']['debug']['log']) {
if ($log == LOG_SQL) {
$error = preg_replace('#([\t]{2,})#isU', "", $error);
}
$data = date("d/m/Y H:i:s : ", time()) . '[' . $type . '] file ' . $file . ' / line ' . $line . ' / ' . $error;
file_put_contents(APP_LOG_PATH . $log . '.log', $data . "\n", FILE_APPEND | LOCK_EX);
if ((Config::config()['user']['debug']['error']['error'] && $type == ERROR_FATAL) || (Config::config()['user']['debug']['error']['exception'] == true && $type == ERROR_EXCEPTION) || preg_match('#Exception#isU', $type) || (Config::config()['user']['debug']['error']['fatal'] == true && $type == ERROR_ERROR)) {
if (CONSOLE_ENABLED == MODE_HTTP) {
echo $data . "\n<br />";
}
else {
echo $data . "\n";
}
}
}
}
else {
file_put_contents(APP_LOG_PATH . $log . '.log', $error . "\n", FILE_APPEND | LOCK_EX);
}
} | [
"public",
"function",
"addError",
"(",
"$",
"error",
",",
"$",
"file",
"=",
"__FILE__",
",",
"$",
"line",
"=",
"__LINE__",
",",
"$",
"type",
"=",
"ERROR_INFORMATION",
",",
"$",
"log",
"=",
"LOG_SYSTEM",
")",
"{",
"if",
"(",
"$",
"log",
"!=",
"LOG_HISTORY",
"&&",
"$",
"log",
"!=",
"LOG_CRONS",
"&&",
"$",
"log",
"!=",
"LOG_EVENT",
")",
"{",
"if",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'log'",
"]",
")",
"{",
"if",
"(",
"$",
"log",
"==",
"LOG_SQL",
")",
"{",
"$",
"error",
"=",
"preg_replace",
"(",
"'#([\\t]{2,})#isU'",
",",
"\"\"",
",",
"$",
"error",
")",
";",
"}",
"$",
"data",
"=",
"date",
"(",
"\"d/m/Y H:i:s : \"",
",",
"time",
"(",
")",
")",
".",
"'['",
".",
"$",
"type",
".",
"'] file '",
".",
"$",
"file",
".",
"' / line '",
".",
"$",
"line",
".",
"' / '",
".",
"$",
"error",
";",
"file_put_contents",
"(",
"APP_LOG_PATH",
".",
"$",
"log",
".",
"'.log'",
",",
"$",
"data",
".",
"\"\\n\"",
",",
"FILE_APPEND",
"|",
"LOCK_EX",
")",
";",
"if",
"(",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'error'",
"]",
"[",
"'error'",
"]",
"&&",
"$",
"type",
"==",
"ERROR_FATAL",
")",
"||",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'error'",
"]",
"[",
"'exception'",
"]",
"==",
"true",
"&&",
"$",
"type",
"==",
"ERROR_EXCEPTION",
")",
"||",
"preg_match",
"(",
"'#Exception#isU'",
",",
"$",
"type",
")",
"||",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'error'",
"]",
"[",
"'fatal'",
"]",
"==",
"true",
"&&",
"$",
"type",
"==",
"ERROR_ERROR",
")",
")",
"{",
"if",
"(",
"CONSOLE_ENABLED",
"==",
"MODE_HTTP",
")",
"{",
"echo",
"$",
"data",
".",
"\"\\n<br />\"",
";",
"}",
"else",
"{",
"echo",
"$",
"data",
".",
"\"\\n\"",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"file_put_contents",
"(",
"APP_LOG_PATH",
".",
"$",
"log",
".",
"'.log'",
",",
"$",
"error",
".",
"\"\\n\"",
",",
"FILE_APPEND",
"|",
"LOCK_EX",
")",
";",
"}",
"}"
] | add an error in the log
@access public
@param $error string : error
@param $file string : file with error
@param $line int : line with error
@param $type string : type of error
@param $log string : log file
@return void
@since 3.0 | [
"add",
"an",
"error",
"in",
"the",
"log"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/General/Errors.php#L33-L56 |
896 | fabsgc/framework | Core/General/Errors.php | Errors.addErrorHr | public function addErrorHr($log = LOG_SYSTEM) {
if (Config::config()['user']['debug']['log']) {
file_put_contents(APP_LOG_PATH . $log . '.log', "#################### END OF EXECUTION OF http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " ####################\n", FILE_APPEND | LOCK_EX);
}
} | php | public function addErrorHr($log = LOG_SYSTEM) {
if (Config::config()['user']['debug']['log']) {
file_put_contents(APP_LOG_PATH . $log . '.log', "#################### END OF EXECUTION OF http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " ####################\n", FILE_APPEND | LOCK_EX);
}
} | [
"public",
"function",
"addErrorHr",
"(",
"$",
"log",
"=",
"LOG_SYSTEM",
")",
"{",
"if",
"(",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'debug'",
"]",
"[",
"'log'",
"]",
")",
"{",
"file_put_contents",
"(",
"APP_LOG_PATH",
".",
"$",
"log",
".",
"'.log'",
",",
"\"#################### END OF EXECUTION OF http://\"",
".",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
".",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
".",
"\" ####################\\n\"",
",",
"FILE_APPEND",
"|",
"LOCK_EX",
")",
";",
"}",
"}"
] | add an hr line in the log
@access public
@param $log string : log file
@return void
@since 3.0 | [
"add",
"an",
"hr",
"line",
"in",
"the",
"log"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/General/Errors.php#L66-L70 |
897 | tenside/core-bundle | src/Security/UserProviderFromConfig.php | UserProviderFromConfig.removeUser | public function removeUser($user)
{
$username = ($user instanceof UserInformation) ? $user->getUsername() : (string) $user;
$this->configSource->set('auth-password/' . $username, null);
return $this;
} | php | public function removeUser($user)
{
$username = ($user instanceof UserInformation) ? $user->getUsername() : (string) $user;
$this->configSource->set('auth-password/' . $username, null);
return $this;
} | [
"public",
"function",
"removeUser",
"(",
"$",
"user",
")",
"{",
"$",
"username",
"=",
"(",
"$",
"user",
"instanceof",
"UserInformation",
")",
"?",
"$",
"user",
"->",
"getUsername",
"(",
")",
":",
"(",
"string",
")",
"$",
"user",
";",
"$",
"this",
"->",
"configSource",
"->",
"set",
"(",
"'auth-password/'",
".",
"$",
"username",
",",
"null",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add the passed credentials in the database.
@param string|UserInformation $user The username to remove.
@return UserProviderFromConfig | [
"Add",
"the",
"passed",
"credentials",
"in",
"the",
"database",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Security/UserProviderFromConfig.php#L110-L117 |
898 | silverorange/Net_Notifier | Net/Notifier/WebSocket/Frame.php | Net_Notifier_WebSocket_Frame.parse | public function parse($data)
{
if ($this->state === self::STATE_UNSENT) {
$this->state = self::STATE_OPENED;
}
if ($this->isHeaderComplete) {
$data = $this->parseData($data);
} else {
$data = $this->parseHeader($data);
}
if ($this->cursor == $this->getLength() + $this->headerLength) {
$this->state = self::STATE_DONE;
}
return $data;
} | php | public function parse($data)
{
if ($this->state === self::STATE_UNSENT) {
$this->state = self::STATE_OPENED;
}
if ($this->isHeaderComplete) {
$data = $this->parseData($data);
} else {
$data = $this->parseHeader($data);
}
if ($this->cursor == $this->getLength() + $this->headerLength) {
$this->state = self::STATE_DONE;
}
return $data;
} | [
"public",
"function",
"parse",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"self",
"::",
"STATE_UNSENT",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_OPENED",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isHeaderComplete",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"parseData",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"parseHeader",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"cursor",
"==",
"$",
"this",
"->",
"getLength",
"(",
")",
"+",
"$",
"this",
"->",
"headerLength",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_DONE",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Parses raw data for this frame
This is intented to be called after reading a raw data chunk from a
WebSocket endpoint. If the chunk contains more data than this frame, the
extra data is returned so it may be passed to the next frame for
parsing.
@param string $data the raw data to parse.
@return string any remaining unparsed data not belonging to this frame. | [
"Parses",
"raw",
"data",
"for",
"this",
"frame"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/WebSocket/Frame.php#L378-L395 |
899 | silverorange/Net_Notifier | Net/Notifier/WebSocket/Frame.php | Net_Notifier_WebSocket_Frame.getLength | public function getLength()
{
$length = $this->length64;
if ($length == 0) {
$length = $this->length16;
}
if ($length == 0) {
$length = $this->length;
}
return $length;
} | php | public function getLength()
{
$length = $this->length64;
if ($length == 0) {
$length = $this->length16;
}
if ($length == 0) {
$length = $this->length;
}
return $length;
} | [
"public",
"function",
"getLength",
"(",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"length64",
";",
"if",
"(",
"$",
"length",
"==",
"0",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"length16",
";",
"}",
"if",
"(",
"$",
"length",
"==",
"0",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"length",
";",
"}",
"return",
"$",
"length",
";",
"}"
] | Gets the length of this frame's payload data in bytes
@return integer the length of this frame's payload data in bytes.
@todo Support long lengths (length values larger than a 32-bit signed
integer.) | [
"Gets",
"the",
"length",
"of",
"this",
"frame",
"s",
"payload",
"data",
"in",
"bytes"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/WebSocket/Frame.php#L482-L495 |