Search is not available for this dataset
repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
list | func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
list | split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
| parameters
list | question
stringlengths 9
114
| answer
list |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
xiewulong/yii2-wechat
|
Manager.php
|
Manager.deleteMaterial
|
public function deleteMaterial($media_id) {
$data = $this->getData('/cgi-bin/material/del_material', [
'access_token' => $this->getAccessToken(),
], Json::encode(['media_id' => $media_id]));
return $this->errcode == 0;
}
|
php
|
public function deleteMaterial($media_id) {
$data = $this->getData('/cgi-bin/material/del_material', [
'access_token' => $this->getAccessToken(),
], Json::encode(['media_id' => $media_id]));
return $this->errcode == 0;
}
|
[
"public",
"function",
"deleteMaterial",
"(",
"$",
"media_id",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/material/del_material'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'media_id'",
"=>",
"$",
"media_id",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"}"
] |
删除永久素材
@since 0.0.1
@param {string} $media_id 媒体文件ID
@return {boolean}
@example \Yii::$app->wechat->deleteMaterial($media_id);
|
[
"删除永久素材"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L440-L446
|
[
"media_id"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->deleteMaterial($media_id);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getMaterial
|
public function getMaterial($media_id) {
$data = $this->getData('/cgi-bin/material/get_material', [
'access_token' => $this->getAccessToken(),
], Json::encode(['media_id' => $media_id]));
return $this->errcode == 0 ? (isset($data['content']) && isset($data['extension']) ? $this->saveFile($data) : $data) : null;
}
|
php
|
public function getMaterial($media_id) {
$data = $this->getData('/cgi-bin/material/get_material', [
'access_token' => $this->getAccessToken(),
], Json::encode(['media_id' => $media_id]));
return $this->errcode == 0 ? (isset($data['content']) && isset($data['extension']) ? $this->saveFile($data) : $data) : null;
}
|
[
"public",
"function",
"getMaterial",
"(",
"$",
"media_id",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/material/get_material'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'media_id'",
"=>",
"$",
"media_id",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
"?",
"(",
"isset",
"(",
"$",
"data",
"[",
"'content'",
"]",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'extension'",
"]",
")",
"?",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"data",
")",
":",
"$",
"data",
")",
":",
"null",
";",
"}"
] |
获取永久素材
@since 0.0.1
@param {string} $media_id 媒体文件ID
@return {string|array|null}
@example \Yii::$app->wechat->getMaterial($media_id);
|
[
"获取永久素材"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L456-L462
|
[
"media_id"
] |
What does this function return?
|
[
"{string|array|null}",
"@example",
"\\Yii::$app->wechat->getMaterial($media_id);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.addMaterial
|
public function addMaterial($material_id) {
$material = WechatMaterial::findOne($material_id);
if(!$material) {
throw new ErrorException('数据查询失败');
}else if($materialMedia = WechatMaterialMedia::findOne(['appid' => $this->app->appid, 'material_id' => $material->id, 'expired_at' => 0])) {
return $materialMedia->id;
}
$postData = ['media' => '@' . $material->localFile];
if($material->type == 'video') {
if($material->title == '') {
throw new ErrorException('视频标题不能为空');
}
$postData['description'] = Json::encode([
'title' => $material->title,
'introduction' => $material->description,
]);
}
$data = $this->getData('/cgi-bin/material/add_material', [
'access_token' => $this->getAccessToken(),
'type' => $material->type,
], $postData);
$material->cleanTmp();
if($this->errcode == 0) {
$materialMedia = new WechatMaterialMedia;
$materialMedia->appid = $this->app->appid;
$materialMedia->material_id = $material->id;
$materialMedia->media_id = $data['media_id'];
if(isset($data['url'])) {
$materialMedia->url = $data['url'];
}
if($materialMedia->save()) {
return $materialMedia->id;
}
}
return 0;
}
|
php
|
public function addMaterial($material_id) {
$material = WechatMaterial::findOne($material_id);
if(!$material) {
throw new ErrorException('数据查询失败');
}else if($materialMedia = WechatMaterialMedia::findOne(['appid' => $this->app->appid, 'material_id' => $material->id, 'expired_at' => 0])) {
return $materialMedia->id;
}
$postData = ['media' => '@' . $material->localFile];
if($material->type == 'video') {
if($material->title == '') {
throw new ErrorException('视频标题不能为空');
}
$postData['description'] = Json::encode([
'title' => $material->title,
'introduction' => $material->description,
]);
}
$data = $this->getData('/cgi-bin/material/add_material', [
'access_token' => $this->getAccessToken(),
'type' => $material->type,
], $postData);
$material->cleanTmp();
if($this->errcode == 0) {
$materialMedia = new WechatMaterialMedia;
$materialMedia->appid = $this->app->appid;
$materialMedia->material_id = $material->id;
$materialMedia->media_id = $data['media_id'];
if(isset($data['url'])) {
$materialMedia->url = $data['url'];
}
if($materialMedia->save()) {
return $materialMedia->id;
}
}
return 0;
}
|
[
"public",
"function",
"addMaterial",
"(",
"$",
"material_id",
")",
"{",
"$",
"material",
"=",
"WechatMaterial",
"::",
"findOne",
"(",
"$",
"material_id",
")",
";",
"if",
"(",
"!",
"$",
"material",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'数据查询失败');",
"",
"",
"}",
"else",
"if",
"(",
"$",
"materialMedia",
"=",
"WechatMaterialMedia",
"::",
"findOne",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'material_id'",
"=>",
"$",
"material",
"->",
"id",
",",
"'expired_at'",
"=>",
"0",
"]",
")",
")",
"{",
"return",
"$",
"materialMedia",
"->",
"id",
";",
"}",
"$",
"postData",
"=",
"[",
"'media'",
"=>",
"'@'",
".",
"$",
"material",
"->",
"localFile",
"]",
";",
"if",
"(",
"$",
"material",
"->",
"type",
"==",
"'video'",
")",
"{",
"if",
"(",
"$",
"material",
"->",
"title",
"==",
"''",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'视频标题不能为空');",
"",
"",
"}",
"$",
"postData",
"[",
"'description'",
"]",
"=",
"Json",
"::",
"encode",
"(",
"[",
"'title'",
"=>",
"$",
"material",
"->",
"title",
",",
"'introduction'",
"=>",
"$",
"material",
"->",
"description",
",",
"]",
")",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/material/add_material'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"'type'",
"=>",
"$",
"material",
"->",
"type",
",",
"]",
",",
"$",
"postData",
")",
";",
"$",
"material",
"->",
"cleanTmp",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"errcode",
"==",
"0",
")",
"{",
"$",
"materialMedia",
"=",
"new",
"WechatMaterialMedia",
";",
"$",
"materialMedia",
"->",
"appid",
"=",
"$",
"this",
"->",
"app",
"->",
"appid",
";",
"$",
"materialMedia",
"->",
"material_id",
"=",
"$",
"material",
"->",
"id",
";",
"$",
"materialMedia",
"->",
"media_id",
"=",
"$",
"data",
"[",
"'media_id'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"materialMedia",
"->",
"url",
"=",
"$",
"data",
"[",
"'url'",
"]",
";",
"}",
"if",
"(",
"$",
"materialMedia",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"materialMedia",
"->",
"id",
";",
"}",
"}",
"return",
"0",
";",
"}"
] |
新增永久素材
@since 0.0.1
@param {integer} $material_id 素材id
@return {integer}
@example \Yii::$app->wechat->addMaterial($material_id);
|
[
"新增永久素材"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L472-L511
|
[
"material_id"
] |
What does this function return?
|
[
"{integer}",
"@example",
"\\Yii::$app->wechat->addMaterial($material_id);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getMedia
|
public function getMedia($media_id) {
$data = $this->getData('/cgi-bin/media/get', [
'access_token' => $this->getAccessToken(),
'media_id' => $media_id,
]);
return $this->errcode == 0 ? $this->saveFile($data) : null;
}
|
php
|
public function getMedia($media_id) {
$data = $this->getData('/cgi-bin/media/get', [
'access_token' => $this->getAccessToken(),
'media_id' => $media_id,
]);
return $this->errcode == 0 ? $this->saveFile($data) : null;
}
|
[
"public",
"function",
"getMedia",
"(",
"$",
"media_id",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/media/get'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"'media_id'",
"=>",
"$",
"media_id",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
"?",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"data",
")",
":",
"null",
";",
"}"
] |
获取临时素材
@since 0.0.1
@param {string} $media_id 媒体文件ID
@return {string|null}
@example \Yii::$app->wechat->getMedia($media_id);
|
[
"获取临时素材"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L521-L528
|
[
"media_id"
] |
What does this function return?
|
[
"{string|null}",
"@example",
"\\Yii::$app->wechat->getMedia($media_id);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.addMedia
|
public function addMedia($material_id) {
$material = WechatMaterial::findOne($material_id);
if(!$material) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/media/upload', [
'access_token' => $this->getAccessToken(),
'type' => $material->type,
], ['media' => '@' . $material->localFile]);
$material->cleanTmp();
if($this->errcode == 0) {
$materialMedia = new WechatMaterialMedia;
$materialMedia->appid = $this->app->appid;
$materialMedia->material_id = $material->id;
$materialMedia->media_id = $data['media_id'];
$materialMedia->expired_at = $data['created_at'] + $this->effectiveTimeOfTemporaryMaterial;
if($materialMedia->save()) {
return $materialMedia->id;
}
}
return 0;
}
|
php
|
public function addMedia($material_id) {
$material = WechatMaterial::findOne($material_id);
if(!$material) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/media/upload', [
'access_token' => $this->getAccessToken(),
'type' => $material->type,
], ['media' => '@' . $material->localFile]);
$material->cleanTmp();
if($this->errcode == 0) {
$materialMedia = new WechatMaterialMedia;
$materialMedia->appid = $this->app->appid;
$materialMedia->material_id = $material->id;
$materialMedia->media_id = $data['media_id'];
$materialMedia->expired_at = $data['created_at'] + $this->effectiveTimeOfTemporaryMaterial;
if($materialMedia->save()) {
return $materialMedia->id;
}
}
return 0;
}
|
[
"public",
"function",
"addMedia",
"(",
"$",
"material_id",
")",
"{",
"$",
"material",
"=",
"WechatMaterial",
"::",
"findOne",
"(",
"$",
"material_id",
")",
";",
"if",
"(",
"!",
"$",
"material",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'数据查询失败');",
"",
"",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/media/upload'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"'type'",
"=>",
"$",
"material",
"->",
"type",
",",
"]",
",",
"[",
"'media'",
"=>",
"'@'",
".",
"$",
"material",
"->",
"localFile",
"]",
")",
";",
"$",
"material",
"->",
"cleanTmp",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"errcode",
"==",
"0",
")",
"{",
"$",
"materialMedia",
"=",
"new",
"WechatMaterialMedia",
";",
"$",
"materialMedia",
"->",
"appid",
"=",
"$",
"this",
"->",
"app",
"->",
"appid",
";",
"$",
"materialMedia",
"->",
"material_id",
"=",
"$",
"material",
"->",
"id",
";",
"$",
"materialMedia",
"->",
"media_id",
"=",
"$",
"data",
"[",
"'media_id'",
"]",
";",
"$",
"materialMedia",
"->",
"expired_at",
"=",
"$",
"data",
"[",
"'created_at'",
"]",
"+",
"$",
"this",
"->",
"effectiveTimeOfTemporaryMaterial",
";",
"if",
"(",
"$",
"materialMedia",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"materialMedia",
"->",
"id",
";",
"}",
"}",
"return",
"0",
";",
"}"
] |
新增临时素材
@since 0.0.1
@param {integer} $material_id 素材id
@return {integer}
@example \Yii::$app->wechat->addMedia($material_id);
|
[
"新增临时素材"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L538-L562
|
[
"material_id"
] |
What does this function return?
|
[
"{integer}",
"@example",
"\\Yii::$app->wechat->addMedia($material_id);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.tryMatchMenu
|
public function tryMatchMenu($openid) {
$data = $this->getData('/cgi-bin/menu/trymatch', [
'access_token' => $this->getAccessToken(),
], Json::encode(['user_id' => $openid]));
return $this->errcode == 0 ? $data : [];
}
|
php
|
public function tryMatchMenu($openid) {
$data = $this->getData('/cgi-bin/menu/trymatch', [
'access_token' => $this->getAccessToken(),
], Json::encode(['user_id' => $openid]));
return $this->errcode == 0 ? $data : [];
}
|
[
"public",
"function",
"tryMatchMenu",
"(",
"$",
"openid",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/menu/trymatch'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'user_id'",
"=>",
"$",
"openid",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
"?",
"$",
"data",
":",
"[",
"]",
";",
"}"
] |
测试个性化菜单匹配结果
@since 0.0.1
@param {string} $openid OpenID或微信号
@return {array}
@example \Yii::$app->wechat->tryMatchMenu($openid);
|
[
"测试个性化菜单匹配结果"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L587-L593
|
[
"openid"
] |
What does this function return?
|
[
"{array}",
"@example",
"\\Yii::$app->wechat->tryMatchMenu($openid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.deleteConditionalMenu
|
public function deleteConditionalMenu($menuid) {
$data = $this->getData('/cgi-bin/menu/delconditional', [
'access_token' => $this->getAccessToken(),
], Json::encode(['menuid' => $menuid]));
return $this->errcode == 0 && WechatMenu::deleteAll(['appid' => $this->app->appid, 'conditional' => 1, 'menuid' => $menuid]);
}
|
php
|
public function deleteConditionalMenu($menuid) {
$data = $this->getData('/cgi-bin/menu/delconditional', [
'access_token' => $this->getAccessToken(),
], Json::encode(['menuid' => $menuid]));
return $this->errcode == 0 && WechatMenu::deleteAll(['appid' => $this->app->appid, 'conditional' => 1, 'menuid' => $menuid]);
}
|
[
"public",
"function",
"deleteConditionalMenu",
"(",
"$",
"menuid",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/menu/delconditional'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'menuid'",
"=>",
"$",
"menuid",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
"&&",
"WechatMenu",
"::",
"deleteAll",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'conditional'",
"=>",
"1",
",",
"'menuid'",
"=>",
"$",
"menuid",
"]",
")",
";",
"}"
] |
删除个性化菜单
@since 0.0.1
@param {integer} $menuid 菜单id
@return {boolean}
@example \Yii::$app->wechat->deleteConditionalMenu($menuid);
|
[
"删除个性化菜单"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L603-L609
|
[
"menuid"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->deleteConditionalMenu($menuid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.deleteMenu
|
public function deleteMenu() {
$data = $this->getData('/cgi-bin/menu/delete', [
'access_token' => $this->getAccessToken(),
]);
return $this->errcode == 0 && WechatMenu::deleteAll(['appid' => $this->app->appid]);
}
|
php
|
public function deleteMenu() {
$data = $this->getData('/cgi-bin/menu/delete', [
'access_token' => $this->getAccessToken(),
]);
return $this->errcode == 0 && WechatMenu::deleteAll(['appid' => $this->app->appid]);
}
|
[
"public",
"function",
"deleteMenu",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/menu/delete'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
"&&",
"WechatMenu",
"::",
"deleteAll",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
"]",
")",
";",
"}"
] |
删除自定义(个性化)菜单
@since 0.0.1
@return {boolean}
@example \Yii::$app->wechat->deleteMenu();
|
[
"删除自定义",
"(",
"个性化",
")",
"菜单"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L618-L624
|
[] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->deleteMenu();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.updateMenu
|
public function updateMenu() {
$data = $this->getData('/cgi-bin/menu/create', [
'access_token' => $this->getAccessToken(),
], Json::encode(['button' => WechatMenu::getMenu($this->app->appid)]));
return $this->errcode == 0;
}
|
php
|
public function updateMenu() {
$data = $this->getData('/cgi-bin/menu/create', [
'access_token' => $this->getAccessToken(),
], Json::encode(['button' => WechatMenu::getMenu($this->app->appid)]));
return $this->errcode == 0;
}
|
[
"public",
"function",
"updateMenu",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/menu/create'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'button'",
"=>",
"WechatMenu",
"::",
"getMenu",
"(",
"$",
"this",
"->",
"app",
"->",
"appid",
")",
"]",
")",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"}"
] |
更新自定义菜单
@method updateMenu
@since 0.0.1
@return {boolean}
@example \Yii::$app->wechat->updateMenu();
|
[
"更新自定义菜单"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L633-L639
|
[] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->updateMenu();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.createMenu
|
public function createMenu($button, $matchrule = null) {
$postData = ['button' => $button];
if($matchrule) {
$postData['matchrule'] = $matchrule;
}
$data = $this->getData('/cgi-bin/menu/' . ($matchrule ? 'addconditional' : 'create'), [
'access_token' => $this->getAccessToken(),
], Json::encode($postData));
if(isset($data['menuid'])) {
$postData['menuid'] = $data['menuid'];
}
return $this->errcode == 0 && WechatMenu::createMenu($this->app->appid, $postData);
}
|
php
|
public function createMenu($button, $matchrule = null) {
$postData = ['button' => $button];
if($matchrule) {
$postData['matchrule'] = $matchrule;
}
$data = $this->getData('/cgi-bin/menu/' . ($matchrule ? 'addconditional' : 'create'), [
'access_token' => $this->getAccessToken(),
], Json::encode($postData));
if(isset($data['menuid'])) {
$postData['menuid'] = $data['menuid'];
}
return $this->errcode == 0 && WechatMenu::createMenu($this->app->appid, $postData);
}
|
[
"public",
"function",
"createMenu",
"(",
"$",
"button",
",",
"$",
"matchrule",
"=",
"null",
")",
"{",
"$",
"postData",
"=",
"[",
"'button'",
"=>",
"$",
"button",
"]",
";",
"if",
"(",
"$",
"matchrule",
")",
"{",
"$",
"postData",
"[",
"'matchrule'",
"]",
"=",
"$",
"matchrule",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/menu/'",
".",
"(",
"$",
"matchrule",
"?",
"'addconditional'",
":",
"'create'",
")",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"$",
"postData",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'menuid'",
"]",
")",
")",
"{",
"$",
"postData",
"[",
"'menuid'",
"]",
"=",
"$",
"data",
"[",
"'menuid'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
"&&",
"WechatMenu",
"::",
"createMenu",
"(",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"$",
"postData",
")",
";",
"}"
] |
创建自定义(个性化)菜单
@since 0.0.1
@param {array} $button 菜单数据
@param {array} [$matchrule] 个性化菜单匹配规则
@return {boolean}
@example \Yii::$app->wechat->createMenu($button, $matchrule);
|
[
"创建自定义",
"(",
"个性化",
")",
"菜单"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L650-L665
|
[
"button",
"matchrule"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->createMenu($button,",
"$matchrule);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.refreshMenu
|
public function refreshMenu() {
$data = $this->getMenu();
if($data && isset($data['menu']) && isset($data['menu']['button'])) {
WechatMenu::deleteAll(['appid' => $this->app->appid]);
WechatMenu::addMenu($this->app->appid, $data['menu']['button'], isset($data['menu']['menuid']) ? $data['menu']['menuid'] : null);
if(isset($data['conditionalmenu'])) {
foreach($data['conditionalmenu'] as $conditionalmenu) {
WechatMenu::addMenu($this->app->appid, $conditionalmenu['button'], $conditionalmenu['menuid'], $conditionalmenu['matchrule']);
}
}
return true;
}
return false;
}
|
php
|
public function refreshMenu() {
$data = $this->getMenu();
if($data && isset($data['menu']) && isset($data['menu']['button'])) {
WechatMenu::deleteAll(['appid' => $this->app->appid]);
WechatMenu::addMenu($this->app->appid, $data['menu']['button'], isset($data['menu']['menuid']) ? $data['menu']['menuid'] : null);
if(isset($data['conditionalmenu'])) {
foreach($data['conditionalmenu'] as $conditionalmenu) {
WechatMenu::addMenu($this->app->appid, $conditionalmenu['button'], $conditionalmenu['menuid'], $conditionalmenu['matchrule']);
}
}
return true;
}
return false;
}
|
[
"public",
"function",
"refreshMenu",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getMenu",
"(",
")",
";",
"if",
"(",
"$",
"data",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'menu'",
"]",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'menu'",
"]",
"[",
"'button'",
"]",
")",
")",
"{",
"WechatMenu",
"::",
"deleteAll",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
"]",
")",
";",
"WechatMenu",
"::",
"addMenu",
"(",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"$",
"data",
"[",
"'menu'",
"]",
"[",
"'button'",
"]",
",",
"isset",
"(",
"$",
"data",
"[",
"'menu'",
"]",
"[",
"'menuid'",
"]",
")",
"?",
"$",
"data",
"[",
"'menu'",
"]",
"[",
"'menuid'",
"]",
":",
"null",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'conditionalmenu'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'conditionalmenu'",
"]",
"as",
"$",
"conditionalmenu",
")",
"{",
"WechatMenu",
"::",
"addMenu",
"(",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"$",
"conditionalmenu",
"[",
"'button'",
"]",
",",
"$",
"conditionalmenu",
"[",
"'menuid'",
"]",
",",
"$",
"conditionalmenu",
"[",
"'matchrule'",
"]",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
刷新自定义(个性化)菜单
@since 0.0.1
@return {boolean}
@example \Yii::$app->wechat->refreshMenu();
|
[
"刷新自定义",
"(",
"个性化",
")",
"菜单"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L674-L689
|
[] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->refreshMenu();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.updateGroupUsers
|
public function updateGroupUsers($uids, $gid) {
if(is_array($uids)) {
$uids = implode(',', $uids);
}
$query = WechatUser::find()->where("id in ($uids) and groupid <> $gid");
$users = $query->all();
$openids = ArrayHelper::getColumn($users, 'openid');
if(!$openids) {
return true;
}
$data = $this->getData('/cgi-bin/groups/members/batchupdate', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid_list' => $openids,
'to_groupid' => $gid,
]));
$result = $this->errcode == 0;
if($result) {
foreach($users as $user) {
if($user->group->updateCounters(['count' => -1])) {
$user->groupid = $gid;
if($user->save()) {
$user->refresh();
$user->group->updateCounters(['count' => 1]);
}
}
}
}
return $result;
}
|
php
|
public function updateGroupUsers($uids, $gid) {
if(is_array($uids)) {
$uids = implode(',', $uids);
}
$query = WechatUser::find()->where("id in ($uids) and groupid <> $gid");
$users = $query->all();
$openids = ArrayHelper::getColumn($users, 'openid');
if(!$openids) {
return true;
}
$data = $this->getData('/cgi-bin/groups/members/batchupdate', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid_list' => $openids,
'to_groupid' => $gid,
]));
$result = $this->errcode == 0;
if($result) {
foreach($users as $user) {
if($user->group->updateCounters(['count' => -1])) {
$user->groupid = $gid;
if($user->save()) {
$user->refresh();
$user->group->updateCounters(['count' => 1]);
}
}
}
}
return $result;
}
|
[
"public",
"function",
"updateGroupUsers",
"(",
"$",
"uids",
",",
"$",
"gid",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"uids",
")",
")",
"{",
"$",
"uids",
"=",
"implode",
"(",
"','",
",",
"$",
"uids",
")",
";",
"}",
"$",
"query",
"=",
"WechatUser",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"\"id in ($uids) and groupid <> $gid\"",
")",
";",
"$",
"users",
"=",
"$",
"query",
"->",
"all",
"(",
")",
";",
"$",
"openids",
"=",
"ArrayHelper",
"::",
"getColumn",
"(",
"$",
"users",
",",
"'openid'",
")",
";",
"if",
"(",
"!",
"$",
"openids",
")",
"{",
"return",
"true",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/groups/members/batchupdate'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'openid_list'",
"=>",
"$",
"openids",
",",
"'to_groupid'",
"=>",
"$",
"gid",
",",
"]",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"if",
"(",
"$",
"result",
")",
"{",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"group",
"->",
"updateCounters",
"(",
"[",
"'count'",
"=>",
"-",
"1",
"]",
")",
")",
"{",
"$",
"user",
"->",
"groupid",
"=",
"$",
"gid",
";",
"if",
"(",
"$",
"user",
"->",
"save",
"(",
")",
")",
"{",
"$",
"user",
"->",
"refresh",
"(",
")",
";",
"$",
"user",
"->",
"group",
"->",
"updateCounters",
"(",
"[",
"'count'",
"=>",
"1",
"]",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
批量移动用户分组
@since 0.0.1
@param {string|array} $uids 用户id
@param {integer} $gid 用户分组gid
@return {boolean}
@example \Yii::$app->wechat->updateGroupUsers($uids, $gid);
|
[
"批量移动用户分组"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L715-L749
|
[
"uids",
"gid"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->updateGroupUsers($uids,",
"$gid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.updateGroupUser
|
public function updateGroupUser($uid, $gid) {
$user = WechatUser::findOne($uid);
if(!$user) {
throw new ErrorException('数据查询失败');
}
if($user->groupid == $gid) {
return true;
}
$data = $this->getData('/cgi-bin/groups/members/update', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid' => $user->openid,
'to_groupid' => $gid,
]));
$result = $this->errcode == 0;
if($result && $user->group->updateCounters(['count' => -1])) {
$user->groupid = $gid;
if($user->save()) {
$user->refresh();
return $user->group->updateCounters(['count' => 1]);
}
}
return $result;
}
|
php
|
public function updateGroupUser($uid, $gid) {
$user = WechatUser::findOne($uid);
if(!$user) {
throw new ErrorException('数据查询失败');
}
if($user->groupid == $gid) {
return true;
}
$data = $this->getData('/cgi-bin/groups/members/update', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid' => $user->openid,
'to_groupid' => $gid,
]));
$result = $this->errcode == 0;
if($result && $user->group->updateCounters(['count' => -1])) {
$user->groupid = $gid;
if($user->save()) {
$user->refresh();
return $user->group->updateCounters(['count' => 1]);
}
}
return $result;
}
|
[
"public",
"function",
"updateGroupUser",
"(",
"$",
"uid",
",",
"$",
"gid",
")",
"{",
"$",
"user",
"=",
"WechatUser",
"::",
"findOne",
"(",
"$",
"uid",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'数据查询失败');",
"",
"",
"}",
"if",
"(",
"$",
"user",
"->",
"groupid",
"==",
"$",
"gid",
")",
"{",
"return",
"true",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/groups/members/update'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'openid'",
"=>",
"$",
"user",
"->",
"openid",
",",
"'to_groupid'",
"=>",
"$",
"gid",
",",
"]",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"if",
"(",
"$",
"result",
"&&",
"$",
"user",
"->",
"group",
"->",
"updateCounters",
"(",
"[",
"'count'",
"=>",
"-",
"1",
"]",
")",
")",
"{",
"$",
"user",
"->",
"groupid",
"=",
"$",
"gid",
";",
"if",
"(",
"$",
"user",
"->",
"save",
"(",
")",
")",
"{",
"$",
"user",
"->",
"refresh",
"(",
")",
";",
"return",
"$",
"user",
"->",
"group",
"->",
"updateCounters",
"(",
"[",
"'count'",
"=>",
"1",
"]",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
移动用户分组
@since 0.0.1
@param {integer} $uid 用户id
@param {integer} $gid 用户分组gid
@return {boolean}
@example \Yii::$app->wechat->updateGroupUser($uid, $gid);
|
[
"移动用户分组"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L760-L787
|
[
"uid",
"gid"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->updateGroupUser($uid,",
"$gid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.deleteGroup
|
public function deleteGroup($gid) {
$group = WechatUserGroup::findOne($gid);
if(!$group) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/groups/delete', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'group' => ['id' => $group->gid],
]));
if(empty($data)) {
return $group->delete();
}
return false;
}
|
php
|
public function deleteGroup($gid) {
$group = WechatUserGroup::findOne($gid);
if(!$group) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/groups/delete', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'group' => ['id' => $group->gid],
]));
if(empty($data)) {
return $group->delete();
}
return false;
}
|
[
"public",
"function",
"deleteGroup",
"(",
"$",
"gid",
")",
"{",
"$",
"group",
"=",
"WechatUserGroup",
"::",
"findOne",
"(",
"$",
"gid",
")",
";",
"if",
"(",
"!",
"$",
"group",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'数据查询失败');",
"",
"",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/groups/delete'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'group'",
"=>",
"[",
"'id'",
"=>",
"$",
"group",
"->",
"gid",
"]",
",",
"]",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"group",
"->",
"delete",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
删除用户分组
@since 0.0.1
@param {integer} $gid 用户分组id
@param {string} [$name] 用户分组名字, 30个字符以内, 默认直接取数据库中的值
@return {boolean}
@example \Yii::$app->wechat->deleteGroup($gid, $name);
|
[
"删除用户分组"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L798-L815
|
[
"gid"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->deleteGroup($gid,",
"$name);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.updateGroup
|
public function updateGroup($gid, $name = null) {
$group = WechatUserGroup::findOne($gid);
if(!$group) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/groups/update', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'group' => ['id' => $group->gid, 'name' => $name ? : $group->name],
]));
$result = $this->errcode == 0;
if($result && $name) {
$group->name = $name;
$group->save();
}
return $result;
}
|
php
|
public function updateGroup($gid, $name = null) {
$group = WechatUserGroup::findOne($gid);
if(!$group) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/groups/update', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'group' => ['id' => $group->gid, 'name' => $name ? : $group->name],
]));
$result = $this->errcode == 0;
if($result && $name) {
$group->name = $name;
$group->save();
}
return $result;
}
|
[
"public",
"function",
"updateGroup",
"(",
"$",
"gid",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"group",
"=",
"WechatUserGroup",
"::",
"findOne",
"(",
"$",
"gid",
")",
";",
"if",
"(",
"!",
"$",
"group",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'数据查询失败');",
"",
"",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/groups/update'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'group'",
"=>",
"[",
"'id'",
"=>",
"$",
"group",
"->",
"gid",
",",
"'name'",
"=>",
"$",
"name",
"?",
":",
"$",
"group",
"->",
"name",
"]",
",",
"]",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"if",
"(",
"$",
"result",
"&&",
"$",
"name",
")",
"{",
"$",
"group",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"group",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
修改用户分组名
@since 0.0.1
@param {integer} $gid 用户分组id
@param {string} [$name] 分组名字, 30个字符以内, 默认直接取数据库中的值
@return {boolean}
@example \Yii::$app->wechat->updateGroup($gid, $name);
|
[
"修改用户分组名"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L826-L845
|
[
"gid",
"name"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->updateGroup($gid,",
"$name);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.createGroup
|
public function createGroup($name) {
$data = $this->getData('/cgi-bin/groups/create', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'group' => ['name' => $name],
]));
if(isset($data['group'])) {
$group = new WechatUserGroup;
$group->appid = $this->app->appid;
$group->gid = $data['group']['id'];
$group->name = $data['group']['name'];
if($group->save()) {
return $group->id;
}
}
return 0;
}
|
php
|
public function createGroup($name) {
$data = $this->getData('/cgi-bin/groups/create', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'group' => ['name' => $name],
]));
if(isset($data['group'])) {
$group = new WechatUserGroup;
$group->appid = $this->app->appid;
$group->gid = $data['group']['id'];
$group->name = $data['group']['name'];
if($group->save()) {
return $group->id;
}
}
return 0;
}
|
[
"public",
"function",
"createGroup",
"(",
"$",
"name",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/groups/create'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'group'",
"=>",
"[",
"'name'",
"=>",
"$",
"name",
"]",
",",
"]",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'group'",
"]",
")",
")",
"{",
"$",
"group",
"=",
"new",
"WechatUserGroup",
";",
"$",
"group",
"->",
"appid",
"=",
"$",
"this",
"->",
"app",
"->",
"appid",
";",
"$",
"group",
"->",
"gid",
"=",
"$",
"data",
"[",
"'group'",
"]",
"[",
"'id'",
"]",
";",
"$",
"group",
"->",
"name",
"=",
"$",
"data",
"[",
"'group'",
"]",
"[",
"'name'",
"]",
";",
"if",
"(",
"$",
"group",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"group",
"->",
"id",
";",
"}",
"}",
"return",
"0",
";",
"}"
] |
创建用户分组
@since 0.0.1
@param {string} $name 用户分组名字, 30个字符以内
@return {object}
@example \Yii::$app->wechat->createGroup($name);
|
[
"创建用户分组"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L855-L873
|
[
"name"
] |
What does this function return?
|
[
"{object}",
"@example",
"\\Yii::$app->wechat->createGroup($name);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getGroups
|
public function getGroups() {
$data = $this->getData('/cgi-bin/groups/get', [
'access_token' => $this->getAccessToken(),
]);
if(isset($data['groups'])) {
foreach($data['groups'] as $_group) {
$group = WechatUserGroup::findOne(['appid' => $this->app->appid, 'gid' => $_group['id']]);
if(!$group) {
$group = new WechatUserGroup;
$group->appid = $this->app->appid;
$group->gid = $_group['id'];
}
$group->name = $_group['name'];
$group->count = $_group['count'];
$group->save();
}
}
return $this->errcode == 0;
}
|
php
|
public function getGroups() {
$data = $this->getData('/cgi-bin/groups/get', [
'access_token' => $this->getAccessToken(),
]);
if(isset($data['groups'])) {
foreach($data['groups'] as $_group) {
$group = WechatUserGroup::findOne(['appid' => $this->app->appid, 'gid' => $_group['id']]);
if(!$group) {
$group = new WechatUserGroup;
$group->appid = $this->app->appid;
$group->gid = $_group['id'];
}
$group->name = $_group['name'];
$group->count = $_group['count'];
$group->save();
}
}
return $this->errcode == 0;
}
|
[
"public",
"function",
"getGroups",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/groups/get'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'groups'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'groups'",
"]",
"as",
"$",
"_group",
")",
"{",
"$",
"group",
"=",
"WechatUserGroup",
"::",
"findOne",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'gid'",
"=>",
"$",
"_group",
"[",
"'id'",
"]",
"]",
")",
";",
"if",
"(",
"!",
"$",
"group",
")",
"{",
"$",
"group",
"=",
"new",
"WechatUserGroup",
";",
"$",
"group",
"->",
"appid",
"=",
"$",
"this",
"->",
"app",
"->",
"appid",
";",
"$",
"group",
"->",
"gid",
"=",
"$",
"_group",
"[",
"'id'",
"]",
";",
"}",
"$",
"group",
"->",
"name",
"=",
"$",
"_group",
"[",
"'name'",
"]",
";",
"$",
"group",
"->",
"count",
"=",
"$",
"_group",
"[",
"'count'",
"]",
";",
"$",
"group",
"->",
"save",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"}"
] |
查询所有用户分组
@since 0.0.1
@return {boolean}
@example \Yii::$app->wechat->getGroups();
|
[
"查询所有用户分组"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L882-L902
|
[] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->getGroups();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getUserGroup
|
public function getUserGroup($openid) {
$data = $this->getData('/cgi-bin/groups/getid', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid' => $openid,
]));
return isset($data['groupid']) ? $data['groupid'] : -1;
}
|
php
|
public function getUserGroup($openid) {
$data = $this->getData('/cgi-bin/groups/getid', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid' => $openid,
]));
return isset($data['groupid']) ? $data['groupid'] : -1;
}
|
[
"public",
"function",
"getUserGroup",
"(",
"$",
"openid",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/groups/getid'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'openid'",
"=>",
"$",
"openid",
",",
"]",
")",
")",
";",
"return",
"isset",
"(",
"$",
"data",
"[",
"'groupid'",
"]",
")",
"?",
"$",
"data",
"[",
"'groupid'",
"]",
":",
"-",
"1",
";",
"}"
] |
查询用户所在分组
@since 0.0.1
@param {string} $openid OpenID
@return {integer}
@example \Yii::$app->wechat->getUserGroup($openid);
|
[
"查询用户所在分组"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L912-L920
|
[
"openid"
] |
What does this function return?
|
[
"{integer}",
"@example",
"\\Yii::$app->wechat->getUserGroup($openid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.updateUserRemark
|
public function updateUserRemark($uid, $remark = null) {
$user = WechatUser::findOne($uid);
if(!$user) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/user/info/updateremark', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid' => $user->openid,
'remark' => $remark ? : $user->remark,
]));
$result = $this->errcode == 0;
if($result && $remark) {
$user->remark = $remark;
$user->save();
}
return $result;
}
|
php
|
public function updateUserRemark($uid, $remark = null) {
$user = WechatUser::findOne($uid);
if(!$user) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/user/info/updateremark', [
'access_token' => $this->getAccessToken(),
], Json::encode([
'openid' => $user->openid,
'remark' => $remark ? : $user->remark,
]));
$result = $this->errcode == 0;
if($result && $remark) {
$user->remark = $remark;
$user->save();
}
return $result;
}
|
[
"public",
"function",
"updateUserRemark",
"(",
"$",
"uid",
",",
"$",
"remark",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"WechatUser",
"::",
"findOne",
"(",
"$",
"uid",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'数据查询失败');",
"",
"",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/user/info/updateremark'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"[",
"'openid'",
"=>",
"$",
"user",
"->",
"openid",
",",
"'remark'",
"=>",
"$",
"remark",
"?",
":",
"$",
"user",
"->",
"remark",
",",
"]",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"if",
"(",
"$",
"result",
"&&",
"$",
"remark",
")",
"{",
"$",
"user",
"->",
"remark",
"=",
"$",
"remark",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
设置用户备注名
@since 0.0.1
@param {integer} $uid 用户id
@param {string} [$remark] 备注名, 长度必须小于30字符, 默认直接取数据库中的值
@return {boolean}
@example \Yii::$app->wechat->updateUserRemark($uid, $remark);
|
[
"设置用户备注名"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L931-L951
|
[
"uid",
"remark"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->updateUserRemark($uid,",
"$remark);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.refreshUser
|
public function refreshUser($uid) {
$user = WechatUser::findOne($uid);
if(!$user) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/user/info', [
'access_token' => $this->getAccessToken(),
'openid' => $user->openid,
'lang' => \Yii::$app->language,
]);
$result = $this->errcode == 0;
if($result) {
$user->subscribe = $data['subscribe'];
if($user->subscribe == 1) {
$user->subscribed_at = $data['subscribe_time'];
$user->name = $data['nickname'];
$user->sex = $data['sex'];
$user->country = $data['country'];
$user->city = $data['city'];
$user->province = $data['province'];
$user->language = $data['language'];
$user->headimgurl = $data['headimgurl'];
$user->remark = $data['remark'];
$user->groupid = $data['groupid'];
}
if(isset($data['unionid'])) {
$user->unionid = $data['unionid'];
}
$user->save();
}
return $result;
}
|
php
|
public function refreshUser($uid) {
$user = WechatUser::findOne($uid);
if(!$user) {
throw new ErrorException('数据查询失败');
}
$data = $this->getData('/cgi-bin/user/info', [
'access_token' => $this->getAccessToken(),
'openid' => $user->openid,
'lang' => \Yii::$app->language,
]);
$result = $this->errcode == 0;
if($result) {
$user->subscribe = $data['subscribe'];
if($user->subscribe == 1) {
$user->subscribed_at = $data['subscribe_time'];
$user->name = $data['nickname'];
$user->sex = $data['sex'];
$user->country = $data['country'];
$user->city = $data['city'];
$user->province = $data['province'];
$user->language = $data['language'];
$user->headimgurl = $data['headimgurl'];
$user->remark = $data['remark'];
$user->groupid = $data['groupid'];
}
if(isset($data['unionid'])) {
$user->unionid = $data['unionid'];
}
$user->save();
}
return $result;
}
|
[
"public",
"function",
"refreshUser",
"(",
"$",
"uid",
")",
"{",
"$",
"user",
"=",
"WechatUser",
"::",
"findOne",
"(",
"$",
"uid",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"'数据查询失败');",
"",
"",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/user/info'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"'openid'",
"=>",
"$",
"user",
"->",
"openid",
",",
"'lang'",
"=>",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"language",
",",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"user",
"->",
"subscribe",
"=",
"$",
"data",
"[",
"'subscribe'",
"]",
";",
"if",
"(",
"$",
"user",
"->",
"subscribe",
"==",
"1",
")",
"{",
"$",
"user",
"->",
"subscribed_at",
"=",
"$",
"data",
"[",
"'subscribe_time'",
"]",
";",
"$",
"user",
"->",
"name",
"=",
"$",
"data",
"[",
"'nickname'",
"]",
";",
"$",
"user",
"->",
"sex",
"=",
"$",
"data",
"[",
"'sex'",
"]",
";",
"$",
"user",
"->",
"country",
"=",
"$",
"data",
"[",
"'country'",
"]",
";",
"$",
"user",
"->",
"city",
"=",
"$",
"data",
"[",
"'city'",
"]",
";",
"$",
"user",
"->",
"province",
"=",
"$",
"data",
"[",
"'province'",
"]",
";",
"$",
"user",
"->",
"language",
"=",
"$",
"data",
"[",
"'language'",
"]",
";",
"$",
"user",
"->",
"headimgurl",
"=",
"$",
"data",
"[",
"'headimgurl'",
"]",
";",
"$",
"user",
"->",
"remark",
"=",
"$",
"data",
"[",
"'remark'",
"]",
";",
"$",
"user",
"->",
"groupid",
"=",
"$",
"data",
"[",
"'groupid'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'unionid'",
"]",
")",
")",
"{",
"$",
"user",
"->",
"unionid",
"=",
"$",
"data",
"[",
"'unionid'",
"]",
";",
"}",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
刷新用户基本信息
@since 0.0.1
@param {integer} $uid 用户id
@return {boolean}
@example \Yii::$app->wechat->refreshUser($uid);
|
[
"刷新用户基本信息"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L961-L995
|
[
"uid"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->refreshUser($uid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.refreshUsers
|
public function refreshUsers($page = 1) {
$query = WechatUser::find()->where(['appid' => $this->app->appid])->select('openid');
$pageSize = 100;
$pagination = new Pagination([
'totalCount' => $query->count(),
'defaultPageSize' => $pageSize,
'pageSizeLimit' => [0, $pageSize],
]);
$pagination->setPage($page - 1, true);
$users = $query->offset($pagination->offset)
->limit($pagination->limit)
->asArray()
->all();
$user_list = [];
foreach($users as $user) {
$user['lang'] = \Yii::$app->language;
$user_list['user_list'][] = $user;
}
if($user_list) {
$data = $this->getData('/cgi-bin/user/info/batchget', [
'access_token' => $this->getAccessToken(),
], Json::encode($user_list));
if(isset($data['user_info_list'])) {
foreach($data['user_info_list'] as $_user) {
$user = WechatUser::findOne(['appid' => $this->app->appid, 'openid' => $_user['openid']]);
if(!$user) {
$user = new WechatUser;
$user->appid = $this->app->appid;
$user->openid = $_user['openid'];
}
$user->subscribe = $_user['subscribe'];
if($user->subscribe == 1) {
$user->subscribed_at = $_user['subscribed_at'];
$user->name = $_user['nickname'];
$user->sex = $_user['sex'];
$user->country = $_user['country'];
$user->city = $_user['city'];
$user->province = $_user['province'];
$user->language = $_user['language'];
$user->headimgurl = $_user['headimgurl'];
$user->remark = $_user['remark'];
$user->groupid = $_user['groupid'];
}
if(isset($_user['unionid'])) {
$user->unionid = $_user['unionid'];
}
$user->save();
}
}
}
return $page < $pagination->pageCount ? $this->refreshUsers($page + 1) : $this->errcode == 0;
}
|
php
|
public function refreshUsers($page = 1) {
$query = WechatUser::find()->where(['appid' => $this->app->appid])->select('openid');
$pageSize = 100;
$pagination = new Pagination([
'totalCount' => $query->count(),
'defaultPageSize' => $pageSize,
'pageSizeLimit' => [0, $pageSize],
]);
$pagination->setPage($page - 1, true);
$users = $query->offset($pagination->offset)
->limit($pagination->limit)
->asArray()
->all();
$user_list = [];
foreach($users as $user) {
$user['lang'] = \Yii::$app->language;
$user_list['user_list'][] = $user;
}
if($user_list) {
$data = $this->getData('/cgi-bin/user/info/batchget', [
'access_token' => $this->getAccessToken(),
], Json::encode($user_list));
if(isset($data['user_info_list'])) {
foreach($data['user_info_list'] as $_user) {
$user = WechatUser::findOne(['appid' => $this->app->appid, 'openid' => $_user['openid']]);
if(!$user) {
$user = new WechatUser;
$user->appid = $this->app->appid;
$user->openid = $_user['openid'];
}
$user->subscribe = $_user['subscribe'];
if($user->subscribe == 1) {
$user->subscribed_at = $_user['subscribed_at'];
$user->name = $_user['nickname'];
$user->sex = $_user['sex'];
$user->country = $_user['country'];
$user->city = $_user['city'];
$user->province = $_user['province'];
$user->language = $_user['language'];
$user->headimgurl = $_user['headimgurl'];
$user->remark = $_user['remark'];
$user->groupid = $_user['groupid'];
}
if(isset($_user['unionid'])) {
$user->unionid = $_user['unionid'];
}
$user->save();
}
}
}
return $page < $pagination->pageCount ? $this->refreshUsers($page + 1) : $this->errcode == 0;
}
|
[
"public",
"function",
"refreshUsers",
"(",
"$",
"page",
"=",
"1",
")",
"{",
"$",
"query",
"=",
"WechatUser",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
"]",
")",
"->",
"select",
"(",
"'openid'",
")",
";",
"$",
"pageSize",
"=",
"100",
";",
"$",
"pagination",
"=",
"new",
"Pagination",
"(",
"[",
"'totalCount'",
"=>",
"$",
"query",
"->",
"count",
"(",
")",
",",
"'defaultPageSize'",
"=>",
"$",
"pageSize",
",",
"'pageSizeLimit'",
"=>",
"[",
"0",
",",
"$",
"pageSize",
"]",
",",
"]",
")",
";",
"$",
"pagination",
"->",
"setPage",
"(",
"$",
"page",
"-",
"1",
",",
"true",
")",
";",
"$",
"users",
"=",
"$",
"query",
"->",
"offset",
"(",
"$",
"pagination",
"->",
"offset",
")",
"->",
"limit",
"(",
"$",
"pagination",
"->",
"limit",
")",
"->",
"asArray",
"(",
")",
"->",
"all",
"(",
")",
";",
"$",
"user_list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"user",
"[",
"'lang'",
"]",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"language",
";",
"$",
"user_list",
"[",
"'user_list'",
"]",
"[",
"]",
"=",
"$",
"user",
";",
"}",
"if",
"(",
"$",
"user_list",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/user/info/batchget'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
",",
"Json",
"::",
"encode",
"(",
"$",
"user_list",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'user_info_list'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'user_info_list'",
"]",
"as",
"$",
"_user",
")",
"{",
"$",
"user",
"=",
"WechatUser",
"::",
"findOne",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'openid'",
"=>",
"$",
"_user",
"[",
"'openid'",
"]",
"]",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"new",
"WechatUser",
";",
"$",
"user",
"->",
"appid",
"=",
"$",
"this",
"->",
"app",
"->",
"appid",
";",
"$",
"user",
"->",
"openid",
"=",
"$",
"_user",
"[",
"'openid'",
"]",
";",
"}",
"$",
"user",
"->",
"subscribe",
"=",
"$",
"_user",
"[",
"'subscribe'",
"]",
";",
"if",
"(",
"$",
"user",
"->",
"subscribe",
"==",
"1",
")",
"{",
"$",
"user",
"->",
"subscribed_at",
"=",
"$",
"_user",
"[",
"'subscribed_at'",
"]",
";",
"$",
"user",
"->",
"name",
"=",
"$",
"_user",
"[",
"'nickname'",
"]",
";",
"$",
"user",
"->",
"sex",
"=",
"$",
"_user",
"[",
"'sex'",
"]",
";",
"$",
"user",
"->",
"country",
"=",
"$",
"_user",
"[",
"'country'",
"]",
";",
"$",
"user",
"->",
"city",
"=",
"$",
"_user",
"[",
"'city'",
"]",
";",
"$",
"user",
"->",
"province",
"=",
"$",
"_user",
"[",
"'province'",
"]",
";",
"$",
"user",
"->",
"language",
"=",
"$",
"_user",
"[",
"'language'",
"]",
";",
"$",
"user",
"->",
"headimgurl",
"=",
"$",
"_user",
"[",
"'headimgurl'",
"]",
";",
"$",
"user",
"->",
"remark",
"=",
"$",
"_user",
"[",
"'remark'",
"]",
";",
"$",
"user",
"->",
"groupid",
"=",
"$",
"_user",
"[",
"'groupid'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_user",
"[",
"'unionid'",
"]",
")",
")",
"{",
"$",
"user",
"->",
"unionid",
"=",
"$",
"_user",
"[",
"'unionid'",
"]",
";",
"}",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"page",
"<",
"$",
"pagination",
"->",
"pageCount",
"?",
"$",
"this",
"->",
"refreshUsers",
"(",
"$",
"page",
"+",
"1",
")",
":",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"}"
] |
刷新所有用户基本信息
@since 0.0.1
@param {integer} [$page=1] 页码
@return {boolean}
@example \Yii::$app->wechat->refreshUsers($page);
|
[
"刷新所有用户基本信息"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1005-L1061
|
[
"page"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->refreshUsers($page);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getUsers
|
public function getUsers($next_openid = null) {
$data = $this->getData('/cgi-bin/user/get', [
'access_token' => $this->getAccessToken(),
'next_openid' => $next_openid,
]);
if(isset($data['count']) && $data['count'] && isset($data['data']) && isset($data['data']['openid'])) {
foreach($data['data']['openid'] as $openid) {
if($user = WechatUser::findOne(['appid' => $this->app->appid, 'openid' => $openid])) {
if($user->subscribe == 0) {
$user->subscribe = 1;
$user->save();
}
} else {
$user = new WechatUser;
$user->appid = $this->app->appid;
$user->openid = $openid;
$user->subscribe = 1;
$user->save();
}
}
}
return isset($data['next_openid']) && $data['next_openid'] ? $this->getUsers($data['next_openid']) : $this->errcode == 0;
}
|
php
|
public function getUsers($next_openid = null) {
$data = $this->getData('/cgi-bin/user/get', [
'access_token' => $this->getAccessToken(),
'next_openid' => $next_openid,
]);
if(isset($data['count']) && $data['count'] && isset($data['data']) && isset($data['data']['openid'])) {
foreach($data['data']['openid'] as $openid) {
if($user = WechatUser::findOne(['appid' => $this->app->appid, 'openid' => $openid])) {
if($user->subscribe == 0) {
$user->subscribe = 1;
$user->save();
}
} else {
$user = new WechatUser;
$user->appid = $this->app->appid;
$user->openid = $openid;
$user->subscribe = 1;
$user->save();
}
}
}
return isset($data['next_openid']) && $data['next_openid'] ? $this->getUsers($data['next_openid']) : $this->errcode == 0;
}
|
[
"public",
"function",
"getUsers",
"(",
"$",
"next_openid",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/user/get'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"'next_openid'",
"=>",
"$",
"next_openid",
",",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'count'",
"]",
")",
"&&",
"$",
"data",
"[",
"'count'",
"]",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'data'",
"]",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'data'",
"]",
"[",
"'openid'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'data'",
"]",
"[",
"'openid'",
"]",
"as",
"$",
"openid",
")",
"{",
"if",
"(",
"$",
"user",
"=",
"WechatUser",
"::",
"findOne",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'openid'",
"=>",
"$",
"openid",
"]",
")",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"subscribe",
"==",
"0",
")",
"{",
"$",
"user",
"->",
"subscribe",
"=",
"1",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"user",
"=",
"new",
"WechatUser",
";",
"$",
"user",
"->",
"appid",
"=",
"$",
"this",
"->",
"app",
"->",
"appid",
";",
"$",
"user",
"->",
"openid",
"=",
"$",
"openid",
";",
"$",
"user",
"->",
"subscribe",
"=",
"1",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}",
"return",
"isset",
"(",
"$",
"data",
"[",
"'next_openid'",
"]",
")",
"&&",
"$",
"data",
"[",
"'next_openid'",
"]",
"?",
"$",
"this",
"->",
"getUsers",
"(",
"$",
"data",
"[",
"'next_openid'",
"]",
")",
":",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"}"
] |
获取用户列表
@since 0.0.1
@param {string} [$next_openid] 第一个拉取的OPENID, 不填默认从头开始拉取
@return {boolean}
@example \Yii::$app->wechat->getUsers($next_openid);
|
[
"获取用户列表"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1071-L1095
|
[
"next_openid"
] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->getUsers($next_openid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getCallbackIp
|
public function getCallbackIp() {
if(empty($this->app->ip_list)) {
$this->refreshIpList();
}
return $this->app->ipListArray;
}
|
php
|
public function getCallbackIp() {
if(empty($this->app->ip_list)) {
$this->refreshIpList();
}
return $this->app->ipListArray;
}
|
[
"public",
"function",
"getCallbackIp",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"app",
"->",
"ip_list",
")",
")",
"{",
"$",
"this",
"->",
"refreshIpList",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"app",
"->",
"ipListArray",
";",
"}"
] |
获取微信服务器IP地址
@since 0.0.1
@return {array}
@example \Yii::$app->wechat->getCallbackIp();
|
[
"获取微信服务器IP地址"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1104-L1110
|
[] |
What does this function return?
|
[
"{array}",
"@example",
"\\Yii::$app->wechat->getCallbackIp();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.refreshIpList
|
public function refreshIpList() {
$data = $this->getData('/cgi-bin/getcallbackip', [
'access_token' => $this->getAccessToken(),
]);
if(isset($data['ip_list'])) {
$this->app->ip_list = Json::encode($data['ip_list']);
return $this->app->save();
}
return $this->errcode == 0;
}
|
php
|
public function refreshIpList() {
$data = $this->getData('/cgi-bin/getcallbackip', [
'access_token' => $this->getAccessToken(),
]);
if(isset($data['ip_list'])) {
$this->app->ip_list = Json::encode($data['ip_list']);
return $this->app->save();
}
return $this->errcode == 0;
}
|
[
"public",
"function",
"refreshIpList",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/getcallbackip'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'ip_list'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"ip_list",
"=",
"Json",
"::",
"encode",
"(",
"$",
"data",
"[",
"'ip_list'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"app",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
";",
"}"
] |
刷新微信服务器IP地址
@since 0.0.1
@return {boolean}
@example \Yii::$app->wechat->refreshIpList();
|
[
"刷新微信服务器IP地址"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1119-L1130
|
[] |
What does this function return?
|
[
"{boolean}",
"@example",
"\\Yii::$app->wechat->refreshIpList();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getJsapiConfig
|
public function getJsapiConfig($url = null) {
$params = [
'jsapi_ticket' => $this->getJsapiTicket(),
'noncestr' => md5(mt_rand()),
'timestamp' => strval(time()),
'url' => $url ? : \Yii::$app->request->absoluteUrl,
];
return [
'appId' => $this->app->appid,
'timestamp' => $params['timestamp'],
'nonceStr' => $params['noncestr'],
'signature' => $this->sign($params),
'signType' => 'sha1',
];
}
|
php
|
public function getJsapiConfig($url = null) {
$params = [
'jsapi_ticket' => $this->getJsapiTicket(),
'noncestr' => md5(mt_rand()),
'timestamp' => strval(time()),
'url' => $url ? : \Yii::$app->request->absoluteUrl,
];
return [
'appId' => $this->app->appid,
'timestamp' => $params['timestamp'],
'nonceStr' => $params['noncestr'],
'signature' => $this->sign($params),
'signType' => 'sha1',
];
}
|
[
"public",
"function",
"getJsapiConfig",
"(",
"$",
"url",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'jsapi_ticket'",
"=>",
"$",
"this",
"->",
"getJsapiTicket",
"(",
")",
",",
"'noncestr'",
"=>",
"md5",
"(",
"mt_rand",
"(",
")",
")",
",",
"'timestamp'",
"=>",
"strval",
"(",
"time",
"(",
")",
")",
",",
"'url'",
"=>",
"$",
"url",
"?",
":",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"absoluteUrl",
",",
"]",
";",
"return",
"[",
"'appId'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'timestamp'",
"=>",
"$",
"params",
"[",
"'timestamp'",
"]",
",",
"'nonceStr'",
"=>",
"$",
"params",
"[",
"'noncestr'",
"]",
",",
"'signature'",
"=>",
"$",
"this",
"->",
"sign",
"(",
"$",
"params",
")",
",",
"'signType'",
"=>",
"'sha1'",
",",
"]",
";",
"}"
] |
获取js接口调用配置
@since 0.0.1
@param {string} [$url] 调用js接口页面url
@return {array}
@example \Yii::$app->wechat->getJsapiConfig($url);
|
[
"获取js接口调用配置"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1140-L1155
|
[
"url"
] |
What does this function return?
|
[
"{array}",
"@example",
"\\Yii::$app->wechat->getJsapiConfig($url);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getJsapiTicket
|
public function getJsapiTicket() {
$time = time();
if(empty($this->app->jsapi_ticket) || $this->app->jsapi_ticket_expired_at < $time) {
$data = $this->getData('/cgi-bin/ticket/getticket', [
'access_token' => $this->getAccessToken(),
'type' => 'jsapi',
]);
if(isset($data['ticket']) && isset($data['expires_in'])) {
$this->app->jsapi_ticket = $data['ticket'];
$this->app->jsapi_ticket_expired_at = $time + $data['expires_in'];
$this->app->save();
}
}
return $this->app->jsapi_ticket;
}
|
php
|
public function getJsapiTicket() {
$time = time();
if(empty($this->app->jsapi_ticket) || $this->app->jsapi_ticket_expired_at < $time) {
$data = $this->getData('/cgi-bin/ticket/getticket', [
'access_token' => $this->getAccessToken(),
'type' => 'jsapi',
]);
if(isset($data['ticket']) && isset($data['expires_in'])) {
$this->app->jsapi_ticket = $data['ticket'];
$this->app->jsapi_ticket_expired_at = $time + $data['expires_in'];
$this->app->save();
}
}
return $this->app->jsapi_ticket;
}
|
[
"public",
"function",
"getJsapiTicket",
"(",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"app",
"->",
"jsapi_ticket",
")",
"||",
"$",
"this",
"->",
"app",
"->",
"jsapi_ticket_expired_at",
"<",
"$",
"time",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/ticket/getticket'",
",",
"[",
"'access_token'",
"=>",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
",",
"'type'",
"=>",
"'jsapi'",
",",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'ticket'",
"]",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'expires_in'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"jsapi_ticket",
"=",
"$",
"data",
"[",
"'ticket'",
"]",
";",
"$",
"this",
"->",
"app",
"->",
"jsapi_ticket_expired_at",
"=",
"$",
"time",
"+",
"$",
"data",
"[",
"'expires_in'",
"]",
";",
"$",
"this",
"->",
"app",
"->",
"save",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"app",
"->",
"jsapi_ticket",
";",
"}"
] |
获取js接口调用票据
@since 0.0.1
@return {string}
@example \Yii::$app->wechat->getJsapiTicket();
|
[
"获取js接口调用票据"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1164-L1179
|
[] |
What does this function return?
|
[
"{string}",
"@example",
"\\Yii::$app->wechat->getJsapiTicket();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getAccessToken
|
public function getAccessToken() {
$time = time();
if(empty($this->app->access_token) || $this->app->access_token_expired_at < $time) {
$data = $this->getData('/cgi-bin/token', [
'grant_type' => 'client_credential',
'appid' => $this->app->appid,
'secret' => $this->app->secret,
]);
if(isset($data['access_token']) && isset($data['expires_in'])) {
$this->app->access_token = $data['access_token'];
$this->app->access_token_expired_at = $time + $data['expires_in'];
$this->app->save();
}
}
return $this->app->access_token;
}
|
php
|
public function getAccessToken() {
$time = time();
if(empty($this->app->access_token) || $this->app->access_token_expired_at < $time) {
$data = $this->getData('/cgi-bin/token', [
'grant_type' => 'client_credential',
'appid' => $this->app->appid,
'secret' => $this->app->secret,
]);
if(isset($data['access_token']) && isset($data['expires_in'])) {
$this->app->access_token = $data['access_token'];
$this->app->access_token_expired_at = $time + $data['expires_in'];
$this->app->save();
}
}
return $this->app->access_token;
}
|
[
"public",
"function",
"getAccessToken",
"(",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"app",
"->",
"access_token",
")",
"||",
"$",
"this",
"->",
"app",
"->",
"access_token_expired_at",
"<",
"$",
"time",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/cgi-bin/token'",
",",
"[",
"'grant_type'",
"=>",
"'client_credential'",
",",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'secret'",
"=>",
"$",
"this",
"->",
"app",
"->",
"secret",
",",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'access_token'",
"]",
")",
"&&",
"isset",
"(",
"$",
"data",
"[",
"'expires_in'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"access_token",
"=",
"$",
"data",
"[",
"'access_token'",
"]",
";",
"$",
"this",
"->",
"app",
"->",
"access_token_expired_at",
"=",
"$",
"time",
"+",
"$",
"data",
"[",
"'expires_in'",
"]",
";",
"$",
"this",
"->",
"app",
"->",
"save",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"app",
"->",
"access_token",
";",
"}"
] |
获取接口调用凭据
@since 0.0.1
@return {string}
@example \Yii::$app->wechat->getAccessToken();
|
[
"获取接口调用凭据"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1188-L1204
|
[] |
What does this function return?
|
[
"{string}",
"@example",
"\\Yii::$app->wechat->getAccessToken();"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.refreshUserAccessToken
|
public function refreshUserAccessToken($refresh_token) {
$data = $this->getData('/sns/oauth2/refresh_token', [
'appid' => $this->app->appid,
'grant_type' => 'refresh_token',
'refresh_token' => $refresh_token,
]);
return $this->errcode == 0 ? $data : [];
}
|
php
|
public function refreshUserAccessToken($refresh_token) {
$data = $this->getData('/sns/oauth2/refresh_token', [
'appid' => $this->app->appid,
'grant_type' => 'refresh_token',
'refresh_token' => $refresh_token,
]);
return $this->errcode == 0 ? $data : [];
}
|
[
"public",
"function",
"refreshUserAccessToken",
"(",
"$",
"refresh_token",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/sns/oauth2/refresh_token'",
",",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'grant_type'",
"=>",
"'refresh_token'",
",",
"'refresh_token'",
"=>",
"$",
"refresh_token",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"errcode",
"==",
"0",
"?",
"$",
"data",
":",
"[",
"]",
";",
"}"
] |
刷新用户网页授权接口调用凭据
@since 0.0.1
@param {string} $refresh_token access_token刷新token
@return {array}
@example \Yii::$app->wechat->refreshUserAccessToken($refresh_token);
|
[
"刷新用户网页授权接口调用凭据"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1214-L1222
|
[
"refresh_token"
] |
What does this function return?
|
[
"{array}",
"@example",
"\\Yii::$app->wechat->refreshUserAccessToken($refresh_token);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.saveUser
|
public function saveUser($userinfo) {
if(!isset($userinfo['openid'])) {
return null;
}
if($user = $this->findUser($userinfo['openid'])) {
return $user;
}
$user = new WechatUser;
$user->appid = $this->app->appid;
$user->openid = $userinfo['openid'];
$user->name = $userinfo['nickname'];
$user->sex = $userinfo['sex'];
$user->language = $userinfo['language'];
$user->city = $userinfo['city'];
$user->province = $userinfo['province'];
$user->country = $userinfo['country'];
$user->headimgurl = $userinfo['headimgurl'];
$user->privilegeList = $userinfo['privilege'];
if(!$user->save()) {
return null;
}
$this->refreshUser($user->id);
return $user;
}
|
php
|
public function saveUser($userinfo) {
if(!isset($userinfo['openid'])) {
return null;
}
if($user = $this->findUser($userinfo['openid'])) {
return $user;
}
$user = new WechatUser;
$user->appid = $this->app->appid;
$user->openid = $userinfo['openid'];
$user->name = $userinfo['nickname'];
$user->sex = $userinfo['sex'];
$user->language = $userinfo['language'];
$user->city = $userinfo['city'];
$user->province = $userinfo['province'];
$user->country = $userinfo['country'];
$user->headimgurl = $userinfo['headimgurl'];
$user->privilegeList = $userinfo['privilege'];
if(!$user->save()) {
return null;
}
$this->refreshUser($user->id);
return $user;
}
|
[
"public",
"function",
"saveUser",
"(",
"$",
"userinfo",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"userinfo",
"[",
"'openid'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"user",
"=",
"$",
"this",
"->",
"findUser",
"(",
"$",
"userinfo",
"[",
"'openid'",
"]",
")",
")",
"{",
"return",
"$",
"user",
";",
"}",
"$",
"user",
"=",
"new",
"WechatUser",
";",
"$",
"user",
"->",
"appid",
"=",
"$",
"this",
"->",
"app",
"->",
"appid",
";",
"$",
"user",
"->",
"openid",
"=",
"$",
"userinfo",
"[",
"'openid'",
"]",
";",
"$",
"user",
"->",
"name",
"=",
"$",
"userinfo",
"[",
"'nickname'",
"]",
";",
"$",
"user",
"->",
"sex",
"=",
"$",
"userinfo",
"[",
"'sex'",
"]",
";",
"$",
"user",
"->",
"language",
"=",
"$",
"userinfo",
"[",
"'language'",
"]",
";",
"$",
"user",
"->",
"city",
"=",
"$",
"userinfo",
"[",
"'city'",
"]",
";",
"$",
"user",
"->",
"province",
"=",
"$",
"userinfo",
"[",
"'province'",
"]",
";",
"$",
"user",
"->",
"country",
"=",
"$",
"userinfo",
"[",
"'country'",
"]",
";",
"$",
"user",
"->",
"headimgurl",
"=",
"$",
"userinfo",
"[",
"'headimgurl'",
"]",
";",
"$",
"user",
"->",
"privilegeList",
"=",
"$",
"userinfo",
"[",
"'privilege'",
"]",
";",
"if",
"(",
"!",
"$",
"user",
"->",
"save",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"refreshUser",
"(",
"$",
"user",
"->",
"id",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
保存用户
@since 0.0.1
@param {string} $openid OpenID
@return {object}
@example \Yii::$app->wechat->findUser($openid);
|
[
"保存用户"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1232-L1260
|
[
"userinfo"
] |
What does this function return?
|
[
"{object}",
"@example",
"\\Yii::$app->wechat->findUser($openid);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getUserInfoByCode
|
public function getUserInfoByCode($code) {
$data = $this->getData('/sns/oauth2/access_token', [
'appid' => $this->app->appid,
'secret' => $this->app->secret,
'grant_type' => 'authorization_code',
'code' => $code,
]);
$user = [];
if($this->errcode == 0) {
$user['openid'] = $data['openid'];
if($data['scope'] == 'snsapi_userinfo') {
$data = $this->getData('/sns/userinfo', [
'access_token' => $data['access_token'],
'openid' => $user['openid'],
'lang' => \Yii::$app->language,
]);
if($this->errcode == 0) {
$user = $data;
}
}
}
return $user;
}
|
php
|
public function getUserInfoByCode($code) {
$data = $this->getData('/sns/oauth2/access_token', [
'appid' => $this->app->appid,
'secret' => $this->app->secret,
'grant_type' => 'authorization_code',
'code' => $code,
]);
$user = [];
if($this->errcode == 0) {
$user['openid'] = $data['openid'];
if($data['scope'] == 'snsapi_userinfo') {
$data = $this->getData('/sns/userinfo', [
'access_token' => $data['access_token'],
'openid' => $user['openid'],
'lang' => \Yii::$app->language,
]);
if($this->errcode == 0) {
$user = $data;
}
}
}
return $user;
}
|
[
"public",
"function",
"getUserInfoByCode",
"(",
"$",
"code",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/sns/oauth2/access_token'",
",",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'secret'",
"=>",
"$",
"this",
"->",
"app",
"->",
"secret",
",",
"'grant_type'",
"=>",
"'authorization_code'",
",",
"'code'",
"=>",
"$",
"code",
",",
"]",
")",
";",
"$",
"user",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"errcode",
"==",
"0",
")",
"{",
"$",
"user",
"[",
"'openid'",
"]",
"=",
"$",
"data",
"[",
"'openid'",
"]",
";",
"if",
"(",
"$",
"data",
"[",
"'scope'",
"]",
"==",
"'snsapi_userinfo'",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"'/sns/userinfo'",
",",
"[",
"'access_token'",
"=>",
"$",
"data",
"[",
"'access_token'",
"]",
",",
"'openid'",
"=>",
"$",
"user",
"[",
"'openid'",
"]",
",",
"'lang'",
"=>",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"language",
",",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"errcode",
"==",
"0",
")",
"{",
"$",
"user",
"=",
"$",
"data",
";",
"}",
"}",
"}",
"return",
"$",
"user",
";",
"}"
] |
获取用户网页授权信息
@since 0.0.1
@param {string} $code 通过用户在网页授权后获取的code参数
@return {array}
@example \Yii::$app->wechat->getUserInfo($code);
|
[
"获取用户网页授权信息"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1285-L1309
|
[
"code"
] |
What does this function return?
|
[
"{array}",
"@example",
"\\Yii::$app->wechat->getUserInfo($code);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getUserAuthorizeCodeUrl
|
public function getUserAuthorizeCodeUrl($state = null, $scope = 'snsapi_base', $url = null) {
return 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query([
'appid' => $this->app->appid,
'redirect_uri' => $url ? : \Yii::$app->request->absoluteUrl,
'response_type' => 'code',
'scope' => $scope,
'state' => $state,
]) . '#wechat_redirect';
}
|
php
|
public function getUserAuthorizeCodeUrl($state = null, $scope = 'snsapi_base', $url = null) {
return 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query([
'appid' => $this->app->appid,
'redirect_uri' => $url ? : \Yii::$app->request->absoluteUrl,
'response_type' => 'code',
'scope' => $scope,
'state' => $state,
]) . '#wechat_redirect';
}
|
[
"public",
"function",
"getUserAuthorizeCodeUrl",
"(",
"$",
"state",
"=",
"null",
",",
"$",
"scope",
"=",
"'snsapi_base'",
",",
"$",
"url",
"=",
"null",
")",
"{",
"return",
"'https://open.weixin.qq.com/connect/oauth2/authorize?'",
".",
"http_build_query",
"(",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"->",
"appid",
",",
"'redirect_uri'",
"=>",
"$",
"url",
"?",
":",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"absoluteUrl",
",",
"'response_type'",
"=>",
"'code'",
",",
"'scope'",
"=>",
"$",
"scope",
",",
"'state'",
"=>",
"$",
"state",
",",
"]",
")",
".",
"'#wechat_redirect'",
";",
"}"
] |
获取用户网页授权code跳转url
@since 0.0.1
@param {string} [$state] 重定向后会带上state参数, 开发者可以填写a-zA-Z0-9的参数值, 最多128字节
@param {string} [$scope=snsapi_base] 应用授权作用域: snsapi_base(默认), snsapi_userinfo
@param {string} [$url] 调用js接口页面url
@return {string}
@example \Yii::$app->wechat->getUserAuthorizeCodeUrl($state, $scope, $url);
|
[
"获取用户网页授权code跳转url"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1321-L1329
|
[
"state",
"scope",
"url"
] |
What does this function return?
|
[
"{string}",
"@example",
"\\Yii::$app->wechat->getUserAuthorizeCodeUrl($state,",
"$scope,",
"$url);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.generateRandomString
|
public function generateRandomString($len = 32) {
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$max = strlen($chars) - 1;
$strArr = [];
for($i = 0; $i < $len; $i++) {
$strArr[] = $chars[mt_rand(0, $max)];
}
return implode($strArr);
}
|
php
|
public function generateRandomString($len = 32) {
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$max = strlen($chars) - 1;
$strArr = [];
for($i = 0; $i < $len; $i++) {
$strArr[] = $chars[mt_rand(0, $max)];
}
return implode($strArr);
}
|
[
"public",
"function",
"generateRandomString",
"(",
"$",
"len",
"=",
"32",
")",
"{",
"$",
"chars",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
";",
"$",
"max",
"=",
"strlen",
"(",
"$",
"chars",
")",
"-",
"1",
";",
"$",
"strArr",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
"$",
"i",
"++",
")",
"{",
"$",
"strArr",
"[",
"]",
"=",
"$",
"chars",
"[",
"mt_rand",
"(",
"0",
",",
"$",
"max",
")",
"]",
";",
"}",
"return",
"implode",
"(",
"$",
"strArr",
")",
";",
"}"
] |
生成随机字符串
@since 0.0.1
@param {integer} [$len=32] 长度
@return {string}
@example \Yii::$app->wechat->generateRandomString($len);
|
[
"生成随机字符串"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1350-L1360
|
[
"len"
] |
What does this function return?
|
[
"{string}",
"@example",
"\\Yii::$app->wechat->generateRandomString($len);"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.saveFile
|
private function saveFile($data) {
$fileupload = \Yii::createObject(\Yii::$app->components[$this->fileupload]);
$fileinfo = $fileupload->createFile($data['extension']);
$file = fopen($fileinfo['tmp'], 'wb');
fwrite($file, $data['content']);
fclose($file);
return $fileupload->finalFile($fileinfo);
}
|
php
|
private function saveFile($data) {
$fileupload = \Yii::createObject(\Yii::$app->components[$this->fileupload]);
$fileinfo = $fileupload->createFile($data['extension']);
$file = fopen($fileinfo['tmp'], 'wb');
fwrite($file, $data['content']);
fclose($file);
return $fileupload->finalFile($fileinfo);
}
|
[
"private",
"function",
"saveFile",
"(",
"$",
"data",
")",
"{",
"$",
"fileupload",
"=",
"\\",
"Yii",
"::",
"createObject",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"components",
"[",
"$",
"this",
"->",
"fileupload",
"]",
")",
";",
"$",
"fileinfo",
"=",
"$",
"fileupload",
"->",
"createFile",
"(",
"$",
"data",
"[",
"'extension'",
"]",
")",
";",
"$",
"file",
"=",
"fopen",
"(",
"$",
"fileinfo",
"[",
"'tmp'",
"]",
",",
"'wb'",
")",
";",
"fwrite",
"(",
"$",
"file",
",",
"$",
"data",
"[",
"'content'",
"]",
")",
";",
"fclose",
"(",
"$",
"file",
")",
";",
"return",
"$",
"fileupload",
"->",
"finalFile",
"(",
"$",
"fileinfo",
")",
";",
"}"
] |
保存文件
@since 0.0.1
@param {array} $data 数据
@return {string}
|
[
"保存文件"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1382-L1390
|
[
"data"
] |
What does this function return?
|
[
"{string}"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getData
|
private function getData($action, $query, $data = null) {
$_result = $this->curl($this->getApiUrl($action, $query), $data);
if(!$_result) {
$this->errcode = '503';
$this->errmsg = '接口服务不可用';
}
$result = json_decode($_result, true);
if(json_last_error()) {
if($extension = $this->getExtension($this->getMimeType($_result, true))) {
$result = ['content' => $_result, 'extension' => $extension];
} else {
$this->errcode = '503';
$this->errmsg = '数据不合法';
}
} else if(isset($result['errcode']) && isset($result['errmsg'])) {
$this->errcode = $result['errcode'];
$this->errmsg = $this->getMessage($result['errmsg']);
}
return $result;
}
|
php
|
private function getData($action, $query, $data = null) {
$_result = $this->curl($this->getApiUrl($action, $query), $data);
if(!$_result) {
$this->errcode = '503';
$this->errmsg = '接口服务不可用';
}
$result = json_decode($_result, true);
if(json_last_error()) {
if($extension = $this->getExtension($this->getMimeType($_result, true))) {
$result = ['content' => $_result, 'extension' => $extension];
} else {
$this->errcode = '503';
$this->errmsg = '数据不合法';
}
} else if(isset($result['errcode']) && isset($result['errmsg'])) {
$this->errcode = $result['errcode'];
$this->errmsg = $this->getMessage($result['errmsg']);
}
return $result;
}
|
[
"private",
"function",
"getData",
"(",
"$",
"action",
",",
"$",
"query",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"_result",
"=",
"$",
"this",
"->",
"curl",
"(",
"$",
"this",
"->",
"getApiUrl",
"(",
"$",
"action",
",",
"$",
"query",
")",
",",
"$",
"data",
")",
";",
"if",
"(",
"!",
"$",
"_result",
")",
"{",
"$",
"this",
"->",
"errcode",
"=",
"'503'",
";",
"$",
"this",
"->",
"errmsg",
"=",
"'接口服务不可用';",
"",
"}",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"_result",
",",
"true",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
")",
"{",
"if",
"(",
"$",
"extension",
"=",
"$",
"this",
"->",
"getExtension",
"(",
"$",
"this",
"->",
"getMimeType",
"(",
"$",
"_result",
",",
"true",
")",
")",
")",
"{",
"$",
"result",
"=",
"[",
"'content'",
"=>",
"$",
"_result",
",",
"'extension'",
"=>",
"$",
"extension",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"errcode",
"=",
"'503'",
";",
"$",
"this",
"->",
"errmsg",
"=",
"'数据不合法';",
"",
"}",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'errcode'",
"]",
")",
"&&",
"isset",
"(",
"$",
"result",
"[",
"'errmsg'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"errcode",
"=",
"$",
"result",
"[",
"'errcode'",
"]",
";",
"$",
"this",
"->",
"errmsg",
"=",
"$",
"this",
"->",
"getMessage",
"(",
"$",
"result",
"[",
"'errmsg'",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
获取数据
@since 0.0.1
@param {string} $action 接口名称
@param {array} $query 参数
@param {string|array} [$data] 数据
@return {array}
|
[
"获取数据"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1401-L1423
|
[
"action",
"query",
"data"
] |
What does this function return?
|
[
"{array}"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getExtension
|
private function getExtension($mimetype) {
if(preg_match('/^(image|audio|video)\/(.+)$/', $mimetype, $matches)) {
$extension = $matches[2];
if(in_array($extension, ['jpeg', 'pjpeg'])) {
$extension = 'jpg';
} else if(in_array($extension, ['mpeg4'])) {
$extension = 'mp4';
}
return $extension;
}
return null;
}
|
php
|
private function getExtension($mimetype) {
if(preg_match('/^(image|audio|video)\/(.+)$/', $mimetype, $matches)) {
$extension = $matches[2];
if(in_array($extension, ['jpeg', 'pjpeg'])) {
$extension = 'jpg';
} else if(in_array($extension, ['mpeg4'])) {
$extension = 'mp4';
}
return $extension;
}
return null;
}
|
[
"private",
"function",
"getExtension",
"(",
"$",
"mimetype",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^(image|audio|video)\\/(.+)$/'",
",",
"$",
"mimetype",
",",
"$",
"matches",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"extension",
",",
"[",
"'jpeg'",
",",
"'pjpeg'",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"'jpg'",
";",
"}",
"else",
"if",
"(",
"in_array",
"(",
"$",
"extension",
",",
"[",
"'mpeg4'",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"'mp4'",
";",
"}",
"return",
"$",
"extension",
";",
"}",
"return",
"null",
";",
"}"
] |
获取文件扩展名
@since 0.0.1
@param {string} $mimetype 文件MIME type
@return {string}
|
[
"获取文件扩展名"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1432-L1445
|
[
"mimetype"
] |
What does this function return?
|
[
"{string}"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getMimeType
|
private function getMimeType($data, $stream = false) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = $stream ? finfo_buffer($finfo, $data) : finfo_file($finfo, $data);
finfo_close($finfo);
return $mimetype;
}
|
php
|
private function getMimeType($data, $stream = false) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = $stream ? finfo_buffer($finfo, $data) : finfo_file($finfo, $data);
finfo_close($finfo);
return $mimetype;
}
|
[
"private",
"function",
"getMimeType",
"(",
"$",
"data",
",",
"$",
"stream",
"=",
"false",
")",
"{",
"$",
"finfo",
"=",
"finfo_open",
"(",
"FILEINFO_MIME_TYPE",
")",
";",
"$",
"mimetype",
"=",
"$",
"stream",
"?",
"finfo_buffer",
"(",
"$",
"finfo",
",",
"$",
"data",
")",
":",
"finfo_file",
"(",
"$",
"finfo",
",",
"$",
"data",
")",
";",
"finfo_close",
"(",
"$",
"finfo",
")",
";",
"return",
"$",
"mimetype",
";",
"}"
] |
获取文件MIME type
@since 0.0.1
@param {string} $data 数据
@param {boolean} $stream 数据流形式
@return {string}
|
[
"获取文件MIME",
"type"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1455-L1461
|
[
"data",
"stream"
] |
What does this function return?
|
[
"{string}"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getApiUrl
|
private function getApiUrl($action, $query = []) {
return $this->api . $action . (empty($query) ? '' : '?' . http_build_query($query));
}
|
php
|
private function getApiUrl($action, $query = []) {
return $this->api . $action . (empty($query) ? '' : '?' . http_build_query($query));
}
|
[
"private",
"function",
"getApiUrl",
"(",
"$",
"action",
",",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"api",
".",
"$",
"action",
".",
"(",
"empty",
"(",
"$",
"query",
")",
"?",
"''",
":",
"'?'",
".",
"http_build_query",
"(",
"$",
"query",
")",
")",
";",
"}"
] |
获取接口完整访问地址
@since 0.0.1
@param {string} $action 接口名称
@param {array} [$query=[]] 参数
@return {string}
|
[
"获取接口完整访问地址"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1471-L1473
|
[
"action",
"query"
] |
What does this function return?
|
[
"{string}"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.getMessage
|
private function getMessage($status) {
if($this->messages === false) {
$this->messages = require(__DIR__ . '/messages.php');
}
return isset($this->messages[$status]) ? $this->messages[$status] : "Error: $status";
}
|
php
|
private function getMessage($status) {
if($this->messages === false) {
$this->messages = require(__DIR__ . '/messages.php');
}
return isset($this->messages[$status]) ? $this->messages[$status] : "Error: $status";
}
|
[
"private",
"function",
"getMessage",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"messages",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"messages",
"=",
"require",
"(",
"__DIR__",
".",
"'/messages.php'",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"messages",
"[",
"$",
"status",
"]",
")",
"?",
"$",
"this",
"->",
"messages",
"[",
"$",
"status",
"]",
":",
"\"Error: $status\"",
";",
"}"
] |
获取信息
@since 0.0.1
@param {string} $status 状态码
@return {string}
|
[
"获取信息"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1493-L1499
|
[
"status"
] |
What does this function return?
|
[
"{string}"
] |
xiewulong/yii2-wechat
|
Manager.php
|
Manager.curl
|
private function curl($url, $data = null, $useragent = null) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if(!empty($data)) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
if(!empty($useragent)) {
curl_setopt($curl, CURLOPT_USERAGENT, $useragent);
}
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
|
php
|
private function curl($url, $data = null, $useragent = null) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if(!empty($data)) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
if(!empty($useragent)) {
curl_setopt($curl, CURLOPT_USERAGENT, $useragent);
}
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
|
[
"private",
"function",
"curl",
"(",
"$",
"url",
",",
"$",
"data",
"=",
"null",
",",
"$",
"useragent",
"=",
"null",
")",
"{",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HEADER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"data",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"useragent",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_USERAGENT",
",",
"$",
"useragent",
")",
";",
"}",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"curl",
")",
";",
"curl_close",
"(",
"$",
"curl",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
curl远程获取数据方法
@since 0.0.1
@param {string} $url 请求地址
@param {string|array} [$data] post数据
@param {string} [$useragent] 模拟浏览器用户代理信息
@return {array}
|
[
"curl远程获取数据方法"
] |
train
|
https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/Manager.php#L1510-L1526
|
[
"url",
"data",
"useragent"
] |
What does this function return?
|
[
"{array}"
] |
PandaPlatform/jar
|
Model/Content/XmlContent.php
|
XmlContent.setDOMElementPayload
|
public function setDOMElementPayload(DOMElement $element)
{
$this->setPayload($element->ownerDocument->saveXML($element));
return $this;
}
|
php
|
public function setDOMElementPayload(DOMElement $element)
{
$this->setPayload($element->ownerDocument->saveXML($element));
return $this;
}
|
[
"public",
"function",
"setDOMElementPayload",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"setPayload",
"(",
"$",
"element",
"->",
"ownerDocument",
"->",
"saveXML",
"(",
"$",
"element",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
@param DOMElement $element
@return $this
|
[
"@param",
"DOMElement",
"$element"
] |
train
|
https://github.com/PandaPlatform/jar/blob/56b6d8687a565482f8315f3dde4cf08d6fc0e2b3/Model/Content/XmlContent.php#L42-L47
|
[
"DOMElement"
] |
What does this function return?
|
[
"$this"
] |
znframework/package-helpers
|
Cleaner.php
|
Cleaner.data
|
public static function data($searchData, $cleanWord)
{
if( length($cleanWord) > length($searchData) )
{
throw new LogicException('[Cleaner::data()] -> 3.($cleanWord) parameter not be longer than 2.($searchData) parameter!');
}
if( ! is_array($searchData) )
{
$result = str_replace($cleanWord, '', $searchData);
}
else
{
if( ! is_array($cleanWord) )
{
$cleanWordArray[] = $cleanWord;
}
else
{
$cleanWordArray = $cleanWord;
}
$result = array_diff($searchData, $cleanWordArray);
}
return $result;
}
|
php
|
public static function data($searchData, $cleanWord)
{
if( length($cleanWord) > length($searchData) )
{
throw new LogicException('[Cleaner::data()] -> 3.($cleanWord) parameter not be longer than 2.($searchData) parameter!');
}
if( ! is_array($searchData) )
{
$result = str_replace($cleanWord, '', $searchData);
}
else
{
if( ! is_array($cleanWord) )
{
$cleanWordArray[] = $cleanWord;
}
else
{
$cleanWordArray = $cleanWord;
}
$result = array_diff($searchData, $cleanWordArray);
}
return $result;
}
|
[
"public",
"static",
"function",
"data",
"(",
"$",
"searchData",
",",
"$",
"cleanWord",
")",
"{",
"if",
"(",
"length",
"(",
"$",
"cleanWord",
")",
">",
"length",
"(",
"$",
"searchData",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'[Cleaner::data()] -> 3.($cleanWord) parameter not be longer than 2.($searchData) parameter!'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"searchData",
")",
")",
"{",
"$",
"result",
"=",
"str_replace",
"(",
"$",
"cleanWord",
",",
"''",
",",
"$",
"searchData",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"cleanWord",
")",
")",
"{",
"$",
"cleanWordArray",
"[",
"]",
"=",
"$",
"cleanWord",
";",
"}",
"else",
"{",
"$",
"cleanWordArray",
"=",
"$",
"cleanWord",
";",
"}",
"$",
"result",
"=",
"array_diff",
"(",
"$",
"searchData",
",",
"$",
"cleanWordArray",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Clean Data
@param mixed $searchData
@param mixed $cleanWord
@return mixed
|
[
"Clean",
"Data"
] |
train
|
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Cleaner.php#L24-L50
|
[
"searchData",
"cleanWord"
] |
What does this function return?
|
[
"mixed"
] |
oscarpalmer/shelf
|
src/oscarpalmer/Shelf/Blob.php
|
Blob.delete
|
public function delete($key) : Blob
{
if ($this->offsetExists($key)) {
$this->offsetUnset($key);
}
return $this;
}
|
php
|
public function delete($key) : Blob
{
if ($this->offsetExists($key)) {
$this->offsetUnset($key);
}
return $this;
}
|
[
"public",
"function",
"delete",
"(",
"$",
"key",
")",
":",
"Blob",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"offsetUnset",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Delete value for key in Blob.
@param mixed $key Key to delete.
@return Blob Blob object for optional chaining.
|
[
"Delete",
"value",
"for",
"key",
"in",
"Blob",
"."
] |
train
|
https://github.com/oscarpalmer/shelf/blob/47bccf7fd8f1750defe1f2805480a6721f1a0e79/src/oscarpalmer/Shelf/Blob.php#L28-L35
|
[
"key"
] |
What does this function return?
|
[
"Blob",
"",
"Blob",
"object",
"for",
"optional",
"chaining."
] |
iwyg/xmlconf
|
src/Thapp/XmlConf/XmlConfServiceProvider.php
|
XmlConfServiceProvider.getSchemaPath
|
public function getSchemaPath($reader, $base)
{
return sprintf('%s/%s/%s/Schema/%s.xsd', dirname(app_path()), $base, ucfirst(camel_case($reader)), $reader);
}
|
php
|
public function getSchemaPath($reader, $base)
{
return sprintf('%s/%s/%s/Schema/%s.xsd', dirname(app_path()), $base, ucfirst(camel_case($reader)), $reader);
}
|
[
"public",
"function",
"getSchemaPath",
"(",
"$",
"reader",
",",
"$",
"base",
")",
"{",
"return",
"sprintf",
"(",
"'%s/%s/%s/Schema/%s.xsd'",
",",
"dirname",
"(",
"app_path",
"(",
")",
")",
",",
"$",
"base",
",",
"ucfirst",
"(",
"camel_case",
"(",
"$",
"reader",
")",
")",
",",
"$",
"reader",
")",
";",
"}"
] |
getSchamePath
@param string $reader
@access public
@return string
|
[
"getSchamePath"
] |
train
|
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/XmlConfServiceProvider.php#L75-L78
|
[
"reader",
"base"
] |
What does this function return?
|
[
"string"
] |
iwyg/xmlconf
|
src/Thapp/XmlConf/XmlConfServiceProvider.php
|
XmlConfServiceProvider.checkBaseDir
|
private function checkBaseDir($reader, array $base)
{
if (!isset($base[$reader]) || !is_dir(dirname(app_path()) . '/' . $base[$reader])) {
throw new \RuntimeException('Either a basedir is not set or basedir is not a directory');
}
}
|
php
|
private function checkBaseDir($reader, array $base)
{
if (!isset($base[$reader]) || !is_dir(dirname(app_path()) . '/' . $base[$reader])) {
throw new \RuntimeException('Either a basedir is not set or basedir is not a directory');
}
}
|
[
"private",
"function",
"checkBaseDir",
"(",
"$",
"reader",
",",
"array",
"$",
"base",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"base",
"[",
"$",
"reader",
"]",
")",
"||",
"!",
"is_dir",
"(",
"dirname",
"(",
"app_path",
"(",
")",
")",
".",
"'/'",
".",
"$",
"base",
"[",
"$",
"reader",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Either a basedir is not set or basedir is not a directory'",
")",
";",
"}",
"}"
] |
checkBaseDir
@param string $reader
@param array $base
@throws \RuntimeException
@access private
@return void
|
[
"checkBaseDir"
] |
train
|
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/XmlConfServiceProvider.php#L102-L107
|
[
"reader",
"array"
] |
What does this function return?
|
[
"void"
] |
iwyg/xmlconf
|
src/Thapp/XmlConf/XmlConfServiceProvider.php
|
XmlConfServiceProvider.regsiterCommands
|
protected function regsiterCommands()
{
$this->app['command.xmlconf.warmup'] = $this->app->share(
function ($app)
{
return new Console\XmlConfWarmupCommand($app, $app['config']->get('xmlconf::namespaces'));
}
);
$this->commands(
'command.xmlconf.warmup'
);
}
|
php
|
protected function regsiterCommands()
{
$this->app['command.xmlconf.warmup'] = $this->app->share(
function ($app)
{
return new Console\XmlConfWarmupCommand($app, $app['config']->get('xmlconf::namespaces'));
}
);
$this->commands(
'command.xmlconf.warmup'
);
}
|
[
"protected",
"function",
"regsiterCommands",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'command.xmlconf.warmup'",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Console",
"\\",
"XmlConfWarmupCommand",
"(",
"$",
"app",
",",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'xmlconf::namespaces'",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"commands",
"(",
"'command.xmlconf.warmup'",
")",
";",
"}"
] |
regsiterCommands
@access protected
@return void
|
[
"regsiterCommands"
] |
train
|
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/XmlConfServiceProvider.php#L115-L130
|
[] |
What does this function return?
|
[
"void"
] |
iwyg/xmlconf
|
src/Thapp/XmlConf/XmlConfServiceProvider.php
|
XmlConfServiceProvider.regsiterConfigDrivers
|
protected function regsiterConfigDrivers()
{
// register xml config dirvers
$me = $this;
$base = $this->app['config']->get('xmlconf::basedir', array());
$cacheDriver = $this->app['config']->get('cache.driver', 'file');
foreach ($this->app['config']->get('xmlconf::namespaces', array()) as $reader => $namespace) {
$this->checkBaseDir($reader, $base);
$this->app['xmlconf.' . $reader] = $this->app->share(function ($app) use ($me, $base, $reader, $namespace, $cacheDriver)
{
$class = $me->getReaderClass($reader, $namespace);
$cache = new Cache\Cache($app['cache']->driver($cacheDriver), $reader);
$xmlreader = new $class(
$cache,
$me->getSimpleXmlClass($reader, $namespace),
$me->getConfPath($reader),
$me->getSchemaPath($reader, $base[$reader])
);
return $xmlreader;
});
}
}
|
php
|
protected function regsiterConfigDrivers()
{
// register xml config dirvers
$me = $this;
$base = $this->app['config']->get('xmlconf::basedir', array());
$cacheDriver = $this->app['config']->get('cache.driver', 'file');
foreach ($this->app['config']->get('xmlconf::namespaces', array()) as $reader => $namespace) {
$this->checkBaseDir($reader, $base);
$this->app['xmlconf.' . $reader] = $this->app->share(function ($app) use ($me, $base, $reader, $namespace, $cacheDriver)
{
$class = $me->getReaderClass($reader, $namespace);
$cache = new Cache\Cache($app['cache']->driver($cacheDriver), $reader);
$xmlreader = new $class(
$cache,
$me->getSimpleXmlClass($reader, $namespace),
$me->getConfPath($reader),
$me->getSchemaPath($reader, $base[$reader])
);
return $xmlreader;
});
}
}
|
[
"protected",
"function",
"regsiterConfigDrivers",
"(",
")",
"{",
"// register xml config dirvers",
"$",
"me",
"=",
"$",
"this",
";",
"$",
"base",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'xmlconf::basedir'",
",",
"array",
"(",
")",
")",
";",
"$",
"cacheDriver",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'cache.driver'",
",",
"'file'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'xmlconf::namespaces'",
",",
"array",
"(",
")",
")",
"as",
"$",
"reader",
"=>",
"$",
"namespace",
")",
"{",
"$",
"this",
"->",
"checkBaseDir",
"(",
"$",
"reader",
",",
"$",
"base",
")",
";",
"$",
"this",
"->",
"app",
"[",
"'xmlconf.'",
".",
"$",
"reader",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"use",
"(",
"$",
"me",
",",
"$",
"base",
",",
"$",
"reader",
",",
"$",
"namespace",
",",
"$",
"cacheDriver",
")",
"{",
"$",
"class",
"=",
"$",
"me",
"->",
"getReaderClass",
"(",
"$",
"reader",
",",
"$",
"namespace",
")",
";",
"$",
"cache",
"=",
"new",
"Cache",
"\\",
"Cache",
"(",
"$",
"app",
"[",
"'cache'",
"]",
"->",
"driver",
"(",
"$",
"cacheDriver",
")",
",",
"$",
"reader",
")",
";",
"$",
"xmlreader",
"=",
"new",
"$",
"class",
"(",
"$",
"cache",
",",
"$",
"me",
"->",
"getSimpleXmlClass",
"(",
"$",
"reader",
",",
"$",
"namespace",
")",
",",
"$",
"me",
"->",
"getConfPath",
"(",
"$",
"reader",
")",
",",
"$",
"me",
"->",
"getSchemaPath",
"(",
"$",
"reader",
",",
"$",
"base",
"[",
"$",
"reader",
"]",
")",
")",
";",
"return",
"$",
"xmlreader",
";",
"}",
")",
";",
"}",
"}"
] |
regsiterConfigDrivers
@access protected
@return void
|
[
"regsiterConfigDrivers"
] |
train
|
https://github.com/iwyg/xmlconf/blob/1d8a657073f3fd46dacfb6bf5d173f9d5283661b/src/Thapp/XmlConf/XmlConfServiceProvider.php#L138-L165
|
[] |
What does this function return?
|
[
"void"
] |
iron-bound-designs/wp-notifications
|
src/Template/Manager.php
|
Manager.listen
|
public function listen( Listener $listener ) {
if ( isset( $this->listeners[ $listener->get_tag() ] ) ) {
return false;
}
$this->listeners[ $listener->get_tag() ] = $listener;
return true;
}
|
php
|
public function listen( Listener $listener ) {
if ( isset( $this->listeners[ $listener->get_tag() ] ) ) {
return false;
}
$this->listeners[ $listener->get_tag() ] = $listener;
return true;
}
|
[
"public",
"function",
"listen",
"(",
"Listener",
"$",
"listener",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"listener",
"->",
"get_tag",
"(",
")",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"listeners",
"[",
"$",
"listener",
"->",
"get_tag",
"(",
")",
"]",
"=",
"$",
"listener",
";",
"return",
"true",
";",
"}"
] |
Listen for a template tag.
@since 1.0
@param Listener $listener
@return bool
|
[
"Listen",
"for",
"a",
"template",
"tag",
"."
] |
train
|
https://github.com/iron-bound-designs/wp-notifications/blob/4fdf67d28d194576d35f86245b2f539c4815cde2/src/Template/Manager.php#L50-L59
|
[
"Listener"
] |
What does this function return?
|
[
"bool"
] |
iron-bound-designs/wp-notifications
|
src/Template/Manager.php
|
Manager.get_listener
|
public function get_listener( $tag ) {
return isset( $this->listeners[ $tag ] ) ? $this->listeners[ $tag ] : new Null_Listener();
}
|
php
|
public function get_listener( $tag ) {
return isset( $this->listeners[ $tag ] ) ? $this->listeners[ $tag ] : new Null_Listener();
}
|
[
"public",
"function",
"get_listener",
"(",
"$",
"tag",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"tag",
"]",
")",
"?",
"$",
"this",
"->",
"listeners",
"[",
"$",
"tag",
"]",
":",
"new",
"Null_Listener",
"(",
")",
";",
"}"
] |
Get a listener for a certain tag.
@param string $tag
@return Listener|Null_Listener Null Listener is returned if listener for given tag does not exist.
|
[
"Get",
"a",
"listener",
"for",
"a",
"certain",
"tag",
"."
] |
train
|
https://github.com/iron-bound-designs/wp-notifications/blob/4fdf67d28d194576d35f86245b2f539c4815cde2/src/Template/Manager.php#L68-L70
|
[
"tag"
] |
What does this function return?
|
[
"Listener|Null_Listener",
"Null",
"Listener",
"is",
"returned",
"if",
"listener",
"for",
"given",
"tag",
"does",
"not",
"exist."
] |
iron-bound-designs/wp-notifications
|
src/Template/Manager.php
|
Manager.render_tags
|
public function render_tags( array $data_sources ) {
$replaced = array();
foreach ( $this->get_listeners() as $tag => $listener ) {
$params = $listener->get_callback_reflection()->getParameters();
$args = array();
foreach ( $params as $param ) {
$found = false;
foreach ( $data_sources as $name => $data_source ) {
if ( is_object( $data_source ) && ( $class = $param->getClass() ) !== null && $class->isInstance( $data_source ) ) {
$args[] = $data_source;
$found = true;
} elseif ( $param->getName() === $name ) {
if ( isset( $class ) ) {
throw new \BadMethodCallException(
"Data source '$name' does not match type of required parameter '{$param->getName()}'. Required type: '{$class->getName()}''",
1
);
}
$args[] = $data_source;
$found = true;
}
if ( $found ) {
break;
}
}
if ( $found ) {
continue;
}
if ( $param->isDefaultValueAvailable() ) {
$args[] = $param->getDefaultValue();
} else {
throw new \BadMethodCallException( "Not all required parameters were provided. Required: '{$param->getName()}'.'", 2 );
}
}
$replaced[ $tag ] = $listener->render( $args );
}
return $replaced;
}
|
php
|
public function render_tags( array $data_sources ) {
$replaced = array();
foreach ( $this->get_listeners() as $tag => $listener ) {
$params = $listener->get_callback_reflection()->getParameters();
$args = array();
foreach ( $params as $param ) {
$found = false;
foreach ( $data_sources as $name => $data_source ) {
if ( is_object( $data_source ) && ( $class = $param->getClass() ) !== null && $class->isInstance( $data_source ) ) {
$args[] = $data_source;
$found = true;
} elseif ( $param->getName() === $name ) {
if ( isset( $class ) ) {
throw new \BadMethodCallException(
"Data source '$name' does not match type of required parameter '{$param->getName()}'. Required type: '{$class->getName()}''",
1
);
}
$args[] = $data_source;
$found = true;
}
if ( $found ) {
break;
}
}
if ( $found ) {
continue;
}
if ( $param->isDefaultValueAvailable() ) {
$args[] = $param->getDefaultValue();
} else {
throw new \BadMethodCallException( "Not all required parameters were provided. Required: '{$param->getName()}'.'", 2 );
}
}
$replaced[ $tag ] = $listener->render( $args );
}
return $replaced;
}
|
[
"public",
"function",
"render_tags",
"(",
"array",
"$",
"data_sources",
")",
"{",
"$",
"replaced",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"get_listeners",
"(",
")",
"as",
"$",
"tag",
"=>",
"$",
"listener",
")",
"{",
"$",
"params",
"=",
"$",
"listener",
"->",
"get_callback_reflection",
"(",
")",
"->",
"getParameters",
"(",
")",
";",
"$",
"args",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"$",
"data_sources",
"as",
"$",
"name",
"=>",
"$",
"data_source",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data_source",
")",
"&&",
"(",
"$",
"class",
"=",
"$",
"param",
"->",
"getClass",
"(",
")",
")",
"!==",
"null",
"&&",
"$",
"class",
"->",
"isInstance",
"(",
"$",
"data_source",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"data_source",
";",
"$",
"found",
"=",
"true",
";",
"}",
"elseif",
"(",
"$",
"param",
"->",
"getName",
"(",
")",
"===",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"\"Data source '$name' does not match type of required parameter '{$param->getName()}'. Required type: '{$class->getName()}''\"",
",",
"1",
")",
";",
"}",
"$",
"args",
"[",
"]",
"=",
"$",
"data_source",
";",
"$",
"found",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"found",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"found",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"param",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"param",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"\"Not all required parameters were provided. Required: '{$param->getName()}'.'\"",
",",
"2",
")",
";",
"}",
"}",
"$",
"replaced",
"[",
"$",
"tag",
"]",
"=",
"$",
"listener",
"->",
"render",
"(",
"$",
"args",
")",
";",
"}",
"return",
"$",
"replaced",
";",
"}"
] |
Return an array of the rendered tags.
@since 1.0
@param array $data_sources
@return array
@throws \BadMethodCallException
|
[
"Return",
"an",
"array",
"of",
"the",
"rendered",
"tags",
"."
] |
train
|
https://github.com/iron-bound-designs/wp-notifications/blob/4fdf67d28d194576d35f86245b2f539c4815cde2/src/Template/Manager.php#L107-L159
|
[
"array"
] |
What does this function return?
|
[
"array",
"",
"@throws",
"\\BadMethodCallException"
] |
jelix/file-utilities
|
lib/Directory.php
|
Directory.create
|
public static function create($dir, $chmod = null)
{
if (!file_exists($dir)) {
if ($chmod === null) {
$chmod = self::$defaultChmod;
}
mkdir($dir, $chmod, true);
// php mkdir apply umask on the given mode, so we must to
// do a chmod manually.
chmod($dir, $chmod);
return true;
}
return false;
}
|
php
|
public static function create($dir, $chmod = null)
{
if (!file_exists($dir)) {
if ($chmod === null) {
$chmod = self::$defaultChmod;
}
mkdir($dir, $chmod, true);
// php mkdir apply umask on the given mode, so we must to
// do a chmod manually.
chmod($dir, $chmod);
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"dir",
",",
"$",
"chmod",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"$",
"chmod",
"===",
"null",
")",
"{",
"$",
"chmod",
"=",
"self",
"::",
"$",
"defaultChmod",
";",
"}",
"mkdir",
"(",
"$",
"dir",
",",
"$",
"chmod",
",",
"true",
")",
";",
"// php mkdir apply umask on the given mode, so we must to",
"// do a chmod manually.",
"chmod",
"(",
"$",
"dir",
",",
"$",
"chmod",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
create a directory.
@return bool false if the directory did already exist
|
[
"create",
"a",
"directory",
"."
] |
train
|
https://github.com/jelix/file-utilities/blob/05fd364860ed147e6367de9db3dc544f58c5a05c/lib/Directory.php#L26-L40
|
[
"dir",
"chmod"
] |
What does this function return?
|
[
"bool",
"false",
"if",
"the",
"directory",
"did",
"already",
"exist"
] |
jelix/file-utilities
|
lib/Directory.php
|
Directory.removeExcept
|
public static function removeExcept($path, $except, $deleteDir = true)
{
if (!is_array($except) || !count($except)) {
throw new \InvalidArgumentException('list of exception is not an array or is empty');
}
if ($path == '' || $path == '/' || $path == DIRECTORY_SEPARATOR) {
throw new \InvalidArgumentException('The root cannot be removed !!');
}
if (!file_exists($path)) {
return true;
}
$allIsDeleted = true;
$dir = new \DirectoryIterator($path);
foreach ($dir as $dirContent) {
// test if the basename matches one of patterns
$exception = false;
foreach ($except as $pattern) {
if ($pattern[0] == '*') { // for pattern like *.foo
if ($dirContent->getBasename() != $dirContent->getBasename(substr($pattern, 1))) {
$allIsDeleted = false;
$exception = true;
break;
}
} elseif ($pattern == $dirContent->getBasename()) {
$allIsDeleted = false;
$exception = true;
break;
}
}
if ($exception) {
continue;
}
// file deletion
if ($dirContent->isFile() || $dirContent->isLink()) {
unlink($dirContent->getPathName());
} else {
// recursive directory deletion
if (!$dirContent->isDot() && $dirContent->isDir()) {
$removed = self::removeExcept($dirContent->getPathName(), $except, true);
if (!$removed) {
$allIsDeleted = false;
}
}
}
}
unset($dir);
unset($dirContent);
// removes the parent directory
if ($deleteDir && $allIsDeleted) {
rmdir($path);
}
return $allIsDeleted;
}
|
php
|
public static function removeExcept($path, $except, $deleteDir = true)
{
if (!is_array($except) || !count($except)) {
throw new \InvalidArgumentException('list of exception is not an array or is empty');
}
if ($path == '' || $path == '/' || $path == DIRECTORY_SEPARATOR) {
throw new \InvalidArgumentException('The root cannot be removed !!');
}
if (!file_exists($path)) {
return true;
}
$allIsDeleted = true;
$dir = new \DirectoryIterator($path);
foreach ($dir as $dirContent) {
// test if the basename matches one of patterns
$exception = false;
foreach ($except as $pattern) {
if ($pattern[0] == '*') { // for pattern like *.foo
if ($dirContent->getBasename() != $dirContent->getBasename(substr($pattern, 1))) {
$allIsDeleted = false;
$exception = true;
break;
}
} elseif ($pattern == $dirContent->getBasename()) {
$allIsDeleted = false;
$exception = true;
break;
}
}
if ($exception) {
continue;
}
// file deletion
if ($dirContent->isFile() || $dirContent->isLink()) {
unlink($dirContent->getPathName());
} else {
// recursive directory deletion
if (!$dirContent->isDot() && $dirContent->isDir()) {
$removed = self::removeExcept($dirContent->getPathName(), $except, true);
if (!$removed) {
$allIsDeleted = false;
}
}
}
}
unset($dir);
unset($dirContent);
// removes the parent directory
if ($deleteDir && $allIsDeleted) {
rmdir($path);
}
return $allIsDeleted;
}
|
[
"public",
"static",
"function",
"removeExcept",
"(",
"$",
"path",
",",
"$",
"except",
",",
"$",
"deleteDir",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"except",
")",
"||",
"!",
"count",
"(",
"$",
"except",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'list of exception is not an array or is empty'",
")",
";",
"}",
"if",
"(",
"$",
"path",
"==",
"''",
"||",
"$",
"path",
"==",
"'/'",
"||",
"$",
"path",
"==",
"DIRECTORY_SEPARATOR",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The root cannot be removed !!'",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"allIsDeleted",
"=",
"true",
";",
"$",
"dir",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"dir",
"as",
"$",
"dirContent",
")",
"{",
"// test if the basename matches one of patterns",
"$",
"exception",
"=",
"false",
";",
"foreach",
"(",
"$",
"except",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"$",
"pattern",
"[",
"0",
"]",
"==",
"'*'",
")",
"{",
"// for pattern like *.foo",
"if",
"(",
"$",
"dirContent",
"->",
"getBasename",
"(",
")",
"!=",
"$",
"dirContent",
"->",
"getBasename",
"(",
"substr",
"(",
"$",
"pattern",
",",
"1",
")",
")",
")",
"{",
"$",
"allIsDeleted",
"=",
"false",
";",
"$",
"exception",
"=",
"true",
";",
"break",
";",
"}",
"}",
"elseif",
"(",
"$",
"pattern",
"==",
"$",
"dirContent",
"->",
"getBasename",
"(",
")",
")",
"{",
"$",
"allIsDeleted",
"=",
"false",
";",
"$",
"exception",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"exception",
")",
"{",
"continue",
";",
"}",
"// file deletion",
"if",
"(",
"$",
"dirContent",
"->",
"isFile",
"(",
")",
"||",
"$",
"dirContent",
"->",
"isLink",
"(",
")",
")",
"{",
"unlink",
"(",
"$",
"dirContent",
"->",
"getPathName",
"(",
")",
")",
";",
"}",
"else",
"{",
"// recursive directory deletion",
"if",
"(",
"!",
"$",
"dirContent",
"->",
"isDot",
"(",
")",
"&&",
"$",
"dirContent",
"->",
"isDir",
"(",
")",
")",
"{",
"$",
"removed",
"=",
"self",
"::",
"removeExcept",
"(",
"$",
"dirContent",
"->",
"getPathName",
"(",
")",
",",
"$",
"except",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"removed",
")",
"{",
"$",
"allIsDeleted",
"=",
"false",
";",
"}",
"}",
"}",
"}",
"unset",
"(",
"$",
"dir",
")",
";",
"unset",
"(",
"$",
"dirContent",
")",
";",
"// removes the parent directory",
"if",
"(",
"$",
"deleteDir",
"&&",
"$",
"allIsDeleted",
")",
"{",
"rmdir",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"allIsDeleted",
";",
"}"
] |
Recursive function deleting all files into a directory except those indicated.
@param string $path The path of the directory to remove recursively
@param array $except filenames and suffix of filename, for files to NOT delete
@param bool $deleteDir If the path must be deleted too
@return bool true if all the content has been removed
@author Loic Mathaud
|
[
"Recursive",
"function",
"deleting",
"all",
"files",
"into",
"a",
"directory",
"except",
"those",
"indicated",
"."
] |
train
|
https://github.com/jelix/file-utilities/blob/05fd364860ed147e6367de9db3dc544f58c5a05c/lib/Directory.php#L93-L150
|
[
"path",
"except",
"deleteDir"
] |
What does this function return?
|
[
"bool",
"true",
"if",
"all",
"the",
"content",
"has",
"been",
"removed",
"",
"@author",
"Loic",
"Mathaud"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.reset
|
function reset()
{
$this->_transforms = array();
$this->_transforms_str = '';
$this->_info = null;
if ($this->_handler) imagedestroy($this->_handler);
$this->_handler = null;
return $this;
}
|
php
|
function reset()
{
$this->_transforms = array();
$this->_transforms_str = '';
$this->_info = null;
if ($this->_handler) imagedestroy($this->_handler);
$this->_handler = null;
return $this;
}
|
[
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"_transforms",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_transforms_str",
"=",
"''",
";",
"$",
"this",
"->",
"_info",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"_handler",
")",
"imagedestroy",
"(",
"$",
"this",
"->",
"_handler",
")",
";",
"$",
"this",
"->",
"_handler",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] |
Сброс трансформаций
@return $this
|
[
"Сброс",
"трансформаций"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L72-L80
|
[] |
What does this function return?
|
[
"$this"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.handler
|
function handler()
{
if (!isset($this->_handler)){
$file = $this->getDir().'/'.$this->file;
switch ($this->ext()){
case 'gif':
$this->_handler = @imagecreatefromgif($file);
break;
case 'png':
$this->_handler = @imagecreatefrompng($file);
break;
case 'jpg':
$this->_handler = @imagecreatefromjpeg($file);
break;
default:
throw new \Exception('Не поддерживаем тип файла-изображения');
}
}
return $this->_handler;
}
|
php
|
function handler()
{
if (!isset($this->_handler)){
$file = $this->getDir().'/'.$this->file;
switch ($this->ext()){
case 'gif':
$this->_handler = @imagecreatefromgif($file);
break;
case 'png':
$this->_handler = @imagecreatefrompng($file);
break;
case 'jpg':
$this->_handler = @imagecreatefromjpeg($file);
break;
default:
throw new \Exception('Не поддерживаем тип файла-изображения');
}
}
return $this->_handler;
}
|
[
"function",
"handler",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_handler",
")",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getDir",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"file",
";",
"switch",
"(",
"$",
"this",
"->",
"ext",
"(",
")",
")",
"{",
"case",
"'gif'",
":",
"$",
"this",
"->",
"_handler",
"=",
"@",
"imagecreatefromgif",
"(",
"$",
"file",
")",
";",
"break",
";",
"case",
"'png'",
":",
"$",
"this",
"->",
"_handler",
"=",
"@",
"imagecreatefrompng",
"(",
"$",
"file",
")",
";",
"break",
";",
"case",
"'jpg'",
":",
"$",
"this",
"->",
"_handler",
"=",
"@",
"imagecreatefromjpeg",
"(",
"$",
"file",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"'Не поддерживаем тип файла-изображения');",
"",
"",
"}",
"}",
"return",
"$",
"this",
"->",
"_handler",
";",
"}"
] |
Ресурс изображения для функций GD
@return resource
@throws \Exception
|
[
"Ресурс",
"изображения",
"для",
"функций",
"GD"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L87-L106
|
[] |
What does this function return?
|
[
"resource",
"@throws",
"\\Exception"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.info
|
function info()
{
if (empty($this->_info)){
$file = $this->getDir().'/'.$this->file;
if (is_file($file) && ($info = getimagesize($file))){
$ext = array(1 => 'gif', 2 => 'jpg', 3 => 'png', 4 => 'swf', 5 => 'psd', 6 => 'bmp', 7 => 'tiff', 8 => 'tiff',
9 => 'jpc', 10 => 'jp2', 11 => 'jpx', 12 => 'jb2', 13 => 'swc', 14 => 'iff', 15 => 'wbmp', 16 => 'xbmp'
);
$this->_info = array(
'width' => $info[0],
'height' => $info[1],
'ext' => $ext[$info[2]],
'quality' => 100
);
if (empty($this->_convert)) $this->_convert = $ext[$info[2]];
}
}
return $this->_info;
}
|
php
|
function info()
{
if (empty($this->_info)){
$file = $this->getDir().'/'.$this->file;
if (is_file($file) && ($info = getimagesize($file))){
$ext = array(1 => 'gif', 2 => 'jpg', 3 => 'png', 4 => 'swf', 5 => 'psd', 6 => 'bmp', 7 => 'tiff', 8 => 'tiff',
9 => 'jpc', 10 => 'jp2', 11 => 'jpx', 12 => 'jb2', 13 => 'swc', 14 => 'iff', 15 => 'wbmp', 16 => 'xbmp'
);
$this->_info = array(
'width' => $info[0],
'height' => $info[1],
'ext' => $ext[$info[2]],
'quality' => 100
);
if (empty($this->_convert)) $this->_convert = $ext[$info[2]];
}
}
return $this->_info;
}
|
[
"function",
"info",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_info",
")",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getDir",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"file",
";",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
"&&",
"(",
"$",
"info",
"=",
"getimagesize",
"(",
"$",
"file",
")",
")",
")",
"{",
"$",
"ext",
"=",
"array",
"(",
"1",
"=>",
"'gif'",
",",
"2",
"=>",
"'jpg'",
",",
"3",
"=>",
"'png'",
",",
"4",
"=>",
"'swf'",
",",
"5",
"=>",
"'psd'",
",",
"6",
"=>",
"'bmp'",
",",
"7",
"=>",
"'tiff'",
",",
"8",
"=>",
"'tiff'",
",",
"9",
"=>",
"'jpc'",
",",
"10",
"=>",
"'jp2'",
",",
"11",
"=>",
"'jpx'",
",",
"12",
"=>",
"'jb2'",
",",
"13",
"=>",
"'swc'",
",",
"14",
"=>",
"'iff'",
",",
"15",
"=>",
"'wbmp'",
",",
"16",
"=>",
"'xbmp'",
")",
";",
"$",
"this",
"->",
"_info",
"=",
"array",
"(",
"'width'",
"=>",
"$",
"info",
"[",
"0",
"]",
",",
"'height'",
"=>",
"$",
"info",
"[",
"1",
"]",
",",
"'ext'",
"=>",
"$",
"ext",
"[",
"$",
"info",
"[",
"2",
"]",
"]",
",",
"'quality'",
"=>",
"100",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_convert",
")",
")",
"$",
"this",
"->",
"_convert",
"=",
"$",
"ext",
"[",
"$",
"info",
"[",
"2",
"]",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_info",
";",
"}"
] |
Информация об изображении
@return array
|
[
"Информация",
"об",
"изображении"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L112-L130
|
[] |
What does this function return?
|
[
"array"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.rotate
|
function rotate($angle, $do = false) {
$angle = min(max(floatval($angle), -360), 360);
if (!$do){
$this->_transforms[] = array('rotate', array($angle, true));
$this->_transforms_str.='rotate('.$angle.')';
}else{
$rgba = array(255,255,255,0);
$handler = $this->handler();
$bg_color = imagecolorallocatealpha($handler, $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
$new = imagerotate($handler, $angle, $bg_color);
imagesavealpha($new, true);
imagealphablending($new, true);
$this->_info['width'] = imagesx($new);
$this->_info['height'] = imagesy($new);
imagedestroy($this->_handler);
$this->_handler = $new;
}
return $this;
}
|
php
|
function rotate($angle, $do = false) {
$angle = min(max(floatval($angle), -360), 360);
if (!$do){
$this->_transforms[] = array('rotate', array($angle, true));
$this->_transforms_str.='rotate('.$angle.')';
}else{
$rgba = array(255,255,255,0);
$handler = $this->handler();
$bg_color = imagecolorallocatealpha($handler, $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
$new = imagerotate($handler, $angle, $bg_color);
imagesavealpha($new, true);
imagealphablending($new, true);
$this->_info['width'] = imagesx($new);
$this->_info['height'] = imagesy($new);
imagedestroy($this->_handler);
$this->_handler = $new;
}
return $this;
}
|
[
"function",
"rotate",
"(",
"$",
"angle",
",",
"$",
"do",
"=",
"false",
")",
"{",
"$",
"angle",
"=",
"min",
"(",
"max",
"(",
"floatval",
"(",
"$",
"angle",
")",
",",
"-",
"360",
")",
",",
"360",
")",
";",
"if",
"(",
"!",
"$",
"do",
")",
"{",
"$",
"this",
"->",
"_transforms",
"[",
"]",
"=",
"array",
"(",
"'rotate'",
",",
"array",
"(",
"$",
"angle",
",",
"true",
")",
")",
";",
"$",
"this",
"->",
"_transforms_str",
".=",
"'rotate('",
".",
"$",
"angle",
".",
"')'",
";",
"}",
"else",
"{",
"$",
"rgba",
"=",
"array",
"(",
"255",
",",
"255",
",",
"255",
",",
"0",
")",
";",
"$",
"handler",
"=",
"$",
"this",
"->",
"handler",
"(",
")",
";",
"$",
"bg_color",
"=",
"imagecolorallocatealpha",
"(",
"$",
"handler",
",",
"$",
"rgba",
"[",
"0",
"]",
",",
"$",
"rgba",
"[",
"1",
"]",
",",
"$",
"rgba",
"[",
"2",
"]",
",",
"$",
"rgba",
"[",
"3",
"]",
")",
";",
"$",
"new",
"=",
"imagerotate",
"(",
"$",
"handler",
",",
"$",
"angle",
",",
"$",
"bg_color",
")",
";",
"imagesavealpha",
"(",
"$",
"new",
",",
"true",
")",
";",
"imagealphablending",
"(",
"$",
"new",
",",
"true",
")",
";",
"$",
"this",
"->",
"_info",
"[",
"'width'",
"]",
"=",
"imagesx",
"(",
"$",
"new",
")",
";",
"$",
"this",
"->",
"_info",
"[",
"'height'",
"]",
"=",
"imagesy",
"(",
"$",
"new",
")",
";",
"imagedestroy",
"(",
"$",
"this",
"->",
"_handler",
")",
";",
"$",
"this",
"->",
"_handler",
"=",
"$",
"new",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Поворот изображения
@param float $angle Угол поворота от -360 до 360
@param bool $do Признак, выполнять трансформацию (true) или отложить до результата (пути на файл)
@return $this
|
[
"Поворот",
"изображения"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L311-L329
|
[
"angle",
"do"
] |
What does this function return?
|
[
"$this"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.flip
|
function flip($dir = self::FLIP_X, $do = false) {
$dir = intval($dir);
if (!$do){
$this->_transforms[] = array('flip', array($dir, true));
$this->_transforms_str.='flip('.$dir.')';
}else{
$new = imagecreatetruecolor($w = $this->width(), $h = $this->height());
$src = $this->handler();
imagealphablending($new, false);
imagesavealpha($new, true);
switch ($dir) {
case self::FLIP_Y:
for ($i = 0; $i < $h; $i++) imagecopy($new, $src, 0, $i, 0, $h - $i - 1, $w, 1);
break;
default:
for ($i = 0; $i < $w; $i++) imagecopy($new, $src, $i, 0, $w - $i - 1, 0, 1, $h);
}
imagedestroy($this->_handler);
$this->_handler = $new;
}
return $this;
}
|
php
|
function flip($dir = self::FLIP_X, $do = false) {
$dir = intval($dir);
if (!$do){
$this->_transforms[] = array('flip', array($dir, true));
$this->_transforms_str.='flip('.$dir.')';
}else{
$new = imagecreatetruecolor($w = $this->width(), $h = $this->height());
$src = $this->handler();
imagealphablending($new, false);
imagesavealpha($new, true);
switch ($dir) {
case self::FLIP_Y:
for ($i = 0; $i < $h; $i++) imagecopy($new, $src, 0, $i, 0, $h - $i - 1, $w, 1);
break;
default:
for ($i = 0; $i < $w; $i++) imagecopy($new, $src, $i, 0, $w - $i - 1, 0, 1, $h);
}
imagedestroy($this->_handler);
$this->_handler = $new;
}
return $this;
}
|
[
"function",
"flip",
"(",
"$",
"dir",
"=",
"self",
"::",
"FLIP_X",
",",
"$",
"do",
"=",
"false",
")",
"{",
"$",
"dir",
"=",
"intval",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"!",
"$",
"do",
")",
"{",
"$",
"this",
"->",
"_transforms",
"[",
"]",
"=",
"array",
"(",
"'flip'",
",",
"array",
"(",
"$",
"dir",
",",
"true",
")",
")",
";",
"$",
"this",
"->",
"_transforms_str",
".=",
"'flip('",
".",
"$",
"dir",
".",
"')'",
";",
"}",
"else",
"{",
"$",
"new",
"=",
"imagecreatetruecolor",
"(",
"$",
"w",
"=",
"$",
"this",
"->",
"width",
"(",
")",
",",
"$",
"h",
"=",
"$",
"this",
"->",
"height",
"(",
")",
")",
";",
"$",
"src",
"=",
"$",
"this",
"->",
"handler",
"(",
")",
";",
"imagealphablending",
"(",
"$",
"new",
",",
"false",
")",
";",
"imagesavealpha",
"(",
"$",
"new",
",",
"true",
")",
";",
"switch",
"(",
"$",
"dir",
")",
"{",
"case",
"self",
"::",
"FLIP_Y",
":",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"h",
";",
"$",
"i",
"++",
")",
"imagecopy",
"(",
"$",
"new",
",",
"$",
"src",
",",
"0",
",",
"$",
"i",
",",
"0",
",",
"$",
"h",
"-",
"$",
"i",
"-",
"1",
",",
"$",
"w",
",",
"1",
")",
";",
"break",
";",
"default",
":",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"w",
";",
"$",
"i",
"++",
")",
"imagecopy",
"(",
"$",
"new",
",",
"$",
"src",
",",
"$",
"i",
",",
"0",
",",
"$",
"w",
"-",
"$",
"i",
"-",
"1",
",",
"0",
",",
"1",
",",
"$",
"h",
")",
";",
"}",
"imagedestroy",
"(",
"$",
"this",
"->",
"_handler",
")",
";",
"$",
"this",
"->",
"_handler",
"=",
"$",
"new",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Отражение изображения
@param int $dir Направление отражения. Задаётся константами Transform::FLIP_*
@param bool $do Признак, выполнять трансформацию (true) или отложить до результата (пути на файл)
@return $this
|
[
"Отражение",
"изображения"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L337-L358
|
[
"dir",
"do"
] |
What does this function return?
|
[
"$this"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.gray
|
function gray($do = false)
{
if (!$do){
$this->_transforms[] = array('gray', array(true));
$this->_transforms_str.='gray()';
}else{
imagefilter($this->handler(), IMG_FILTER_GRAYSCALE);
}
return $this;
}
|
php
|
function gray($do = false)
{
if (!$do){
$this->_transforms[] = array('gray', array(true));
$this->_transforms_str.='gray()';
}else{
imagefilter($this->handler(), IMG_FILTER_GRAYSCALE);
}
return $this;
}
|
[
"function",
"gray",
"(",
"$",
"do",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"do",
")",
"{",
"$",
"this",
"->",
"_transforms",
"[",
"]",
"=",
"array",
"(",
"'gray'",
",",
"array",
"(",
"true",
")",
")",
";",
"$",
"this",
"->",
"_transforms_str",
".=",
"'gray()'",
";",
"}",
"else",
"{",
"imagefilter",
"(",
"$",
"this",
"->",
"handler",
"(",
")",
",",
"IMG_FILTER_GRAYSCALE",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Преобразование в серые тона
@param bool $do Признак, выполнять трансформацию (true) или отложить до результата (пути на файл)
@return $this
|
[
"Преобразование",
"в",
"серые",
"тона"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L365-L374
|
[
"do"
] |
What does this function return?
|
[
"$this"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.quality
|
function quality($percent)
{
$this->info();
$this->_info['quality'] = intval($percent);
if ($percent!=100){
$this->_transforms_str.='quality('.$this->_info['quality'].')';
}
return $this;
}
|
php
|
function quality($percent)
{
$this->info();
$this->_info['quality'] = intval($percent);
if ($percent!=100){
$this->_transforms_str.='quality('.$this->_info['quality'].')';
}
return $this;
}
|
[
"function",
"quality",
"(",
"$",
"percent",
")",
"{",
"$",
"this",
"->",
"info",
"(",
")",
";",
"$",
"this",
"->",
"_info",
"[",
"'quality'",
"]",
"=",
"intval",
"(",
"$",
"percent",
")",
";",
"if",
"(",
"$",
"percent",
"!=",
"100",
")",
"{",
"$",
"this",
"->",
"_transforms_str",
".=",
"'quality('",
".",
"$",
"this",
"->",
"_info",
"[",
"'quality'",
"]",
".",
"')'",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Качество изображения для jpg и png
@param int $percent от 0 до 100
@return $this
|
[
"Качество",
"изображения",
"для",
"jpg",
"и",
"png"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L381-L389
|
[
"percent"
] |
What does this function return?
|
[
"$this"
] |
Boolive/Core
|
utils/Transform.php
|
Transform.convert
|
function convert($type)
{
if (in_array($type, array('gif','png','jpg'))){
$this->_transforms_str.='convert('.$type.')';
$this->_convert = $type;
}
return $this;
}
|
php
|
function convert($type)
{
if (in_array($type, array('gif','png','jpg'))){
$this->_transforms_str.='convert('.$type.')';
$this->_convert = $type;
}
return $this;
}
|
[
"function",
"convert",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"array",
"(",
"'gif'",
",",
"'png'",
",",
"'jpg'",
")",
")",
")",
"{",
"$",
"this",
"->",
"_transforms_str",
".=",
"'convert('",
".",
"$",
"type",
".",
"')'",
";",
"$",
"this",
"->",
"_convert",
"=",
"$",
"type",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Смена расширения
@param string $type Новое расширение (gif, png, jpg)
@return $this
|
[
"Смена",
"расширения"
] |
train
|
https://github.com/Boolive/Core/blob/ead9668f1a6adf41656131eb608a99db6855138d/utils/Transform.php#L396-L403
|
[
"type"
] |
What does this function return?
|
[
"$this"
] |
ellipsephp/container-reflection
|
src/AbstractReflectionContainer.php
|
AbstractReflectionContainer.isAutoWirable
|
private function isAutoWirable($id): bool
{
if (is_string($id) && class_exists($id)) {
if (count($this->interfaces) > 0) {
return (bool) array_intersect($this->interfaces, class_implements($id));
}
return true;
}
return false;
}
|
php
|
private function isAutoWirable($id): bool
{
if (is_string($id) && class_exists($id)) {
if (count($this->interfaces) > 0) {
return (bool) array_intersect($this->interfaces, class_implements($id));
}
return true;
}
return false;
}
|
[
"private",
"function",
"isAutoWirable",
"(",
"$",
"id",
")",
":",
"bool",
"{",
"if",
"(",
"is_string",
"(",
"$",
"id",
")",
"&&",
"class_exists",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"interfaces",
")",
">",
"0",
")",
"{",
"return",
"(",
"bool",
")",
"array_intersect",
"(",
"$",
"this",
"->",
"interfaces",
",",
"class_implements",
"(",
"$",
"id",
")",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Return whether the given id is an auto wirable class.
@param $id
@return bool
|
[
"Return",
"whether",
"the",
"given",
"id",
"is",
"an",
"auto",
"wirable",
"class",
"."
] |
train
|
https://github.com/ellipsephp/container-reflection/blob/bd35a26e0fc924788f54b560d4a2d72ecf9a2be9/src/AbstractReflectionContainer.php#L99-L114
|
[
"id"
] |
What does this function return?
|
[
"bool"
] |
ellipsephp/container-reflection
|
src/AbstractReflectionContainer.php
|
AbstractReflectionContainer.make
|
private function make(string $class)
{
if (! array_key_exists($class, $this->instances)) {
try {
return $this->instances[$class] = ($this->factory)($class)->value($this);
}
catch (ResolvingExceptionInterface $e) {
throw new ReflectionContainerException($class, $e);
}
}
return $this->instances[$class];
}
|
php
|
private function make(string $class)
{
if (! array_key_exists($class, $this->instances)) {
try {
return $this->instances[$class] = ($this->factory)($class)->value($this);
}
catch (ResolvingExceptionInterface $e) {
throw new ReflectionContainerException($class, $e);
}
}
return $this->instances[$class];
}
|
[
"private",
"function",
"make",
"(",
"string",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"instances",
")",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"class",
"]",
"=",
"(",
"$",
"this",
"->",
"factory",
")",
"(",
"$",
"class",
")",
"->",
"value",
"(",
"$",
"this",
")",
";",
"}",
"catch",
"(",
"ResolvingExceptionInterface",
"$",
"e",
")",
"{",
"throw",
"new",
"ReflectionContainerException",
"(",
"$",
"class",
",",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"class",
"]",
";",
"}"
] |
Return an instance of the given class name. Cache the created instance so
the same one is returned on multiple calls.
@param string $class
@return mixed
@throws \Ellipse\Container\Exceptions\ReflectionContainerException
|
[
"Return",
"an",
"instance",
"of",
"the",
"given",
"class",
"name",
".",
"Cache",
"the",
"created",
"instance",
"so",
"the",
"same",
"one",
"is",
"returned",
"on",
"multiple",
"calls",
"."
] |
train
|
https://github.com/ellipsephp/container-reflection/blob/bd35a26e0fc924788f54b560d4a2d72ecf9a2be9/src/AbstractReflectionContainer.php#L124-L143
|
[
"string"
] |
What does this function return?
|
[
"mixed",
"@throws",
"\\Ellipse\\Container\\Exceptions\\ReflectionContainerException"
] |
fnayou/instapush-php
|
src/Http/AbstractHttpClientConfigurator.php
|
AbstractHttpClientConfigurator.appendPlugin
|
public function appendPlugin(Plugin ...$plugins)
{
foreach ($plugins as $plugin) {
$this->appendPlugins[] = $plugin;
}
return $this;
}
|
php
|
public function appendPlugin(Plugin ...$plugins)
{
foreach ($plugins as $plugin) {
$this->appendPlugins[] = $plugin;
}
return $this;
}
|
[
"public",
"function",
"appendPlugin",
"(",
"Plugin",
"...",
"$",
"plugins",
")",
"{",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"appendPlugins",
"[",
"]",
"=",
"$",
"plugin",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
@param \Http\Client\Common\Plugin ...$plugins
@return $this
|
[
"@param",
"\\",
"Http",
"\\",
"Client",
"\\",
"Common",
"\\",
"Plugin",
"...",
"$plugins"
] |
train
|
https://github.com/fnayou/instapush-php/blob/fa7bd9091cf4dee767449412dc10911f4afbdf24/src/Http/AbstractHttpClientConfigurator.php#L107-L114
|
[
"Plugin"
] |
What does this function return?
|
[
"$this"
] |
fnayou/instapush-php
|
src/Http/AbstractHttpClientConfigurator.php
|
AbstractHttpClientConfigurator.prependPlugin
|
public function prependPlugin(Plugin ...$plugins)
{
$plugins = \array_reverse($plugins);
foreach ($plugins as $plugin) {
\array_unshift($this->prependPlugins, $plugin);
}
return $this;
}
|
php
|
public function prependPlugin(Plugin ...$plugins)
{
$plugins = \array_reverse($plugins);
foreach ($plugins as $plugin) {
\array_unshift($this->prependPlugins, $plugin);
}
return $this;
}
|
[
"public",
"function",
"prependPlugin",
"(",
"Plugin",
"...",
"$",
"plugins",
")",
"{",
"$",
"plugins",
"=",
"\\",
"array_reverse",
"(",
"$",
"plugins",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"\\",
"array_unshift",
"(",
"$",
"this",
"->",
"prependPlugins",
",",
"$",
"plugin",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
@param \Http\Client\Common\Plugin ...$plugins
@return $this
|
[
"@param",
"\\",
"Http",
"\\",
"Client",
"\\",
"Common",
"\\",
"Plugin",
"...",
"$plugins"
] |
train
|
https://github.com/fnayou/instapush-php/blob/fa7bd9091cf4dee767449412dc10911f4afbdf24/src/Http/AbstractHttpClientConfigurator.php#L121-L130
|
[
"Plugin"
] |
What does this function return?
|
[
"$this"
] |
pmdevelopment/tool-bundle
|
Framework/Model/ChartJs/DataObject.php
|
DataObject.exportDataSets
|
public function exportDataSets($dataSetConfig = null)
{
$response = [];
foreach ($this->getDataSets() as $set) {
if ($set instanceof DataSet) {
$response[] = $set->export($dataSetConfig);
} else {
$response[] = $set;
}
}
return $response;
}
|
php
|
public function exportDataSets($dataSetConfig = null)
{
$response = [];
foreach ($this->getDataSets() as $set) {
if ($set instanceof DataSet) {
$response[] = $set->export($dataSetConfig);
} else {
$response[] = $set;
}
}
return $response;
}
|
[
"public",
"function",
"exportDataSets",
"(",
"$",
"dataSetConfig",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getDataSets",
"(",
")",
"as",
"$",
"set",
")",
"{",
"if",
"(",
"$",
"set",
"instanceof",
"DataSet",
")",
"{",
"$",
"response",
"[",
"]",
"=",
"$",
"set",
"->",
"export",
"(",
"$",
"dataSetConfig",
")",
";",
"}",
"else",
"{",
"$",
"response",
"[",
"]",
"=",
"$",
"set",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] |
Export Data Sets
@param DataSetConfig|null $dataSetConfig
@return array
|
[
"Export",
"Data",
"Sets"
] |
train
|
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Framework/Model/ChartJs/DataObject.php#L64-L77
|
[
"dataSetConfig"
] |
What does this function return?
|
[
"array"
] |
Tuna-CMS/tuna-bundle
|
src/Tuna/Bundle/FileBundle/Controller/DefaultController.php
|
DefaultController.getErrorResponse
|
private function getErrorResponse(FormInterface $form)
{
$errors = $form->getErrors();
$errorCollection = [];
foreach ($errors as $error) {
$errorCollection[] = $error->getMessage();
}
return new JsonResponse([
'messages' => $errorCollection,
], 400);
}
|
php
|
private function getErrorResponse(FormInterface $form)
{
$errors = $form->getErrors();
$errorCollection = [];
foreach ($errors as $error) {
$errorCollection[] = $error->getMessage();
}
return new JsonResponse([
'messages' => $errorCollection,
], 400);
}
|
[
"private",
"function",
"getErrorResponse",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"errors",
"=",
"$",
"form",
"->",
"getErrors",
"(",
")",
";",
"$",
"errorCollection",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"$",
"errorCollection",
"[",
"]",
"=",
"$",
"error",
"->",
"getMessage",
"(",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"[",
"'messages'",
"=>",
"$",
"errorCollection",
",",
"]",
",",
"400",
")",
";",
"}"
] |
@param FormInterface $form
@return JsonResponse
|
[
"@param",
"FormInterface",
"$form"
] |
train
|
https://github.com/Tuna-CMS/tuna-bundle/blob/1f999de44e14cbe9f992d46f2e5e74ddc117b04c/src/Tuna/Bundle/FileBundle/Controller/DefaultController.php#L52-L64
|
[
"FormInterface"
] |
What does this function return?
|
[
"JsonResponse"
] |
Tuna-CMS/tuna-bundle
|
src/Tuna/Bundle/FileBundle/Controller/DefaultController.php
|
DefaultController.getFileInfo
|
private function getFileInfo(UploadedFile $file)
{
$fileManager = $this->get('tuna_cms_file.manager.file_manager');
$filename = $fileManager->generateTmpFilename($file);
return [
'path' => $filename,
'mimeType' => $file->getMimeType(),
'originalName' => $file->getClientOriginalName(),
];
}
|
php
|
private function getFileInfo(UploadedFile $file)
{
$fileManager = $this->get('tuna_cms_file.manager.file_manager');
$filename = $fileManager->generateTmpFilename($file);
return [
'path' => $filename,
'mimeType' => $file->getMimeType(),
'originalName' => $file->getClientOriginalName(),
];
}
|
[
"private",
"function",
"getFileInfo",
"(",
"UploadedFile",
"$",
"file",
")",
"{",
"$",
"fileManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'tuna_cms_file.manager.file_manager'",
")",
";",
"$",
"filename",
"=",
"$",
"fileManager",
"->",
"generateTmpFilename",
"(",
"$",
"file",
")",
";",
"return",
"[",
"'path'",
"=>",
"$",
"filename",
",",
"'mimeType'",
"=>",
"$",
"file",
"->",
"getMimeType",
"(",
")",
",",
"'originalName'",
"=>",
"$",
"file",
"->",
"getClientOriginalName",
"(",
")",
",",
"]",
";",
"}"
] |
@param UploadedFile $file
@return array
|
[
"@param",
"UploadedFile",
"$file"
] |
train
|
https://github.com/Tuna-CMS/tuna-bundle/blob/1f999de44e14cbe9f992d46f2e5e74ddc117b04c/src/Tuna/Bundle/FileBundle/Controller/DefaultController.php#L71-L81
|
[
"UploadedFile"
] |
What does this function return?
|
[
"array"
] |
crisu83/yii-consoletools
|
commands/PermissionsCommand.php
|
PermissionsCommand.run
|
public function run($args)
{
foreach ($this->permissions as $dir => $config) {
$path = $this->basePath . '/' . $dir;
if (file_exists($path)) {
try {
if (isset($config['user'])) {
$this->changeOwner($path, $config['user']);
}
if (isset($config['group'])) {
$this->changeGroup($path, $config['group']);
}
if (isset($config['mode'])) {
$this->changeMode($path, $config['mode']);
}
} catch(CException $e) {
echo $this->formatError($e->getMessage())."\n";
}
} else {
echo sprintf("Failed to change permissions for %s. File does not exist!\n", $path);
}
}
echo "Permissions successfully changed.\n";
return 0;
}
|
php
|
public function run($args)
{
foreach ($this->permissions as $dir => $config) {
$path = $this->basePath . '/' . $dir;
if (file_exists($path)) {
try {
if (isset($config['user'])) {
$this->changeOwner($path, $config['user']);
}
if (isset($config['group'])) {
$this->changeGroup($path, $config['group']);
}
if (isset($config['mode'])) {
$this->changeMode($path, $config['mode']);
}
} catch(CException $e) {
echo $this->formatError($e->getMessage())."\n";
}
} else {
echo sprintf("Failed to change permissions for %s. File does not exist!\n", $path);
}
}
echo "Permissions successfully changed.\n";
return 0;
}
|
[
"public",
"function",
"run",
"(",
"$",
"args",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"permissions",
"as",
"$",
"dir",
"=>",
"$",
"config",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"basePath",
".",
"'/'",
".",
"$",
"dir",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"try",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'user'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"changeOwner",
"(",
"$",
"path",
",",
"$",
"config",
"[",
"'user'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'group'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"changeGroup",
"(",
"$",
"path",
",",
"$",
"config",
"[",
"'group'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'mode'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"changeMode",
"(",
"$",
"path",
",",
"$",
"config",
"[",
"'mode'",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"CException",
"$",
"e",
")",
"{",
"echo",
"$",
"this",
"->",
"formatError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
".",
"\"\\n\"",
";",
"}",
"}",
"else",
"{",
"echo",
"sprintf",
"(",
"\"Failed to change permissions for %s. File does not exist!\\n\"",
",",
"$",
"path",
")",
";",
"}",
"}",
"echo",
"\"Permissions successfully changed.\\n\"",
";",
"return",
"0",
";",
"}"
] |
Runs the command.
@param array $args the command-line arguments.
@return integer the return code.
|
[
"Runs",
"the",
"command",
"."
] |
train
|
https://github.com/crisu83/yii-consoletools/blob/53bcb1bcdd33b9ef79034ff9c0d5bbfb3f971afc/commands/PermissionsCommand.php#L63-L87
|
[
"args"
] |
What does this function return?
|
[
"integer",
"the",
"return",
"code."
] |
IftekherSunny/Planet-Framework
|
src/Sun/Http/Redirect.php
|
Redirect.with
|
public function with($key, $value)
{
$this->hasData = true;
$this->session->create($key, $value);
return $this;
}
|
php
|
public function with($key, $value)
{
$this->hasData = true;
$this->session->create($key, $value);
return $this;
}
|
[
"public",
"function",
"with",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"hasData",
"=",
"true",
";",
"$",
"this",
"->",
"session",
"->",
"create",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
To store data in a session
@param string $key
@param mixed $value
@return $this
|
[
"To",
"store",
"data",
"in",
"a",
"session"
] |
train
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Http/Redirect.php#L72-L79
|
[
"key",
"value"
] |
What does this function return?
|
[
"$this"
] |
pilipinews/common
|
src/Converters/LinkConverter.php
|
LinkConverter.convert
|
public function convert(ElementInterface $element)
{
$text = trim($element->getValue(), "\t\n\r\0\x0B");
$href = $element->getAttribute('href');
$markdown = $text . ' (' . $href . ')';
$autolink = $this->isValidAutolink((string) $href);
$href === $text && $autolink && $markdown = $href;
return $markdown;
}
|
php
|
public function convert(ElementInterface $element)
{
$text = trim($element->getValue(), "\t\n\r\0\x0B");
$href = $element->getAttribute('href');
$markdown = $text . ' (' . $href . ')';
$autolink = $this->isValidAutolink((string) $href);
$href === $text && $autolink && $markdown = $href;
return $markdown;
}
|
[
"public",
"function",
"convert",
"(",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"text",
"=",
"trim",
"(",
"$",
"element",
"->",
"getValue",
"(",
")",
",",
"\"\\t\\n\\r\\0\\x0B\"",
")",
";",
"$",
"href",
"=",
"$",
"element",
"->",
"getAttribute",
"(",
"'href'",
")",
";",
"$",
"markdown",
"=",
"$",
"text",
".",
"' ('",
".",
"$",
"href",
".",
"')'",
";",
"$",
"autolink",
"=",
"$",
"this",
"->",
"isValidAutolink",
"(",
"(",
"string",
")",
"$",
"href",
")",
";",
"$",
"href",
"===",
"$",
"text",
"&&",
"$",
"autolink",
"&&",
"$",
"markdown",
"=",
"$",
"href",
";",
"return",
"$",
"markdown",
";",
"}"
] |
Converts the specified element into a parsed string.
@param \League\HTMLToMarkdown\ElementInterface $element
@return string
|
[
"Converts",
"the",
"specified",
"element",
"into",
"a",
"parsed",
"string",
"."
] |
train
|
https://github.com/pilipinews/common/blob/a39f16e935b3b8e97b54b6e9348a1deab2d0a2a0/src/Converters/LinkConverter.php#L22-L35
|
[
"ElementInterface"
] |
What does this function return?
|
[
"string"
] |
akumar2-velsof/guzzlehttp
|
src/RingBridge.php
|
RingBridge.createRingRequest
|
public static function createRingRequest(RequestInterface $request)
{
$options = $request->getConfig()->toArray();
$url = $request->getUrl();
// No need to calculate the query string twice (in URL and query).
$qs = ($pos = strpos($url, '?')) ? substr($url, $pos + 1) : null;
return [
'scheme' => $request->getScheme(),
'http_method' => $request->getMethod(),
'url' => $url,
'uri' => $request->getPath(),
'headers' => $request->getHeaders(),
'body' => $request->getBody(),
'version' => $request->getProtocolVersion(),
'client' => $options,
'query_string' => $qs,
'future' => isset($options['future']) ? $options['future'] : false
];
}
|
php
|
public static function createRingRequest(RequestInterface $request)
{
$options = $request->getConfig()->toArray();
$url = $request->getUrl();
// No need to calculate the query string twice (in URL and query).
$qs = ($pos = strpos($url, '?')) ? substr($url, $pos + 1) : null;
return [
'scheme' => $request->getScheme(),
'http_method' => $request->getMethod(),
'url' => $url,
'uri' => $request->getPath(),
'headers' => $request->getHeaders(),
'body' => $request->getBody(),
'version' => $request->getProtocolVersion(),
'client' => $options,
'query_string' => $qs,
'future' => isset($options['future']) ? $options['future'] : false
];
}
|
[
"public",
"static",
"function",
"createRingRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"options",
"=",
"$",
"request",
"->",
"getConfig",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"url",
"=",
"$",
"request",
"->",
"getUrl",
"(",
")",
";",
"// No need to calculate the query string twice (in URL and query).",
"$",
"qs",
"=",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"url",
",",
"'?'",
")",
")",
"?",
"substr",
"(",
"$",
"url",
",",
"$",
"pos",
"+",
"1",
")",
":",
"null",
";",
"return",
"[",
"'scheme'",
"=>",
"$",
"request",
"->",
"getScheme",
"(",
")",
",",
"'http_method'",
"=>",
"$",
"request",
"->",
"getMethod",
"(",
")",
",",
"'url'",
"=>",
"$",
"url",
",",
"'uri'",
"=>",
"$",
"request",
"->",
"getPath",
"(",
")",
",",
"'headers'",
"=>",
"$",
"request",
"->",
"getHeaders",
"(",
")",
",",
"'body'",
"=>",
"$",
"request",
"->",
"getBody",
"(",
")",
",",
"'version'",
"=>",
"$",
"request",
"->",
"getProtocolVersion",
"(",
")",
",",
"'client'",
"=>",
"$",
"options",
",",
"'query_string'",
"=>",
"$",
"qs",
",",
"'future'",
"=>",
"isset",
"(",
"$",
"options",
"[",
"'future'",
"]",
")",
"?",
"$",
"options",
"[",
"'future'",
"]",
":",
"false",
"]",
";",
"}"
] |
Creates a Ring request from a request object.
This function does not hook up the "then" and "progress" events that
would be required for actually sending a Guzzle request through a
RingPHP handler.
@param RequestInterface $request Request to convert.
@return array Converted Guzzle Ring request.
|
[
"Creates",
"a",
"Ring",
"request",
"from",
"a",
"request",
"object",
"."
] |
train
|
https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/RingBridge.php#L28-L47
|
[
"RequestInterface"
] |
What does this function return?
|
[
"array",
"Converted",
"Guzzle",
"Ring",
"request."
] |
akumar2-velsof/guzzlehttp
|
src/RingBridge.php
|
RingBridge.prepareRingRequest
|
public static function prepareRingRequest(Transaction $trans)
{
// Clear out the transaction state when initiating.
$trans->exception = null;
$request = self::createRingRequest($trans->request);
// Emit progress events if any progress listeners are registered.
if ($trans->request->getEmitter()->hasListeners('progress')) {
$emitter = $trans->request->getEmitter();
$request['client']['progress'] = function ($a, $b, $c, $d) use ($trans, $emitter) {
$emitter->emit('progress', new ProgressEvent($trans, $a, $b, $c, $d));
};
}
return $request;
}
|
php
|
public static function prepareRingRequest(Transaction $trans)
{
// Clear out the transaction state when initiating.
$trans->exception = null;
$request = self::createRingRequest($trans->request);
// Emit progress events if any progress listeners are registered.
if ($trans->request->getEmitter()->hasListeners('progress')) {
$emitter = $trans->request->getEmitter();
$request['client']['progress'] = function ($a, $b, $c, $d) use ($trans, $emitter) {
$emitter->emit('progress', new ProgressEvent($trans, $a, $b, $c, $d));
};
}
return $request;
}
|
[
"public",
"static",
"function",
"prepareRingRequest",
"(",
"Transaction",
"$",
"trans",
")",
"{",
"// Clear out the transaction state when initiating.",
"$",
"trans",
"->",
"exception",
"=",
"null",
";",
"$",
"request",
"=",
"self",
"::",
"createRingRequest",
"(",
"$",
"trans",
"->",
"request",
")",
";",
"// Emit progress events if any progress listeners are registered.",
"if",
"(",
"$",
"trans",
"->",
"request",
"->",
"getEmitter",
"(",
")",
"->",
"hasListeners",
"(",
"'progress'",
")",
")",
"{",
"$",
"emitter",
"=",
"$",
"trans",
"->",
"request",
"->",
"getEmitter",
"(",
")",
";",
"$",
"request",
"[",
"'client'",
"]",
"[",
"'progress'",
"]",
"=",
"function",
"(",
"$",
"a",
",",
"$",
"b",
",",
"$",
"c",
",",
"$",
"d",
")",
"use",
"(",
"$",
"trans",
",",
"$",
"emitter",
")",
"{",
"$",
"emitter",
"->",
"emit",
"(",
"'progress'",
",",
"new",
"ProgressEvent",
"(",
"$",
"trans",
",",
"$",
"a",
",",
"$",
"b",
",",
"$",
"c",
",",
"$",
"d",
")",
")",
";",
"}",
";",
"}",
"return",
"$",
"request",
";",
"}"
] |
Creates a Ring request from a request object AND prepares the callbacks.
@param Transaction $trans Transaction to update.
@return array Converted Guzzle Ring request.
|
[
"Creates",
"a",
"Ring",
"request",
"from",
"a",
"request",
"object",
"AND",
"prepares",
"the",
"callbacks",
"."
] |
train
|
https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/RingBridge.php#L56-L71
|
[
"Transaction"
] |
What does this function return?
|
[
"array",
"Converted",
"Guzzle",
"Ring",
"request."
] |
akumar2-velsof/guzzlehttp
|
src/RingBridge.php
|
RingBridge.fromRingRequest
|
public static function fromRingRequest(array $request)
{
$options = [];
if (isset($request['version'])) {
$options['protocol_version'] = $request['version'];
}
if (!isset($request['http_method'])) {
throw new \InvalidArgumentException('No http_method');
}
return new Request(
$request['http_method'],
Core::url($request),
isset($request['headers']) ? $request['headers'] : [],
isset($request['body']) ? Stream::factory($request['body']) : null,
$options
);
}
|
php
|
public static function fromRingRequest(array $request)
{
$options = [];
if (isset($request['version'])) {
$options['protocol_version'] = $request['version'];
}
if (!isset($request['http_method'])) {
throw new \InvalidArgumentException('No http_method');
}
return new Request(
$request['http_method'],
Core::url($request),
isset($request['headers']) ? $request['headers'] : [],
isset($request['body']) ? Stream::factory($request['body']) : null,
$options
);
}
|
[
"public",
"static",
"function",
"fromRingRequest",
"(",
"array",
"$",
"request",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"request",
"[",
"'version'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'protocol_version'",
"]",
"=",
"$",
"request",
"[",
"'version'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"request",
"[",
"'http_method'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'No http_method'",
")",
";",
"}",
"return",
"new",
"Request",
"(",
"$",
"request",
"[",
"'http_method'",
"]",
",",
"Core",
"::",
"url",
"(",
"$",
"request",
")",
",",
"isset",
"(",
"$",
"request",
"[",
"'headers'",
"]",
")",
"?",
"$",
"request",
"[",
"'headers'",
"]",
":",
"[",
"]",
",",
"isset",
"(",
"$",
"request",
"[",
"'body'",
"]",
")",
"?",
"Stream",
"::",
"factory",
"(",
"$",
"request",
"[",
"'body'",
"]",
")",
":",
"null",
",",
"$",
"options",
")",
";",
"}"
] |
Creates a Guzzle request object using a ring request array.
@param array $request Ring request
@return Request
@throws \InvalidArgumentException for incomplete requests.
|
[
"Creates",
"a",
"Guzzle",
"request",
"object",
"using",
"a",
"ring",
"request",
"array",
"."
] |
train
|
https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/RingBridge.php#L127-L145
|
[
"array"
] |
What does this function return?
|
[
"Request",
"@throws",
"\\InvalidArgumentException",
"for",
"incomplete",
"requests."
] |
loevgaard/dandomain-api
|
src/Api.php
|
Api.doRequest
|
public function doRequest(string $method, string $uri, $body = null, array $options = [])
{
$parsedResponse = [];
try {
// merge all options
// the priority is
// 1. options supplied by the user
// 2. options supplied by the method calling
// 3. the default options
$options = $this->resolveOptions($this->defaultOptions, $options, $this->options);
if (!empty($body)) {
$body = $this->objectToArray($body);
Assert::that($body)->notEmpty('The body of the request cannot be empty');
// the body will always override any other data sent
$options['json'] = $body;
}
// save the resolved options
$this->lastOptions = $options;
// replace the {KEY} placeholder with the api key
$url = $this->host . str_replace('{KEY}', $this->apiKey, $uri);
// do request
$this->response = $this->getClient()->request($method, $url, $options);
// parse response and create error object if the json decode throws an exception
try {
$parsedResponse = \GuzzleHttp\json_decode((string)$this->response->getBody(), true);
} catch (\InvalidArgumentException $e) {
$parsedResponse['errors'][] = [
'status' => $this->response->getStatusCode(),
'title' => 'JSON parse error',
'detail' => $e->getMessage()
];
}
$statusCode = $this->response->getStatusCode();
if ($statusCode > 299 || $statusCode < 200) {
if (!is_array($parsedResponse)) {
$parsedResponse = [];
}
$parsedResponse['errors'] = [];
$parsedResponse['errors'][] = [
'status' => $this->response->getStatusCode(),
'detail' => 'See Api::$response for details'
];
}
} catch (GuzzleException $e) {
$parsedResponse['errors'] = [];
$parsedResponse['errors'][] = [
'title' => 'Unexpected error',
'detail' => $e->getMessage()
];
} finally {
// reset request options
$this->options = [];
}
return $parsedResponse;
}
|
php
|
public function doRequest(string $method, string $uri, $body = null, array $options = [])
{
$parsedResponse = [];
try {
// merge all options
// the priority is
// 1. options supplied by the user
// 2. options supplied by the method calling
// 3. the default options
$options = $this->resolveOptions($this->defaultOptions, $options, $this->options);
if (!empty($body)) {
$body = $this->objectToArray($body);
Assert::that($body)->notEmpty('The body of the request cannot be empty');
// the body will always override any other data sent
$options['json'] = $body;
}
// save the resolved options
$this->lastOptions = $options;
// replace the {KEY} placeholder with the api key
$url = $this->host . str_replace('{KEY}', $this->apiKey, $uri);
// do request
$this->response = $this->getClient()->request($method, $url, $options);
// parse response and create error object if the json decode throws an exception
try {
$parsedResponse = \GuzzleHttp\json_decode((string)$this->response->getBody(), true);
} catch (\InvalidArgumentException $e) {
$parsedResponse['errors'][] = [
'status' => $this->response->getStatusCode(),
'title' => 'JSON parse error',
'detail' => $e->getMessage()
];
}
$statusCode = $this->response->getStatusCode();
if ($statusCode > 299 || $statusCode < 200) {
if (!is_array($parsedResponse)) {
$parsedResponse = [];
}
$parsedResponse['errors'] = [];
$parsedResponse['errors'][] = [
'status' => $this->response->getStatusCode(),
'detail' => 'See Api::$response for details'
];
}
} catch (GuzzleException $e) {
$parsedResponse['errors'] = [];
$parsedResponse['errors'][] = [
'title' => 'Unexpected error',
'detail' => $e->getMessage()
];
} finally {
// reset request options
$this->options = [];
}
return $parsedResponse;
}
|
[
"public",
"function",
"doRequest",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"uri",
",",
"$",
"body",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"parsedResponse",
"=",
"[",
"]",
";",
"try",
"{",
"// merge all options",
"// the priority is",
"// 1. options supplied by the user",
"// 2. options supplied by the method calling",
"// 3. the default options",
"$",
"options",
"=",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"this",
"->",
"defaultOptions",
",",
"$",
"options",
",",
"$",
"this",
"->",
"options",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"body",
")",
")",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"objectToArray",
"(",
"$",
"body",
")",
";",
"Assert",
"::",
"that",
"(",
"$",
"body",
")",
"->",
"notEmpty",
"(",
"'The body of the request cannot be empty'",
")",
";",
"// the body will always override any other data sent",
"$",
"options",
"[",
"'json'",
"]",
"=",
"$",
"body",
";",
"}",
"// save the resolved options",
"$",
"this",
"->",
"lastOptions",
"=",
"$",
"options",
";",
"// replace the {KEY} placeholder with the api key",
"$",
"url",
"=",
"$",
"this",
"->",
"host",
".",
"str_replace",
"(",
"'{KEY}'",
",",
"$",
"this",
"->",
"apiKey",
",",
"$",
"uri",
")",
";",
"// do request",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"// parse response and create error object if the json decode throws an exception",
"try",
"{",
"$",
"parsedResponse",
"=",
"\\",
"GuzzleHttp",
"\\",
"json_decode",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"parsedResponse",
"[",
"'errors'",
"]",
"[",
"]",
"=",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"'title'",
"=>",
"'JSON parse error'",
",",
"'detail'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
";",
"}",
"$",
"statusCode",
"=",
"$",
"this",
"->",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"$",
"statusCode",
">",
"299",
"||",
"$",
"statusCode",
"<",
"200",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"parsedResponse",
")",
")",
"{",
"$",
"parsedResponse",
"=",
"[",
"]",
";",
"}",
"$",
"parsedResponse",
"[",
"'errors'",
"]",
"=",
"[",
"]",
";",
"$",
"parsedResponse",
"[",
"'errors'",
"]",
"[",
"]",
"=",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"'detail'",
"=>",
"'See Api::$response for details'",
"]",
";",
"}",
"}",
"catch",
"(",
"GuzzleException",
"$",
"e",
")",
"{",
"$",
"parsedResponse",
"[",
"'errors'",
"]",
"=",
"[",
"]",
";",
"$",
"parsedResponse",
"[",
"'errors'",
"]",
"[",
"]",
"=",
"[",
"'title'",
"=>",
"'Unexpected error'",
",",
"'detail'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
";",
"}",
"finally",
"{",
"// reset request options",
"$",
"this",
"->",
"options",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"parsedResponse",
";",
"}"
] |
Will always return a JSON result contrary to Dandomains API
Errors are formatted as described here: http://jsonapi.org/format/#errors
@param string $method
@param string $uri
@param array|\stdClass $body The body is sent as JSON
@param array $options
@return mixed
|
[
"Will",
"always",
"return",
"a",
"JSON",
"result",
"contrary",
"to",
"Dandomains",
"API",
"Errors",
"are",
"formatted",
"as",
"described",
"here",
":",
"http",
":",
"//",
"jsonapi",
".",
"org",
"/",
"format",
"/",
"#errors"
] |
train
|
https://github.com/loevgaard/dandomain-api/blob/cd420d5f92a78eece4201ab57a5f6356537ed371/src/Api.php#L172-L235
|
[
"string",
"string",
"body",
"array"
] |
What does this function return?
|
[
"mixed"
] |
loevgaard/dandomain-api
|
src/Api.php
|
Api.objectToArray
|
protected function objectToArray($obj) : array
{
if ($obj instanceof \stdClass) {
$obj = json_decode(json_encode($obj), true);
}
return (array)$obj;
}
|
php
|
protected function objectToArray($obj) : array
{
if ($obj instanceof \stdClass) {
$obj = json_decode(json_encode($obj), true);
}
return (array)$obj;
}
|
[
"protected",
"function",
"objectToArray",
"(",
"$",
"obj",
")",
":",
"array",
"{",
"if",
"(",
"$",
"obj",
"instanceof",
"\\",
"stdClass",
")",
"{",
"$",
"obj",
"=",
"json_decode",
"(",
"json_encode",
"(",
"$",
"obj",
")",
",",
"true",
")",
";",
"}",
"return",
"(",
"array",
")",
"$",
"obj",
";",
"}"
] |
Helper method to convert a \stdClass into an array
@param $obj
@return array
|
[
"Helper",
"method",
"to",
"convert",
"a",
"\\",
"stdClass",
"into",
"an",
"array"
] |
train
|
https://github.com/loevgaard/dandomain-api/blob/cd420d5f92a78eece4201ab57a5f6356537ed371/src/Api.php#L307-L314
|
[
"obj"
] |
What does this function return?
|
[
"array"
] |
PHPColibri/framework
|
Routing/Route.php
|
Route.parseRequestedFile
|
private static function parseRequestedFile(string $file): array
{
$file = ltrim($file, '/');
$moduleConfig = Config::application('module');
$parts = explode('/', $file);
$partsCnt = count($parts);
if ($partsCnt > 0 && in_array($parts[0], Config::get('divisions'))) {
$_division = $parts[0];
$parts = array_slice($parts, 1);
} else {
$_division = '';
}
$_module = empty($parts[0])
? $moduleConfig['default']
: $parts[0];
$_method = $partsCnt < 2 || empty($parts[1])
? $moduleConfig['defaultViewsControllerAction']
: Str::camel($parts[1]);
$_params = $partsCnt > 2
? array_slice($parts, 2)
: [];
return [$_division, $_module, $_method, $_params];
}
|
php
|
private static function parseRequestedFile(string $file): array
{
$file = ltrim($file, '/');
$moduleConfig = Config::application('module');
$parts = explode('/', $file);
$partsCnt = count($parts);
if ($partsCnt > 0 && in_array($parts[0], Config::get('divisions'))) {
$_division = $parts[0];
$parts = array_slice($parts, 1);
} else {
$_division = '';
}
$_module = empty($parts[0])
? $moduleConfig['default']
: $parts[0];
$_method = $partsCnt < 2 || empty($parts[1])
? $moduleConfig['defaultViewsControllerAction']
: Str::camel($parts[1]);
$_params = $partsCnt > 2
? array_slice($parts, 2)
: [];
return [$_division, $_module, $_method, $_params];
}
|
[
"private",
"static",
"function",
"parseRequestedFile",
"(",
"string",
"$",
"file",
")",
":",
"array",
"{",
"$",
"file",
"=",
"ltrim",
"(",
"$",
"file",
",",
"'/'",
")",
";",
"$",
"moduleConfig",
"=",
"Config",
"::",
"application",
"(",
"'module'",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"file",
")",
";",
"$",
"partsCnt",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"if",
"(",
"$",
"partsCnt",
">",
"0",
"&&",
"in_array",
"(",
"$",
"parts",
"[",
"0",
"]",
",",
"Config",
"::",
"get",
"(",
"'divisions'",
")",
")",
")",
"{",
"$",
"_division",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"parts",
"=",
"array_slice",
"(",
"$",
"parts",
",",
"1",
")",
";",
"}",
"else",
"{",
"$",
"_division",
"=",
"''",
";",
"}",
"$",
"_module",
"=",
"empty",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
"?",
"$",
"moduleConfig",
"[",
"'default'",
"]",
":",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"_method",
"=",
"$",
"partsCnt",
"<",
"2",
"||",
"empty",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
"?",
"$",
"moduleConfig",
"[",
"'defaultViewsControllerAction'",
"]",
":",
"Str",
"::",
"camel",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"$",
"_params",
"=",
"$",
"partsCnt",
">",
"2",
"?",
"array_slice",
"(",
"$",
"parts",
",",
"2",
")",
":",
"[",
"]",
";",
"return",
"[",
"$",
"_division",
",",
"$",
"_module",
",",
"$",
"_method",
",",
"$",
"_params",
"]",
";",
"}"
] |
@param string $file requested file name
@return array
@throws \InvalidArgumentException
|
[
"@param",
"string",
"$file",
"requested",
"file",
"name"
] |
train
|
https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Routing/Route.php#L46-L75
|
[
"string"
] |
What does this function return?
|
[
"array",
"",
"@throws",
"\\InvalidArgumentException"
] |
PHPColibri/framework
|
Routing/Route.php
|
Route.applyRewrites
|
private static function applyRewrites(string $requestedUri, array $rewrites): string
{
foreach ($rewrites as $route) {
$pattern = $route['pattern'];
$replacement = $route['replacement'];
$requestedUri = preg_replace($pattern, $replacement, $requestedUri);
if (isset($route['last'])) {
break;
}
}
return $requestedUri;
}
|
php
|
private static function applyRewrites(string $requestedUri, array $rewrites): string
{
foreach ($rewrites as $route) {
$pattern = $route['pattern'];
$replacement = $route['replacement'];
$requestedUri = preg_replace($pattern, $replacement, $requestedUri);
if (isset($route['last'])) {
break;
}
}
return $requestedUri;
}
|
[
"private",
"static",
"function",
"applyRewrites",
"(",
"string",
"$",
"requestedUri",
",",
"array",
"$",
"rewrites",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"rewrites",
"as",
"$",
"route",
")",
"{",
"$",
"pattern",
"=",
"$",
"route",
"[",
"'pattern'",
"]",
";",
"$",
"replacement",
"=",
"$",
"route",
"[",
"'replacement'",
"]",
";",
"$",
"requestedUri",
"=",
"preg_replace",
"(",
"$",
"pattern",
",",
"$",
"replacement",
",",
"$",
"requestedUri",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"route",
"[",
"'last'",
"]",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"requestedUri",
";",
"}"
] |
@param string $requestedUri
@param array $rewrites
@return string
|
[
"@param",
"string",
"$requestedUri",
"@param",
"array",
"$rewrites"
] |
train
|
https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Routing/Route.php#L83-L96
|
[
"string",
"array"
] |
What does this function return?
|
[
"string"
] |
selikhovleonid/nadir
|
src/core/ViewFactory.php
|
ViewFactory.createView
|
public static function createView($sCtrlName = null, $sActionName)
{
$sViewsRoot = AppHelper::getInstance()->getComponentRoot('views');
$sAddPath = '';
if (!empty($sCtrlName)) {
$sAddPath .= DIRECTORY_SEPARATOR.strtolower($sCtrlName);
}
$sViewFile = $sViewsRoot.$sAddPath.DIRECTORY_SEPARATOR
.strtolower($sActionName).'.php';
if (is_readable($sViewFile)) {
return new View($sViewFile);
}
return null;
}
|
php
|
public static function createView($sCtrlName = null, $sActionName)
{
$sViewsRoot = AppHelper::getInstance()->getComponentRoot('views');
$sAddPath = '';
if (!empty($sCtrlName)) {
$sAddPath .= DIRECTORY_SEPARATOR.strtolower($sCtrlName);
}
$sViewFile = $sViewsRoot.$sAddPath.DIRECTORY_SEPARATOR
.strtolower($sActionName).'.php';
if (is_readable($sViewFile)) {
return new View($sViewFile);
}
return null;
}
|
[
"public",
"static",
"function",
"createView",
"(",
"$",
"sCtrlName",
"=",
"null",
",",
"$",
"sActionName",
")",
"{",
"$",
"sViewsRoot",
"=",
"AppHelper",
"::",
"getInstance",
"(",
")",
"->",
"getComponentRoot",
"(",
"'views'",
")",
";",
"$",
"sAddPath",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sCtrlName",
")",
")",
"{",
"$",
"sAddPath",
".=",
"DIRECTORY_SEPARATOR",
".",
"strtolower",
"(",
"$",
"sCtrlName",
")",
";",
"}",
"$",
"sViewFile",
"=",
"$",
"sViewsRoot",
".",
"$",
"sAddPath",
".",
"DIRECTORY_SEPARATOR",
".",
"strtolower",
"(",
"$",
"sActionName",
")",
".",
"'.php'",
";",
"if",
"(",
"is_readable",
"(",
"$",
"sViewFile",
")",
")",
"{",
"return",
"new",
"View",
"(",
"$",
"sViewFile",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
The method creates a view object assigned with the specific controller and
action in it. If controller name is empty it means a markup file determined
only with action name. It doesn't physically consist into the direcory named
as controller, it's in the root of the view directory.
@param string $sCtrlName|null The controller name (as optional)
@param string $sActionName The action name.
@return \nadir\core\View|null It returns null if view file isn't readable.
|
[
"The",
"method",
"creates",
"a",
"view",
"object",
"assigned",
"with",
"the",
"specific",
"controller",
"and",
"action",
"in",
"it",
".",
"If",
"controller",
"name",
"is",
"empty",
"it",
"means",
"a",
"markup",
"file",
"determined",
"only",
"with",
"action",
"name",
".",
"It",
"doesn",
"t",
"physically",
"consist",
"into",
"the",
"direcory",
"named",
"as",
"controller",
"it",
"s",
"in",
"the",
"root",
"of",
"the",
"view",
"directory",
"."
] |
train
|
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/ViewFactory.php#L29-L42
|
[
"sCtrlName",
"sActionName"
] |
What does this function return?
|
[
"\\nadir\\core\\View|null",
"It",
"returns",
"null",
"if",
"view",
"file",
"isn't",
"readable."
] |
selikhovleonid/nadir
|
src/core/ViewFactory.php
|
ViewFactory.createLayout
|
public static function createLayout($sLayoutName, View $oView)
{
$sLayoutsRoot = AppHelper::getInstance()->getComponentRoot('layouts');
$sLayoutFile = $sLayoutsRoot.DIRECTORY_SEPARATOR
.strtolower($sLayoutName).'.php';
if (is_readable($sLayoutFile)) {
return new Layout($sLayoutFile, $oView);
}
return null;
}
|
php
|
public static function createLayout($sLayoutName, View $oView)
{
$sLayoutsRoot = AppHelper::getInstance()->getComponentRoot('layouts');
$sLayoutFile = $sLayoutsRoot.DIRECTORY_SEPARATOR
.strtolower($sLayoutName).'.php';
if (is_readable($sLayoutFile)) {
return new Layout($sLayoutFile, $oView);
}
return null;
}
|
[
"public",
"static",
"function",
"createLayout",
"(",
"$",
"sLayoutName",
",",
"View",
"$",
"oView",
")",
"{",
"$",
"sLayoutsRoot",
"=",
"AppHelper",
"::",
"getInstance",
"(",
")",
"->",
"getComponentRoot",
"(",
"'layouts'",
")",
";",
"$",
"sLayoutFile",
"=",
"$",
"sLayoutsRoot",
".",
"DIRECTORY_SEPARATOR",
".",
"strtolower",
"(",
"$",
"sLayoutName",
")",
".",
"'.php'",
";",
"if",
"(",
"is_readable",
"(",
"$",
"sLayoutFile",
")",
")",
"{",
"return",
"new",
"Layout",
"(",
"$",
"sLayoutFile",
",",
"$",
"oView",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
It creates a layout object.
@param type $sLayoutName The layout name.
@param \nadir\core\View $oView The object of view.
@return \nadir\core\Layout|null
|
[
"It",
"creates",
"a",
"layout",
"object",
"."
] |
train
|
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/ViewFactory.php#L50-L59
|
[
"sLayoutName",
"View"
] |
What does this function return?
|
[
"\\nadir\\core\\Layout|null"
] |
selikhovleonid/nadir
|
src/core/ViewFactory.php
|
ViewFactory.createSnippet
|
public static function createSnippet($sSnptName)
{
$sSnptRoot = AppHelper::getInstance()->getComponentRoot('snippets');
$SnptFile = $sSnptRoot.DIRECTORY_SEPARATOR
.strtolower($sSnptName).'.php';
if (is_readable($SnptFile)) {
return new Snippet($SnptFile);
}
return null;
}
|
php
|
public static function createSnippet($sSnptName)
{
$sSnptRoot = AppHelper::getInstance()->getComponentRoot('snippets');
$SnptFile = $sSnptRoot.DIRECTORY_SEPARATOR
.strtolower($sSnptName).'.php';
if (is_readable($SnptFile)) {
return new Snippet($SnptFile);
}
return null;
}
|
[
"public",
"static",
"function",
"createSnippet",
"(",
"$",
"sSnptName",
")",
"{",
"$",
"sSnptRoot",
"=",
"AppHelper",
"::",
"getInstance",
"(",
")",
"->",
"getComponentRoot",
"(",
"'snippets'",
")",
";",
"$",
"SnptFile",
"=",
"$",
"sSnptRoot",
".",
"DIRECTORY_SEPARATOR",
".",
"strtolower",
"(",
"$",
"sSnptName",
")",
".",
"'.php'",
";",
"if",
"(",
"is_readable",
"(",
"$",
"SnptFile",
")",
")",
"{",
"return",
"new",
"Snippet",
"(",
"$",
"SnptFile",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
The method creates a snippet-object.
@param type $sSnptName The snippet name.
@return \nadir\core\Snippet|null.
|
[
"The",
"method",
"creates",
"a",
"snippet",
"-",
"object",
"."
] |
train
|
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/ViewFactory.php#L66-L75
|
[
"sSnptName"
] |
What does this function return?
|
[
"\\nadir\\core\\Snippet|null."
] |
fxpio/fxp-gluon
|
Twig/Extension/GoogleFontsExtension.php
|
GoogleFontsExtension.addStylesheetGoogleFonts
|
public function addStylesheetGoogleFonts()
{
$str = '';
foreach ($this->fonts as $url) {
$str .= sprintf('<link href="%s" rel="stylesheet">', $url);
}
return $str;
}
|
php
|
public function addStylesheetGoogleFonts()
{
$str = '';
foreach ($this->fonts as $url) {
$str .= sprintf('<link href="%s" rel="stylesheet">', $url);
}
return $str;
}
|
[
"public",
"function",
"addStylesheetGoogleFonts",
"(",
")",
"{",
"$",
"str",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"fonts",
"as",
"$",
"url",
")",
"{",
"$",
"str",
".=",
"sprintf",
"(",
"'<link href=\"%s\" rel=\"stylesheet\">'",
",",
"$",
"url",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Build the stylesheet links of google fonts.
@return string
|
[
"Build",
"the",
"stylesheet",
"links",
"of",
"google",
"fonts",
"."
] |
train
|
https://github.com/fxpio/fxp-gluon/blob/0548b7d598ef4b0785b5df3b849a10f439b2dc65/Twig/Extension/GoogleFontsExtension.php#L51-L60
|
[] |
What does this function return?
|
[
"string"
] |
alex-oleshkevich/classnames
|
src/ClassNames.php
|
ClassNames.parse
|
public function parse($filename)
{
$tokens = token_get_all(file_get_contents($filename));
$classNames = [];
$interfaceNames = [];
$traitNames = [];
$namespace = [];
$curleys = 0;
$isInNamespace = false;
$totalTokens = count($tokens);
for ($i = 0; $i <= $totalTokens; $i++) {
if (!isset($tokens[$i])) {
break;
}
$token = $tokens[$i];
if (is_string($token)) {
if (in_array($token[0], ['{'])) {
$curleys++;
}
if (in_array($token[0], ['}'])) {
$curleys--;
}
$token = [0 => $token];
}
// iterate until space to get FQ NS name.
if ($token[0] == T_NAMESPACE) {
$namespace = [];
$i = $i + 2;
for (; $i <= $totalTokens; $i++) {
if (!isset($tokens[$i])) {
break;
}
$token = $tokens[$i];
if ($token[0] == T_STRING) {
$namespace[] = $token[1];
}
if ($token[0] == ';') {
$isInNamespace = true;
break;
}
if ($token[0] == '{') {
$curleys++;
break;
}
if ($token[0] == '{') {
$curleys--;
}
}
}
if ($token[0] == T_CLASS) {
$prevToken = $tokens[$i - 1];
if (is_array($prevToken) && $prevToken[0] == T_DOUBLE_COLON) {
continue;
}
$i = $i + 2;
for (; $i <= count($tokens); $i++) {
$token = $tokens[$i];
if ($token[0] == T_STRING) {
if ($curleys == 0 && !$isInNamespace) {
$namespace = [];
}
$classParts = array_merge($namespace, [$token[1]]);
$classNames[] = join('\\', $classParts);
break;
}
}
}
if ($token[0] == T_INTERFACE) {
$i = $i + 2;
for (; $i <= count($tokens); $i++) {
$token = $tokens[$i];
if ($token[0] == T_STRING) {
if ($curleys == 0 && !$isInNamespace) {
$namespace = [];
}
$interfaceParts = array_merge($namespace, [$token[1]]);
$interfaceNames[] = join('\\', $interfaceParts);
break;
}
}
}
if ($token[0] == T_TRAIT) {
$i = $i + 2;
for (; $i <= count($tokens); $i++) {
$token = $tokens[$i];
if ($token[0] == T_STRING) {
if ($curleys == 0 && !$isInNamespace) {
$namespace = [];
}
$traitParts = array_merge($namespace, [$token[1]]);
$traitNames[] = join('\\', $traitParts);
break;
}
}
}
}
return [
'classes' => $classNames,
'interfaces' => $interfaceNames,
'traits' => $traitNames
];
}
|
php
|
public function parse($filename)
{
$tokens = token_get_all(file_get_contents($filename));
$classNames = [];
$interfaceNames = [];
$traitNames = [];
$namespace = [];
$curleys = 0;
$isInNamespace = false;
$totalTokens = count($tokens);
for ($i = 0; $i <= $totalTokens; $i++) {
if (!isset($tokens[$i])) {
break;
}
$token = $tokens[$i];
if (is_string($token)) {
if (in_array($token[0], ['{'])) {
$curleys++;
}
if (in_array($token[0], ['}'])) {
$curleys--;
}
$token = [0 => $token];
}
// iterate until space to get FQ NS name.
if ($token[0] == T_NAMESPACE) {
$namespace = [];
$i = $i + 2;
for (; $i <= $totalTokens; $i++) {
if (!isset($tokens[$i])) {
break;
}
$token = $tokens[$i];
if ($token[0] == T_STRING) {
$namespace[] = $token[1];
}
if ($token[0] == ';') {
$isInNamespace = true;
break;
}
if ($token[0] == '{') {
$curleys++;
break;
}
if ($token[0] == '{') {
$curleys--;
}
}
}
if ($token[0] == T_CLASS) {
$prevToken = $tokens[$i - 1];
if (is_array($prevToken) && $prevToken[0] == T_DOUBLE_COLON) {
continue;
}
$i = $i + 2;
for (; $i <= count($tokens); $i++) {
$token = $tokens[$i];
if ($token[0] == T_STRING) {
if ($curleys == 0 && !$isInNamespace) {
$namespace = [];
}
$classParts = array_merge($namespace, [$token[1]]);
$classNames[] = join('\\', $classParts);
break;
}
}
}
if ($token[0] == T_INTERFACE) {
$i = $i + 2;
for (; $i <= count($tokens); $i++) {
$token = $tokens[$i];
if ($token[0] == T_STRING) {
if ($curleys == 0 && !$isInNamespace) {
$namespace = [];
}
$interfaceParts = array_merge($namespace, [$token[1]]);
$interfaceNames[] = join('\\', $interfaceParts);
break;
}
}
}
if ($token[0] == T_TRAIT) {
$i = $i + 2;
for (; $i <= count($tokens); $i++) {
$token = $tokens[$i];
if ($token[0] == T_STRING) {
if ($curleys == 0 && !$isInNamespace) {
$namespace = [];
}
$traitParts = array_merge($namespace, [$token[1]]);
$traitNames[] = join('\\', $traitParts);
break;
}
}
}
}
return [
'classes' => $classNames,
'interfaces' => $interfaceNames,
'traits' => $traitNames
];
}
|
[
"public",
"function",
"parse",
"(",
"$",
"filename",
")",
"{",
"$",
"tokens",
"=",
"token_get_all",
"(",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
";",
"$",
"classNames",
"=",
"[",
"]",
";",
"$",
"interfaceNames",
"=",
"[",
"]",
";",
"$",
"traitNames",
"=",
"[",
"]",
";",
"$",
"namespace",
"=",
"[",
"]",
";",
"$",
"curleys",
"=",
"0",
";",
"$",
"isInNamespace",
"=",
"false",
";",
"$",
"totalTokens",
"=",
"count",
"(",
"$",
"tokens",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"$",
"totalTokens",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
")",
")",
"{",
"break",
";",
"}",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"is_string",
"(",
"$",
"token",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"token",
"[",
"0",
"]",
",",
"[",
"'{'",
"]",
")",
")",
"{",
"$",
"curleys",
"++",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"token",
"[",
"0",
"]",
",",
"[",
"'}'",
"]",
")",
")",
"{",
"$",
"curleys",
"--",
";",
"}",
"$",
"token",
"=",
"[",
"0",
"=>",
"$",
"token",
"]",
";",
"}",
"// iterate until space to get FQ NS name.",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_NAMESPACE",
")",
"{",
"$",
"namespace",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"$",
"i",
"+",
"2",
";",
"for",
"(",
";",
"$",
"i",
"<=",
"$",
"totalTokens",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
")",
")",
"{",
"break",
";",
"}",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_STRING",
")",
"{",
"$",
"namespace",
"[",
"]",
"=",
"$",
"token",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"';'",
")",
"{",
"$",
"isInNamespace",
"=",
"true",
";",
"break",
";",
"}",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"'{'",
")",
"{",
"$",
"curleys",
"++",
";",
"break",
";",
"}",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"'{'",
")",
"{",
"$",
"curleys",
"--",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_CLASS",
")",
"{",
"$",
"prevToken",
"=",
"$",
"tokens",
"[",
"$",
"i",
"-",
"1",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"prevToken",
")",
"&&",
"$",
"prevToken",
"[",
"0",
"]",
"==",
"T_DOUBLE_COLON",
")",
"{",
"continue",
";",
"}",
"$",
"i",
"=",
"$",
"i",
"+",
"2",
";",
"for",
"(",
";",
"$",
"i",
"<=",
"count",
"(",
"$",
"tokens",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_STRING",
")",
"{",
"if",
"(",
"$",
"curleys",
"==",
"0",
"&&",
"!",
"$",
"isInNamespace",
")",
"{",
"$",
"namespace",
"=",
"[",
"]",
";",
"}",
"$",
"classParts",
"=",
"array_merge",
"(",
"$",
"namespace",
",",
"[",
"$",
"token",
"[",
"1",
"]",
"]",
")",
";",
"$",
"classNames",
"[",
"]",
"=",
"join",
"(",
"'\\\\'",
",",
"$",
"classParts",
")",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_INTERFACE",
")",
"{",
"$",
"i",
"=",
"$",
"i",
"+",
"2",
";",
"for",
"(",
";",
"$",
"i",
"<=",
"count",
"(",
"$",
"tokens",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_STRING",
")",
"{",
"if",
"(",
"$",
"curleys",
"==",
"0",
"&&",
"!",
"$",
"isInNamespace",
")",
"{",
"$",
"namespace",
"=",
"[",
"]",
";",
"}",
"$",
"interfaceParts",
"=",
"array_merge",
"(",
"$",
"namespace",
",",
"[",
"$",
"token",
"[",
"1",
"]",
"]",
")",
";",
"$",
"interfaceNames",
"[",
"]",
"=",
"join",
"(",
"'\\\\'",
",",
"$",
"interfaceParts",
")",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_TRAIT",
")",
"{",
"$",
"i",
"=",
"$",
"i",
"+",
"2",
";",
"for",
"(",
";",
"$",
"i",
"<=",
"count",
"(",
"$",
"tokens",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"token",
"[",
"0",
"]",
"==",
"T_STRING",
")",
"{",
"if",
"(",
"$",
"curleys",
"==",
"0",
"&&",
"!",
"$",
"isInNamespace",
")",
"{",
"$",
"namespace",
"=",
"[",
"]",
";",
"}",
"$",
"traitParts",
"=",
"array_merge",
"(",
"$",
"namespace",
",",
"[",
"$",
"token",
"[",
"1",
"]",
"]",
")",
";",
"$",
"traitNames",
"[",
"]",
"=",
"join",
"(",
"'\\\\'",
",",
"$",
"traitParts",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"[",
"'classes'",
"=>",
"$",
"classNames",
",",
"'interfaces'",
"=>",
"$",
"interfaceNames",
",",
"'traits'",
"=>",
"$",
"traitNames",
"]",
";",
"}"
] |
Parse .php file.
@param string $filename
@return array
|
[
"Parse",
".",
"php",
"file",
"."
] |
train
|
https://github.com/alex-oleshkevich/classnames/blob/2640603475cb5c95945920e4466561c3e30d6676/src/ClassNames.php#L23-L136
|
[
"filename"
] |
What does this function return?
|
[
"array"
] |
IftekherSunny/Planet-Framework
|
src/Sun/Console/Commands/AppName.php
|
AppName.setBootstrapNamespace
|
private function setBootstrapNamespace($oldNamespace, $newNamespace)
{
$files = $this->filesystem->files(base_path() . '/bootstrap');
foreach ($files as $file) {
$content = $this->filesystem->get($file);
$this->filesystem->create($file, str_replace($oldNamespace . '\Controllers', $newNamespace . '\Controllers', $content));
}
}
|
php
|
private function setBootstrapNamespace($oldNamespace, $newNamespace)
{
$files = $this->filesystem->files(base_path() . '/bootstrap');
foreach ($files as $file) {
$content = $this->filesystem->get($file);
$this->filesystem->create($file, str_replace($oldNamespace . '\Controllers', $newNamespace . '\Controllers', $content));
}
}
|
[
"private",
"function",
"setBootstrapNamespace",
"(",
"$",
"oldNamespace",
",",
"$",
"newNamespace",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"files",
"(",
"base_path",
"(",
")",
".",
"'/bootstrap'",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"get",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"create",
"(",
"$",
"file",
",",
"str_replace",
"(",
"$",
"oldNamespace",
".",
"'\\Controllers'",
",",
"$",
"newNamespace",
".",
"'\\Controllers'",
",",
"$",
"content",
")",
")",
";",
"}",
"}"
] |
To set bootstrap file namespace
@param $oldNamespace
@param $newNamespace
@return array
|
[
"To",
"set",
"bootstrap",
"file",
"namespace"
] |
train
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Console/Commands/AppName.php#L106-L114
|
[
"oldNamespace",
"newNamespace"
] |
What does this function return?
|
[
"array"
] |
IftekherSunny/Planet-Framework
|
src/Sun/Console/Commands/AppName.php
|
AppName.setConfigNamespace
|
private function setConfigNamespace($oldNamespace, $newNamespace)
{
$files = $this->filesystem->files(base_path() . '/config');
foreach ($files as $file) {
$content = $this->filesystem->get($file);
$this->filesystem->create($file, preg_replace("/\\b" . $oldNamespace . "\\b/", $newNamespace, $content));
}
}
|
php
|
private function setConfigNamespace($oldNamespace, $newNamespace)
{
$files = $this->filesystem->files(base_path() . '/config');
foreach ($files as $file) {
$content = $this->filesystem->get($file);
$this->filesystem->create($file, preg_replace("/\\b" . $oldNamespace . "\\b/", $newNamespace, $content));
}
}
|
[
"private",
"function",
"setConfigNamespace",
"(",
"$",
"oldNamespace",
",",
"$",
"newNamespace",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"files",
"(",
"base_path",
"(",
")",
".",
"'/config'",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"get",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"create",
"(",
"$",
"file",
",",
"preg_replace",
"(",
"\"/\\\\b\"",
".",
"$",
"oldNamespace",
".",
"\"\\\\b/\"",
",",
"$",
"newNamespace",
",",
"$",
"content",
")",
")",
";",
"}",
"}"
] |
To set config directory files namespace
@param $oldNamespace
@param $newNamespace
@return array
|
[
"To",
"set",
"config",
"directory",
"files",
"namespace"
] |
train
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Console/Commands/AppName.php#L124-L132
|
[
"oldNamespace",
"newNamespace"
] |
What does this function return?
|
[
"array"
] |
chilimatic/chilimatic-framework
|
lib/request/CLI.php
|
CLI._transform
|
public function _transform(array $array = null)
{
if (empty($array)) return;
foreach ($array as $param) {
if (strpos($param, '=') > 0) {
$tmp = explode(Generic::ASSIGNMENT_OPERATOR, $param);
$this->$tmp[0] = $tmp[1];
}
}
return;
}
|
php
|
public function _transform(array $array = null)
{
if (empty($array)) return;
foreach ($array as $param) {
if (strpos($param, '=') > 0) {
$tmp = explode(Generic::ASSIGNMENT_OPERATOR, $param);
$this->$tmp[0] = $tmp[1];
}
}
return;
}
|
[
"public",
"function",
"_transform",
"(",
"array",
"$",
"array",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"array",
")",
")",
"return",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"param",
",",
"'='",
")",
">",
"0",
")",
"{",
"$",
"tmp",
"=",
"explode",
"(",
"Generic",
"::",
"ASSIGNMENT_OPERATOR",
",",
"$",
"param",
")",
";",
"$",
"this",
"->",
"$",
"tmp",
"[",
"0",
"]",
"=",
"$",
"tmp",
"[",
"1",
"]",
";",
"}",
"}",
"return",
";",
"}"
] |
adapted "transform" method for the argv we
need a different approach ofc
@param array $array
@return void
|
[
"adapted",
"transform",
"method",
"for",
"the",
"argv",
"we",
"need",
"a",
"different",
"approach",
"ofc"
] |
train
|
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/request/CLI.php#L72-L85
|
[
"array"
] |
What does this function return?
|
[
"void"
] |
bruno-barros/w.eloquent-framework
|
src/weloquent/Core/Console/WelConsole.php
|
WelConsole.make
|
public static function make($app)
{
$app->boot();
$console = with($console = new static('WEL. A w.eloquent console by artisan.', $app::VERSION))
->setLaravel($app)
->setExceptionHandler($app['exception'])
->setAutoExit(false);
$app->instance('artisan', $console);
return $console;
}
|
php
|
public static function make($app)
{
$app->boot();
$console = with($console = new static('WEL. A w.eloquent console by artisan.', $app::VERSION))
->setLaravel($app)
->setExceptionHandler($app['exception'])
->setAutoExit(false);
$app->instance('artisan', $console);
return $console;
}
|
[
"public",
"static",
"function",
"make",
"(",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"boot",
"(",
")",
";",
"$",
"console",
"=",
"with",
"(",
"$",
"console",
"=",
"new",
"static",
"(",
"'WEL. A w.eloquent console by artisan.'",
",",
"$",
"app",
"::",
"VERSION",
")",
")",
"->",
"setLaravel",
"(",
"$",
"app",
")",
"->",
"setExceptionHandler",
"(",
"$",
"app",
"[",
"'exception'",
"]",
")",
"->",
"setAutoExit",
"(",
"false",
")",
";",
"$",
"app",
"->",
"instance",
"(",
"'artisan'",
",",
"$",
"console",
")",
";",
"return",
"$",
"console",
";",
"}"
] |
Create a new Console application.
@param \Weloquent\Core\Application $app
@return \Illuminate\Console\Application
|
[
"Create",
"a",
"new",
"Console",
"application",
"."
] |
train
|
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Core/Console/WelConsole.php#L20-L32
|
[
"app"
] |
What does this function return?
|
[
"\\Illuminate\\Console\\Application"
] |
bruno-barros/w.eloquent-framework
|
src/weloquent/Core/Console/WelConsole.php
|
WelConsole.boot
|
public function boot()
{
$path = $this->laravel['path'].'/config/wel.php';
if (file_exists($path))
{
require $path;
}
// If the event dispatcher is set on the application, we will fire an event
// with the Artisan instance to provide each listener the opportunity to
// register their commands on this application before it gets started.
if (isset($this->laravel['events']))
{
$this->laravel['events']
->fire('artisan.start', array($this));
}
return $this;
}
|
php
|
public function boot()
{
$path = $this->laravel['path'].'/config/wel.php';
if (file_exists($path))
{
require $path;
}
// If the event dispatcher is set on the application, we will fire an event
// with the Artisan instance to provide each listener the opportunity to
// register their commands on this application before it gets started.
if (isset($this->laravel['events']))
{
$this->laravel['events']
->fire('artisan.start', array($this));
}
return $this;
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'path'",
"]",
".",
"'/config/wel.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"require",
"$",
"path",
";",
"}",
"// If the event dispatcher is set on the application, we will fire an event",
"// with the Artisan instance to provide each listener the opportunity to",
"// register their commands on this application before it gets started.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"laravel",
"[",
"'events'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"laravel",
"[",
"'events'",
"]",
"->",
"fire",
"(",
"'artisan.start'",
",",
"array",
"(",
"$",
"this",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Boot the Console application.
@return $this
|
[
"Boot",
"the",
"Console",
"application",
"."
] |
train
|
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Core/Console/WelConsole.php#L39-L58
|
[] |
What does this function return?
|
[
"$this"
] |
Napp/aclcore
|
src/Role/HasRole.php
|
HasRole.getMergedPermissions
|
public function getMergedPermissions(): array
{
$permissions = [];
foreach ($this->getRoles() as $role) {
$permissions = \array_merge($permissions, $role->getPermissions() ?? []);
}
// merge with users own permissions
return \array_merge($permissions, $this->getPermissions());
}
|
php
|
public function getMergedPermissions(): array
{
$permissions = [];
foreach ($this->getRoles() as $role) {
$permissions = \array_merge($permissions, $role->getPermissions() ?? []);
}
// merge with users own permissions
return \array_merge($permissions, $this->getPermissions());
}
|
[
"public",
"function",
"getMergedPermissions",
"(",
")",
":",
"array",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRoles",
"(",
")",
"as",
"$",
"role",
")",
"{",
"$",
"permissions",
"=",
"\\",
"array_merge",
"(",
"$",
"permissions",
",",
"$",
"role",
"->",
"getPermissions",
"(",
")",
"??",
"[",
"]",
")",
";",
"}",
"// merge with users own permissions",
"return",
"\\",
"array_merge",
"(",
"$",
"permissions",
",",
"$",
"this",
"->",
"getPermissions",
"(",
")",
")",
";",
"}"
] |
Returns an array of merged permissions for each group the user is in.
@return array
|
[
"Returns",
"an",
"array",
"of",
"merged",
"permissions",
"for",
"each",
"group",
"the",
"user",
"is",
"in",
"."
] |
train
|
https://github.com/Napp/aclcore/blob/9f2f48fe0af4c50ed7cbbafe653761da42e39596/src/Role/HasRole.php#L71-L80
|
[] |
What does this function return?
|
[
"array"
] |
danhanly/signalert
|
src/Signalert/Renderer/FoundationRenderer.php
|
FoundationRenderer.render
|
public function render(array $notifications, $type = 'info')
{
// Ensure Type is Supported
if (in_array($type, $this->supportedTypes) === false) {
// If not, fall back to default
$type = 'info';
}
// If there aren't any notifications, then return an empty string
if (empty($notifications) === true) {
return '';
}
$html = $this->createHtmlByType($notifications, $type);
return $html;
}
|
php
|
public function render(array $notifications, $type = 'info')
{
// Ensure Type is Supported
if (in_array($type, $this->supportedTypes) === false) {
// If not, fall back to default
$type = 'info';
}
// If there aren't any notifications, then return an empty string
if (empty($notifications) === true) {
return '';
}
$html = $this->createHtmlByType($notifications, $type);
return $html;
}
|
[
"public",
"function",
"render",
"(",
"array",
"$",
"notifications",
",",
"$",
"type",
"=",
"'info'",
")",
"{",
"// Ensure Type is Supported",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"supportedTypes",
")",
"===",
"false",
")",
"{",
"// If not, fall back to default",
"$",
"type",
"=",
"'info'",
";",
"}",
"// If there aren't any notifications, then return an empty string",
"if",
"(",
"empty",
"(",
"$",
"notifications",
")",
"===",
"true",
")",
"{",
"return",
"''",
";",
"}",
"$",
"html",
"=",
"$",
"this",
"->",
"createHtmlByType",
"(",
"$",
"notifications",
",",
"$",
"type",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Renders all messages as part of the notification stack, beneath the defined identifier, as HTML
@param array $notifications
@param string $type
@return string|void
|
[
"Renders",
"all",
"messages",
"as",
"part",
"of",
"the",
"notification",
"stack",
"beneath",
"the",
"defined",
"identifier",
"as",
"HTML"
] |
train
|
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Renderer/FoundationRenderer.php#L23-L38
|
[
"array",
"type"
] |
What does this function return?
|
[
"string|void"
] |
danhanly/signalert
|
src/Signalert/Renderer/FoundationRenderer.php
|
FoundationRenderer.createHtmlByType
|
private function createHtmlByType(array $notifications, $type)
{
$html = "<div class='alert-box {$type} radius' data-alert>";
foreach ($notifications as $notification) {
$html .= "{$notification}";
// If it's not the last notification, add a line break for the next one
if (end($notifications) !== $notification) {
$html .= "<br />";
}
}
$html .= "<a href='#' class='close'>×</a>";
$html .= "</div>";
return $html;
}
|
php
|
private function createHtmlByType(array $notifications, $type)
{
$html = "<div class='alert-box {$type} radius' data-alert>";
foreach ($notifications as $notification) {
$html .= "{$notification}";
// If it's not the last notification, add a line break for the next one
if (end($notifications) !== $notification) {
$html .= "<br />";
}
}
$html .= "<a href='#' class='close'>×</a>";
$html .= "</div>";
return $html;
}
|
[
"private",
"function",
"createHtmlByType",
"(",
"array",
"$",
"notifications",
",",
"$",
"type",
")",
"{",
"$",
"html",
"=",
"\"<div class='alert-box {$type} radius' data-alert>\"",
";",
"foreach",
"(",
"$",
"notifications",
"as",
"$",
"notification",
")",
"{",
"$",
"html",
".=",
"\"{$notification}\"",
";",
"// If it's not the last notification, add a line break for the next one",
"if",
"(",
"end",
"(",
"$",
"notifications",
")",
"!==",
"$",
"notification",
")",
"{",
"$",
"html",
".=",
"\"<br />\"",
";",
"}",
"}",
"$",
"html",
".=",
"\"<a href='#' class='close'>×</a>\"",
";",
"$",
"html",
".=",
"\"</div>\"",
";",
"return",
"$",
"html",
";",
"}"
] |
Create and return html string.
@param array $notifications
@param string $type
@return string
|
[
"Create",
"and",
"return",
"html",
"string",
"."
] |
train
|
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Renderer/FoundationRenderer.php#L47-L61
|
[
"array",
"type"
] |
What does this function return?
|
[
"string"
] |
RadialCorp/magento-core
|
src/app/code/community/Radial/Order/Model/Observer.php
|
Radial_Order_Model_Observer.handleSalesConvertQuoteItemToOrderItem
|
public function handleSalesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
{
$quote = $observer->getEvent()->getQuote();
$orderC = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('quote_id', array('eq' => $quote->getId()))->getAllIds();
foreach( $quote->getAllItems() as $quoteItem )
{
$itemC = Mage::getModel('sales/order_item')->getCollection()
->addFieldToFilter('product_id', array('eq' => $quoteItem->getProductId()))
->addFieldToFilter('order_id', array('in' => $orderC));
if( $itemC->getSize() > 0 )
{
$discountData = $quoteItem->getData('ebayenterprise_order_discount_data');
if($discountData)
{
foreach( $itemC as $item )
{
$item->setData('ebayenterprise_order_discount_data', $discountData);
$item->save();
}
}
}
}
}
|
php
|
public function handleSalesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
{
$quote = $observer->getEvent()->getQuote();
$orderC = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('quote_id', array('eq' => $quote->getId()))->getAllIds();
foreach( $quote->getAllItems() as $quoteItem )
{
$itemC = Mage::getModel('sales/order_item')->getCollection()
->addFieldToFilter('product_id', array('eq' => $quoteItem->getProductId()))
->addFieldToFilter('order_id', array('in' => $orderC));
if( $itemC->getSize() > 0 )
{
$discountData = $quoteItem->getData('ebayenterprise_order_discount_data');
if($discountData)
{
foreach( $itemC as $item )
{
$item->setData('ebayenterprise_order_discount_data', $discountData);
$item->save();
}
}
}
}
}
|
[
"public",
"function",
"handleSalesConvertQuoteItemToOrderItem",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"$",
"quote",
"=",
"$",
"observer",
"->",
"getEvent",
"(",
")",
"->",
"getQuote",
"(",
")",
";",
"$",
"orderC",
"=",
"Mage",
"::",
"getModel",
"(",
"'sales/order'",
")",
"->",
"getCollection",
"(",
")",
"->",
"addFieldToFilter",
"(",
"'quote_id'",
",",
"array",
"(",
"'eq'",
"=>",
"$",
"quote",
"->",
"getId",
"(",
")",
")",
")",
"->",
"getAllIds",
"(",
")",
";",
"foreach",
"(",
"$",
"quote",
"->",
"getAllItems",
"(",
")",
"as",
"$",
"quoteItem",
")",
"{",
"$",
"itemC",
"=",
"Mage",
"::",
"getModel",
"(",
"'sales/order_item'",
")",
"->",
"getCollection",
"(",
")",
"->",
"addFieldToFilter",
"(",
"'product_id'",
",",
"array",
"(",
"'eq'",
"=>",
"$",
"quoteItem",
"->",
"getProductId",
"(",
")",
")",
")",
"->",
"addFieldToFilter",
"(",
"'order_id'",
",",
"array",
"(",
"'in'",
"=>",
"$",
"orderC",
")",
")",
";",
"if",
"(",
"$",
"itemC",
"->",
"getSize",
"(",
")",
">",
"0",
")",
"{",
"$",
"discountData",
"=",
"$",
"quoteItem",
"->",
"getData",
"(",
"'ebayenterprise_order_discount_data'",
")",
";",
"if",
"(",
"$",
"discountData",
")",
"{",
"foreach",
"(",
"$",
"itemC",
"as",
"$",
"item",
")",
"{",
"$",
"item",
"->",
"setData",
"(",
"'ebayenterprise_order_discount_data'",
",",
"$",
"discountData",
")",
";",
"$",
"item",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Copy discount data from Quote Item to Order Item (when quote converts to order)
@param Varien_Event_Observer
@return self
|
[
"Copy",
"discount",
"data",
"from",
"Quote",
"Item",
"to",
"Order",
"Item",
"(",
"when",
"quote",
"converts",
"to",
"order",
")"
] |
train
|
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Order/Model/Observer.php#L48-L74
|
[
"Varien_Event_Observer"
] |
What does this function return?
|
[
"self"
] |
schpill/thin
|
src/Mock.php
|
Mock.resolveFacadeInstance
|
protected static function resolveFacadeInstance($name)
{
if (is_object($name)) {
return $name;
}
if (isset(static::$resolvedInstance[$name])) {
return static::$resolvedInstance[$name];
}
return false;
}
|
php
|
protected static function resolveFacadeInstance($name)
{
if (is_object($name)) {
return $name;
}
if (isset(static::$resolvedInstance[$name])) {
return static::$resolvedInstance[$name];
}
return false;
}
|
[
"protected",
"static",
"function",
"resolveFacadeInstance",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"name",
";",
"}",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"resolvedInstance",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"static",
"::",
"$",
"resolvedInstance",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"false",
";",
"}"
] |
Resolve the facade root instance from the container.
@param string $name
@return mixed
|
[
"Resolve",
"the",
"facade",
"root",
"instance",
"from",
"the",
"container",
"."
] |
train
|
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Mock.php#L125-L136
|
[
"name"
] |
What does this function return?
|
[
"mixed"
] |
zhenggg/easy-ihuyi
|
src/HasHttpRequest.php
|
HasHttpRequest.getBaseOptions
|
protected function getBaseOptions()
{
$options = [
'base_uri' => method_exists($this, 'getBaseUri') ? $this->getBaseUri() : '',
'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0,
];
return $options;
}
|
php
|
protected function getBaseOptions()
{
$options = [
'base_uri' => method_exists($this, 'getBaseUri') ? $this->getBaseUri() : '',
'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0,
];
return $options;
}
|
[
"protected",
"function",
"getBaseOptions",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"'base_uri'",
"=>",
"method_exists",
"(",
"$",
"this",
",",
"'getBaseUri'",
")",
"?",
"$",
"this",
"->",
"getBaseUri",
"(",
")",
":",
"''",
",",
"'timeout'",
"=>",
"property_exists",
"(",
"$",
"this",
",",
"'timeout'",
")",
"?",
"$",
"this",
"->",
"timeout",
":",
"5.0",
",",
"]",
";",
"return",
"$",
"options",
";",
"}"
] |
Return base Guzzle options.
@return array
|
[
"Return",
"base",
"Guzzle",
"options",
"."
] |
train
|
https://github.com/zhenggg/easy-ihuyi/blob/90ff0da31de3974e2a7b6e59f76f8f1ccec06aca/src/HasHttpRequest.php#L73-L81
|
[] |
What does this function return?
|
[
"array"
] |
IftekherSunny/Planet-Framework
|
src/Sun/Support/Str.php
|
Str.random
|
public static function random($size = 32)
{
$bytes = openssl_random_pseudo_bytes($size, $strong);
if ($bytes !== false && $strong !== false) {
$string = '';
while (($len = strlen($string)) < $size) {
$length = $size - $len;
$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $length);
}
return $string;
}
}
|
php
|
public static function random($size = 32)
{
$bytes = openssl_random_pseudo_bytes($size, $strong);
if ($bytes !== false && $strong !== false) {
$string = '';
while (($len = strlen($string)) < $size) {
$length = $size - $len;
$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $length);
}
return $string;
}
}
|
[
"public",
"static",
"function",
"random",
"(",
"$",
"size",
"=",
"32",
")",
"{",
"$",
"bytes",
"=",
"openssl_random_pseudo_bytes",
"(",
"$",
"size",
",",
"$",
"strong",
")",
";",
"if",
"(",
"$",
"bytes",
"!==",
"false",
"&&",
"$",
"strong",
"!==",
"false",
")",
"{",
"$",
"string",
"=",
"''",
";",
"while",
"(",
"(",
"$",
"len",
"=",
"strlen",
"(",
"$",
"string",
")",
")",
"<",
"$",
"size",
")",
"{",
"$",
"length",
"=",
"$",
"size",
"-",
"$",
"len",
";",
"$",
"string",
".=",
"substr",
"(",
"str_replace",
"(",
"[",
"'/'",
",",
"'+'",
",",
"'='",
"]",
",",
"''",
",",
"base64_encode",
"(",
"$",
"bytes",
")",
")",
",",
"0",
",",
"$",
"length",
")",
";",
"}",
"return",
"$",
"string",
";",
"}",
"}"
] |
To generate random string
@param int $size
@return string
|
[
"To",
"generate",
"random",
"string"
] |
train
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Support/Str.php#L14-L28
|
[
"size"
] |
What does this function return?
|
[
"string"
] |
syzygypl/remote-media-bundle
|
src/MediaHandler/RemoteImageHandler.php
|
RemoteImageHandler.getImageUrl
|
public function getImageUrl(Media $media, $basepath)
{
if ($media->getUrl() === parse_url($media->getUrl(), PHP_URL_PATH)) {
return $basepath . $media->getUrl();
}
return $media->getUrl();
}
|
php
|
public function getImageUrl(Media $media, $basepath)
{
if ($media->getUrl() === parse_url($media->getUrl(), PHP_URL_PATH)) {
return $basepath . $media->getUrl();
}
return $media->getUrl();
}
|
[
"public",
"function",
"getImageUrl",
"(",
"Media",
"$",
"media",
",",
"$",
"basepath",
")",
"{",
"if",
"(",
"$",
"media",
"->",
"getUrl",
"(",
")",
"===",
"parse_url",
"(",
"$",
"media",
"->",
"getUrl",
"(",
")",
",",
"PHP_URL_PATH",
")",
")",
"{",
"return",
"$",
"basepath",
".",
"$",
"media",
"->",
"getUrl",
"(",
")",
";",
"}",
"return",
"$",
"media",
"->",
"getUrl",
"(",
")",
";",
"}"
] |
@param Media $media The media entity
@param string $basepath The base path
@return string
|
[
"@param",
"Media",
"$media",
"The",
"media",
"entity",
"@param",
"string",
"$basepath",
"The",
"base",
"path"
] |
train
|
https://github.com/syzygypl/remote-media-bundle/blob/2be3284d5baf8a12220ecbaf63043eb105eb87ef/src/MediaHandler/RemoteImageHandler.php#L82-L89
|
[
"Media",
"basepath"
] |
What does this function return?
|
[
"string"
] |
znframework/package-helpers
|
Rounder.php
|
Rounder.down
|
public static function down(Float $number, Int $count = 0) : Float
{
if( $count === 0 )
{
return floor($number);
}
$numbers = explode(".", $number);
$edit = 0;
if( ! empty($numbers[1]) )
{
$edit = substr($numbers[1], 0, $count);
return (float) $numbers[0].".".$edit;
}
else
{
throw new LogicException('[Rounder::down()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!');
}
}
|
php
|
public static function down(Float $number, Int $count = 0) : Float
{
if( $count === 0 )
{
return floor($number);
}
$numbers = explode(".", $number);
$edit = 0;
if( ! empty($numbers[1]) )
{
$edit = substr($numbers[1], 0, $count);
return (float) $numbers[0].".".$edit;
}
else
{
throw new LogicException('[Rounder::down()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!');
}
}
|
[
"public",
"static",
"function",
"down",
"(",
"Float",
"$",
"number",
",",
"Int",
"$",
"count",
"=",
"0",
")",
":",
"Float",
"{",
"if",
"(",
"$",
"count",
"===",
"0",
")",
"{",
"return",
"floor",
"(",
"$",
"number",
")",
";",
"}",
"$",
"numbers",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"number",
")",
";",
"$",
"edit",
"=",
"0",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"numbers",
"[",
"1",
"]",
")",
")",
"{",
"$",
"edit",
"=",
"substr",
"(",
"$",
"numbers",
"[",
"1",
"]",
",",
"0",
",",
"$",
"count",
")",
";",
"return",
"(",
"float",
")",
"$",
"numbers",
"[",
"0",
"]",
".",
"\".\"",
".",
"$",
"edit",
";",
"}",
"else",
"{",
"throw",
"new",
"LogicException",
"(",
"'[Rounder::down()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!'",
")",
";",
"}",
"}"
] |
Down
@param float $number
@param int $count = 0
@return float
|
[
"Down"
] |
train
|
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Rounder.php#L37-L58
|
[
"Float",
"Int"
] |
What does this function return?
|
[
"float"
] |
znframework/package-helpers
|
Rounder.php
|
Rounder.up
|
public static function up(Float $number, Int $count = 0) : Float
{
if( $count === 0 )
{
return ceil($number);
}
$numbers = explode(".", $number);
$edit = 0;
if( ! empty($numbers[1]) )
{
$edit = substr($numbers[1], 0, $count);
return (float) $numbers[0].".".($edit + 1);
}
else
{
throw new LogicException('[Rounder::up()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!');
}
}
|
php
|
public static function up(Float $number, Int $count = 0) : Float
{
if( $count === 0 )
{
return ceil($number);
}
$numbers = explode(".", $number);
$edit = 0;
if( ! empty($numbers[1]) )
{
$edit = substr($numbers[1], 0, $count);
return (float) $numbers[0].".".($edit + 1);
}
else
{
throw new LogicException('[Rounder::up()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!');
}
}
|
[
"public",
"static",
"function",
"up",
"(",
"Float",
"$",
"number",
",",
"Int",
"$",
"count",
"=",
"0",
")",
":",
"Float",
"{",
"if",
"(",
"$",
"count",
"===",
"0",
")",
"{",
"return",
"ceil",
"(",
"$",
"number",
")",
";",
"}",
"$",
"numbers",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"number",
")",
";",
"$",
"edit",
"=",
"0",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"numbers",
"[",
"1",
"]",
")",
")",
"{",
"$",
"edit",
"=",
"substr",
"(",
"$",
"numbers",
"[",
"1",
"]",
",",
"0",
",",
"$",
"count",
")",
";",
"return",
"(",
"float",
")",
"$",
"numbers",
"[",
"0",
"]",
".",
"\".\"",
".",
"(",
"$",
"edit",
"+",
"1",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"LogicException",
"(",
"'[Rounder::up()] -> Decimal values can not be specified for the integer! Check 2.($count) parameter!'",
")",
";",
"}",
"}"
] |
Up
@param float $number
@param int $count = 0
@return float
|
[
"Up"
] |
train
|
https://github.com/znframework/package-helpers/blob/c78502263cdda5c14626a1abf7fc7e02dd2bd57d/Rounder.php#L68-L89
|
[
"Float",
"Int"
] |
What does this function return?
|
[
"float"
] |
nekudo/shiny_gears
|
src/Worker.php
|
Worker.getJobInfo
|
public function getJobInfo($Job) : void
{
$uptimeSeconds = time() - $this->startupTime;
$uptimeSeconds = ($uptimeSeconds === 0) ? 1 : $uptimeSeconds;
$avgJobsMin = $this->jobsTotal / ($uptimeSeconds / 60);
$avgJobsMin = round($avgJobsMin, 2);
$response = [
'jobs_total' => $this->jobsTotal,
'avg_jobs_min' => $avgJobsMin,
'uptime_seconds' => $uptimeSeconds,
];
$Job->sendData(json_encode($response));
}
|
php
|
public function getJobInfo($Job) : void
{
$uptimeSeconds = time() - $this->startupTime;
$uptimeSeconds = ($uptimeSeconds === 0) ? 1 : $uptimeSeconds;
$avgJobsMin = $this->jobsTotal / ($uptimeSeconds / 60);
$avgJobsMin = round($avgJobsMin, 2);
$response = [
'jobs_total' => $this->jobsTotal,
'avg_jobs_min' => $avgJobsMin,
'uptime_seconds' => $uptimeSeconds,
];
$Job->sendData(json_encode($response));
}
|
[
"public",
"function",
"getJobInfo",
"(",
"$",
"Job",
")",
":",
"void",
"{",
"$",
"uptimeSeconds",
"=",
"time",
"(",
")",
"-",
"$",
"this",
"->",
"startupTime",
";",
"$",
"uptimeSeconds",
"=",
"(",
"$",
"uptimeSeconds",
"===",
"0",
")",
"?",
"1",
":",
"$",
"uptimeSeconds",
";",
"$",
"avgJobsMin",
"=",
"$",
"this",
"->",
"jobsTotal",
"/",
"(",
"$",
"uptimeSeconds",
"/",
"60",
")",
";",
"$",
"avgJobsMin",
"=",
"round",
"(",
"$",
"avgJobsMin",
",",
"2",
")",
";",
"$",
"response",
"=",
"[",
"'jobs_total'",
"=>",
"$",
"this",
"->",
"jobsTotal",
",",
"'avg_jobs_min'",
"=>",
"$",
"avgJobsMin",
",",
"'uptime_seconds'",
"=>",
"$",
"uptimeSeconds",
",",
"]",
";",
"$",
"Job",
"->",
"sendData",
"(",
"json_encode",
"(",
"$",
"response",
")",
")",
";",
"}"
] |
Returns information about jobs handled.
@param \GearmanJob $Job
@return void
|
[
"Returns",
"information",
"about",
"jobs",
"handled",
"."
] |
train
|
https://github.com/nekudo/shiny_gears/blob/5cb72e1efc7df1c9d97c8bf14ef1d8ba6d44df9a/src/Worker.php#L154-L166
|
[
"Job"
] |
What does this function return?
|
[
"void"
] |
nekudo/shiny_gears
|
src/Worker.php
|
Worker.updatePidFile
|
public function updatePidFile() : void
{
$pidFolder = $this->getRunPath($this->poolName);
if (!file_exists($pidFolder)) {
mkdir($pidFolder, 0755, true);
}
$pidFile = $pidFolder . '/' . $this->workerName . '.pid';
$pid = getmypid();
if (file_put_contents($pidFile, $pid) === false) {
throw new WorkerException('Could not create PID file.');
}
}
|
php
|
public function updatePidFile() : void
{
$pidFolder = $this->getRunPath($this->poolName);
if (!file_exists($pidFolder)) {
mkdir($pidFolder, 0755, true);
}
$pidFile = $pidFolder . '/' . $this->workerName . '.pid';
$pid = getmypid();
if (file_put_contents($pidFile, $pid) === false) {
throw new WorkerException('Could not create PID file.');
}
}
|
[
"public",
"function",
"updatePidFile",
"(",
")",
":",
"void",
"{",
"$",
"pidFolder",
"=",
"$",
"this",
"->",
"getRunPath",
"(",
"$",
"this",
"->",
"poolName",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"pidFolder",
")",
")",
"{",
"mkdir",
"(",
"$",
"pidFolder",
",",
"0755",
",",
"true",
")",
";",
"}",
"$",
"pidFile",
"=",
"$",
"pidFolder",
".",
"'/'",
".",
"$",
"this",
"->",
"workerName",
".",
"'.pid'",
";",
"$",
"pid",
"=",
"getmypid",
"(",
")",
";",
"if",
"(",
"file_put_contents",
"(",
"$",
"pidFile",
",",
"$",
"pid",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"WorkerException",
"(",
"'Could not create PID file.'",
")",
";",
"}",
"}"
] |
Updates PID file for the worker.
@return void
@throws WorkerException
|
[
"Updates",
"PID",
"file",
"for",
"the",
"worker",
"."
] |
train
|
https://github.com/nekudo/shiny_gears/blob/5cb72e1efc7df1c9d97c8bf14ef1d8ba6d44df9a/src/Worker.php#L174-L185
|
[] |
What does this function return?
|
[
"void",
"@throws",
"WorkerException"
] |
LapaLabs/YoutubeHelper
|
Resource/VideoResource.php
|
VideoResource.setId
|
public function setId($id)
{
$this->id = (string)$id;
if (!$this->isIdValid($this->id)) {
throw new InvalidIdException($this);
}
return $this;
}
|
php
|
public function setId($id)
{
$this->id = (string)$id;
if (!$this->isIdValid($this->id)) {
throw new InvalidIdException($this);
}
return $this;
}
|
[
"public",
"function",
"setId",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"(",
"string",
")",
"$",
"id",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isIdValid",
"(",
"$",
"this",
"->",
"id",
")",
")",
"{",
"throw",
"new",
"InvalidIdException",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
@param string $id
@return $this
@throws InvalidIdException
|
[
"@param",
"string",
"$id"
] |
train
|
https://github.com/LapaLabs/YoutubeHelper/blob/b94fd4700881494d24f14fb39ed8093215d0b25b/Resource/VideoResource.php#L79-L88
|
[
"id"
] |
What does this function return?
|
[
"$this",
"",
"@throws",
"InvalidIdException"
] |
mlocati/concrete5-translation-library
|
src/Parser/Dynamic.php
|
Dynamic.getSubParsers
|
public function getSubParsers()
{
$result = array();
$dir = __DIR__.'/DynamicItem';
if (is_dir($dir) && is_readable($dir)) {
$matches = null;
foreach (scandir($dir) as $item) {
if (($item[0] !== '.') && preg_match('/^(.+)\.php$/i', $item, $matches) && ($matches[1] !== 'DynamicItem')) {
$fqClassName = '\\'.__NAMESPACE__.'\\DynamicItem\\'.$matches[1];
$instance = new $fqClassName();
/* @var $instance \C5TL\Parser\DynamicItem\DynamicItem */
$result[$instance->getDynamicItemsParserHandler()] = $instance;
}
}
}
return $result;
}
|
php
|
public function getSubParsers()
{
$result = array();
$dir = __DIR__.'/DynamicItem';
if (is_dir($dir) && is_readable($dir)) {
$matches = null;
foreach (scandir($dir) as $item) {
if (($item[0] !== '.') && preg_match('/^(.+)\.php$/i', $item, $matches) && ($matches[1] !== 'DynamicItem')) {
$fqClassName = '\\'.__NAMESPACE__.'\\DynamicItem\\'.$matches[1];
$instance = new $fqClassName();
/* @var $instance \C5TL\Parser\DynamicItem\DynamicItem */
$result[$instance->getDynamicItemsParserHandler()] = $instance;
}
}
}
return $result;
}
|
[
"public",
"function",
"getSubParsers",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"dir",
"=",
"__DIR__",
".",
"'/DynamicItem'",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
"&&",
"is_readable",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"matches",
"=",
"null",
";",
"foreach",
"(",
"scandir",
"(",
"$",
"dir",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"$",
"item",
"[",
"0",
"]",
"!==",
"'.'",
")",
"&&",
"preg_match",
"(",
"'/^(.+)\\.php$/i'",
",",
"$",
"item",
",",
"$",
"matches",
")",
"&&",
"(",
"$",
"matches",
"[",
"1",
"]",
"!==",
"'DynamicItem'",
")",
")",
"{",
"$",
"fqClassName",
"=",
"'\\\\'",
".",
"__NAMESPACE__",
".",
"'\\\\DynamicItem\\\\'",
".",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"instance",
"=",
"new",
"$",
"fqClassName",
"(",
")",
";",
"/* @var $instance \\C5TL\\Parser\\DynamicItem\\DynamicItem */",
"$",
"result",
"[",
"$",
"instance",
"->",
"getDynamicItemsParserHandler",
"(",
")",
"]",
"=",
"$",
"instance",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the fully-qualified class names of all the sub-parsers.
@return array[\C5TL\Parser\DynamicItem\DynamicItem]
|
[
"Returns",
"the",
"fully",
"-",
"qualified",
"class",
"names",
"of",
"all",
"the",
"sub",
"-",
"parsers",
"."
] |
train
|
https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Dynamic.php#L49-L66
|
[] |
What does this function return?
|
[
"array[\\C5TL\\Parser\\DynamicItem\\DynamicItem]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.