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
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
spiral-modules/auth | source/Auth/Database/Sources/AuthTokenSource.php | AuthTokenSource.findToken | public function findToken(string $token)
{
/**
* @var AuthToken $token
*/
$token = $this->findOne([
'token_hash' => hash('sha512', $token)
]);
if (!empty($token) && $token->getExpiration() < new \DateTime('now')) {
//Token has expired
return null;
}
return $token;
} | php | public function findToken(string $token)
{
/**
* @var AuthToken $token
*/
$token = $this->findOne([
'token_hash' => hash('sha512', $token)
]);
if (!empty($token) && $token->getExpiration() < new \DateTime('now')) {
//Token has expired
return null;
}
return $token;
} | [
"public",
"function",
"findToken",
"(",
"string",
"$",
"token",
")",
"{",
"/**\n * @var AuthToken $token\n */",
"$",
"token",
"=",
"$",
"this",
"->",
"findOne",
"(",
"[",
"'token_hash'",
"=>",
"hash",
"(",
"'sha512'",
",",
"$",
"token",
")",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"token",
")",
"&&",
"$",
"token",
"->",
"getExpiration",
"(",
")",
"<",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
")",
"{",
"//Token has expired",
"return",
"null",
";",
"}",
"return",
"$",
"token",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Database/Sources/AuthTokenSource.php#L27-L42 |
spiral-modules/auth | source/Auth/Database/Sources/AuthTokenSource.php | AuthTokenSource.createToken | public function createToken(UserInterface $user, int $lifetime): TokenInterface
{
//Base64 encoded random token value
$tokenValue = Strings::random(128);
/** @var AuthToken $token */
$token = $this->create([
'user_pk' => $user->primaryKey(),
'token_value' => $tokenValue,
'token_hash' => hash('sha512', $tokenValue),
'expires_at' => (new \DateTime('now'))->add(
new \DateInterval("PT{$lifetime}S")
)
]);
$token->save();
return $token;
} | php | public function createToken(UserInterface $user, int $lifetime): TokenInterface
{
//Base64 encoded random token value
$tokenValue = Strings::random(128);
/** @var AuthToken $token */
$token = $this->create([
'user_pk' => $user->primaryKey(),
'token_value' => $tokenValue,
'token_hash' => hash('sha512', $tokenValue),
'expires_at' => (new \DateTime('now'))->add(
new \DateInterval("PT{$lifetime}S")
)
]);
$token->save();
return $token;
} | [
"public",
"function",
"createToken",
"(",
"UserInterface",
"$",
"user",
",",
"int",
"$",
"lifetime",
")",
":",
"TokenInterface",
"{",
"//Base64 encoded random token value",
"$",
"tokenValue",
"=",
"Strings",
"::",
"random",
"(",
"128",
")",
";",
"/** @var AuthToken $token */",
"$",
"token",
"=",
"$",
"this",
"->",
"create",
"(",
"[",
"'user_pk'",
"=>",
"$",
"user",
"->",
"primaryKey",
"(",
")",
",",
"'token_value'",
"=>",
"$",
"tokenValue",
",",
"'token_hash'",
"=>",
"hash",
"(",
"'sha512'",
",",
"$",
"tokenValue",
")",
",",
"'expires_at'",
"=>",
"(",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
")",
"->",
"add",
"(",
"new",
"\\",
"DateInterval",
"(",
"\"PT{$lifetime}S\"",
")",
")",
"]",
")",
";",
"$",
"token",
"->",
"save",
"(",
")",
";",
"return",
"$",
"token",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Database/Sources/AuthTokenSource.php#L47-L65 |
spiral-modules/auth | source/Auth/Database/Sources/AuthTokenSource.php | AuthTokenSource.touchToken | public function touchToken(TokenInterface $token, int $lifetime): bool
{
if (!$token instanceof AuthToken) {
throw new LogicException("Invalid token type, instances of AuthToken are expected");
}
$token->touch();
$token->save();
return true;
} | php | public function touchToken(TokenInterface $token, int $lifetime): bool
{
if (!$token instanceof AuthToken) {
throw new LogicException("Invalid token type, instances of AuthToken are expected");
}
$token->touch();
$token->save();
return true;
} | [
"public",
"function",
"touchToken",
"(",
"TokenInterface",
"$",
"token",
",",
"int",
"$",
"lifetime",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"token",
"instanceof",
"AuthToken",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"Invalid token type, instances of AuthToken are expected\"",
")",
";",
"}",
"$",
"token",
"->",
"touch",
"(",
")",
";",
"$",
"token",
"->",
"save",
"(",
")",
";",
"return",
"true",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Database/Sources/AuthTokenSource.php#L70-L80 |
yuncms/framework | src/helpers/AvatarHelper.php | AvatarHelper.saveById | public static function saveById($userId, $originalImage): bool
{
$user = User::findOne(['id' => $userId]);
if ($user) {
return self::save($user, $originalImage);
}
return false;
} | php | public static function saveById($userId, $originalImage): bool
{
$user = User::findOne(['id' => $userId]);
if ($user) {
return self::save($user, $originalImage);
}
return false;
} | [
"public",
"static",
"function",
"saveById",
"(",
"$",
"userId",
",",
"$",
"originalImage",
")",
":",
"bool",
"{",
"$",
"user",
"=",
"User",
"::",
"findOne",
"(",
"[",
"'id'",
"=>",
"$",
"userId",
"]",
")",
";",
"if",
"(",
"$",
"user",
")",
"{",
"return",
"self",
"::",
"save",
"(",
"$",
"user",
",",
"$",
"originalImage",
")",
";",
"}",
"return",
"false",
";",
"}"
] | 按UID保存用户头像
@param int $userId
@param string $originalImage
@return bool
@throws ErrorException
@throws Exception | [
"按UID保存用户头像"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/AvatarHelper.php#L50-L57 |
yuncms/framework | src/helpers/AvatarHelper.php | AvatarHelper.save | public static function save(User $user, $originalImage): bool
{
$avatarPath = AvatarHelper::getAvatarPath($user->id);
foreach (self::$avatarSize as $size => $value) {
try {
$tempFile = Yii::getAlias('@runtime') . DIRECTORY_SEPARATOR . $user->id . '_avatar_' . $size . '.jpg';
Image::thumbnail($originalImage, $value, $value)->save($tempFile, ['quality' => 100]);
$currentAvatarPath = $avatarPath . "_avatar_{$size}.jpg";
if (self::getDisk()->exists($currentAvatarPath)) {
self::getDisk()->delete($currentAvatarPath);
}
self::getDisk()->put($currentAvatarPath, FileHelper::readAndDelete($tempFile), [
'visibility' => AdapterInterface::VISIBILITY_PUBLIC
]);
} catch (Exception $e) {
throw $e;
}
}
$user->updateAttributes(['avatar' => true]);
$user->touch('updated_at');
return true;
} | php | public static function save(User $user, $originalImage): bool
{
$avatarPath = AvatarHelper::getAvatarPath($user->id);
foreach (self::$avatarSize as $size => $value) {
try {
$tempFile = Yii::getAlias('@runtime') . DIRECTORY_SEPARATOR . $user->id . '_avatar_' . $size . '.jpg';
Image::thumbnail($originalImage, $value, $value)->save($tempFile, ['quality' => 100]);
$currentAvatarPath = $avatarPath . "_avatar_{$size}.jpg";
if (self::getDisk()->exists($currentAvatarPath)) {
self::getDisk()->delete($currentAvatarPath);
}
self::getDisk()->put($currentAvatarPath, FileHelper::readAndDelete($tempFile), [
'visibility' => AdapterInterface::VISIBILITY_PUBLIC
]);
} catch (Exception $e) {
throw $e;
}
}
$user->updateAttributes(['avatar' => true]);
$user->touch('updated_at');
return true;
} | [
"public",
"static",
"function",
"save",
"(",
"User",
"$",
"user",
",",
"$",
"originalImage",
")",
":",
"bool",
"{",
"$",
"avatarPath",
"=",
"AvatarHelper",
"::",
"getAvatarPath",
"(",
"$",
"user",
"->",
"id",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"avatarSize",
"as",
"$",
"size",
"=>",
"$",
"value",
")",
"{",
"try",
"{",
"$",
"tempFile",
"=",
"Yii",
"::",
"getAlias",
"(",
"'@runtime'",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"user",
"->",
"id",
".",
"'_avatar_'",
".",
"$",
"size",
".",
"'.jpg'",
";",
"Image",
"::",
"thumbnail",
"(",
"$",
"originalImage",
",",
"$",
"value",
",",
"$",
"value",
")",
"->",
"save",
"(",
"$",
"tempFile",
",",
"[",
"'quality'",
"=>",
"100",
"]",
")",
";",
"$",
"currentAvatarPath",
"=",
"$",
"avatarPath",
".",
"\"_avatar_{$size}.jpg\"",
";",
"if",
"(",
"self",
"::",
"getDisk",
"(",
")",
"->",
"exists",
"(",
"$",
"currentAvatarPath",
")",
")",
"{",
"self",
"::",
"getDisk",
"(",
")",
"->",
"delete",
"(",
"$",
"currentAvatarPath",
")",
";",
"}",
"self",
"::",
"getDisk",
"(",
")",
"->",
"put",
"(",
"$",
"currentAvatarPath",
",",
"FileHelper",
"::",
"readAndDelete",
"(",
"$",
"tempFile",
")",
",",
"[",
"'visibility'",
"=>",
"AdapterInterface",
"::",
"VISIBILITY_PUBLIC",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"$",
"user",
"->",
"updateAttributes",
"(",
"[",
"'avatar'",
"=>",
"true",
"]",
")",
";",
"$",
"user",
"->",
"touch",
"(",
"'updated_at'",
")",
";",
"return",
"true",
";",
"}"
] | 从文件保存用户头像
@param User $user
@param string $originalImage
@return bool
@throws ErrorException
@throws Exception | [
"从文件保存用户头像"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/AvatarHelper.php#L67-L88 |
yuncms/framework | src/helpers/AvatarHelper.php | AvatarHelper.getAvatarById | public static function getAvatarById($userId, $size = self::AVATAR_MIDDLE)
{
$user = User::findOne(['id' => $userId]);
if ($user) {
return self::getAvatar($user, $size);
}
return '';
} | php | public static function getAvatarById($userId, $size = self::AVATAR_MIDDLE)
{
$user = User::findOne(['id' => $userId]);
if ($user) {
return self::getAvatar($user, $size);
}
return '';
} | [
"public",
"static",
"function",
"getAvatarById",
"(",
"$",
"userId",
",",
"$",
"size",
"=",
"self",
"::",
"AVATAR_MIDDLE",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOne",
"(",
"[",
"'id'",
"=>",
"$",
"userId",
"]",
")",
";",
"if",
"(",
"$",
"user",
")",
"{",
"return",
"self",
"::",
"getAvatar",
"(",
"$",
"user",
",",
"$",
"size",
")",
";",
"}",
"return",
"''",
";",
"}"
] | 通过UID获取用户头像
@param int $userId
@param string $size
@return string
@throws \OSS\Core\OssException
@throws \yii\base\InvalidConfigException | [
"通过UID获取用户头像"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/AvatarHelper.php#L98-L105 |
yuncms/framework | src/helpers/AvatarHelper.php | AvatarHelper.getAvatar | public static function getAvatar(User $user, $size = self::AVATAR_MIDDLE)
{
$size = in_array($size, [self::AVATAR_BIG, self::AVATAR_MIDDLE, self::AVATAR_SMALL]) ? $size : self::AVATAR_BIG;
if ($user->getIsAvatar()) {
$avatarPath = AvatarHelper::getAvatarPath($user->id) . "_avatar_{$size}.jpg";
return static::getDisk()->url($avatarPath) . '?_t=' . $user->updated_at;
} else {
$avatarUrl = "/img/no_avatar_{$size}.gif";
if (Yii::getAlias('@webroot', false)) {
$baseUrl = UserAsset::register(Yii::$app->view)->baseUrl;
return Url::to($baseUrl . $avatarUrl, true);
}
}
return '';
} | php | public static function getAvatar(User $user, $size = self::AVATAR_MIDDLE)
{
$size = in_array($size, [self::AVATAR_BIG, self::AVATAR_MIDDLE, self::AVATAR_SMALL]) ? $size : self::AVATAR_BIG;
if ($user->getIsAvatar()) {
$avatarPath = AvatarHelper::getAvatarPath($user->id) . "_avatar_{$size}.jpg";
return static::getDisk()->url($avatarPath) . '?_t=' . $user->updated_at;
} else {
$avatarUrl = "/img/no_avatar_{$size}.gif";
if (Yii::getAlias('@webroot', false)) {
$baseUrl = UserAsset::register(Yii::$app->view)->baseUrl;
return Url::to($baseUrl . $avatarUrl, true);
}
}
return '';
} | [
"public",
"static",
"function",
"getAvatar",
"(",
"User",
"$",
"user",
",",
"$",
"size",
"=",
"self",
"::",
"AVATAR_MIDDLE",
")",
"{",
"$",
"size",
"=",
"in_array",
"(",
"$",
"size",
",",
"[",
"self",
"::",
"AVATAR_BIG",
",",
"self",
"::",
"AVATAR_MIDDLE",
",",
"self",
"::",
"AVATAR_SMALL",
"]",
")",
"?",
"$",
"size",
":",
"self",
"::",
"AVATAR_BIG",
";",
"if",
"(",
"$",
"user",
"->",
"getIsAvatar",
"(",
")",
")",
"{",
"$",
"avatarPath",
"=",
"AvatarHelper",
"::",
"getAvatarPath",
"(",
"$",
"user",
"->",
"id",
")",
".",
"\"_avatar_{$size}.jpg\"",
";",
"return",
"static",
"::",
"getDisk",
"(",
")",
"->",
"url",
"(",
"$",
"avatarPath",
")",
".",
"'?_t='",
".",
"$",
"user",
"->",
"updated_at",
";",
"}",
"else",
"{",
"$",
"avatarUrl",
"=",
"\"/img/no_avatar_{$size}.gif\"",
";",
"if",
"(",
"Yii",
"::",
"getAlias",
"(",
"'@webroot'",
",",
"false",
")",
")",
"{",
"$",
"baseUrl",
"=",
"UserAsset",
"::",
"register",
"(",
"Yii",
"::",
"$",
"app",
"->",
"view",
")",
"->",
"baseUrl",
";",
"return",
"Url",
"::",
"to",
"(",
"$",
"baseUrl",
".",
"$",
"avatarUrl",
",",
"true",
")",
";",
"}",
"}",
"return",
"''",
";",
"}"
] | 获取头像Url
@param User $user
@param string $size
@return string
@throws \OSS\Core\OssException
@throws \yii\base\InvalidConfigException | [
"获取头像Url"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/AvatarHelper.php#L115-L129 |
yuncms/framework | src/helpers/AvatarHelper.php | AvatarHelper.getAvatarPath | public static function getAvatarPath($userId)
{
$id = sprintf("%09d", $userId);
$dir1 = substr($id, 0, 3);
$dir2 = substr($id, 3, 2);
$dir3 = substr($id, 5, 2);
return 'avatar' . '/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($userId, -2);
} | php | public static function getAvatarPath($userId)
{
$id = sprintf("%09d", $userId);
$dir1 = substr($id, 0, 3);
$dir2 = substr($id, 3, 2);
$dir3 = substr($id, 5, 2);
return 'avatar' . '/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($userId, -2);
} | [
"public",
"static",
"function",
"getAvatarPath",
"(",
"$",
"userId",
")",
"{",
"$",
"id",
"=",
"sprintf",
"(",
"\"%09d\"",
",",
"$",
"userId",
")",
";",
"$",
"dir1",
"=",
"substr",
"(",
"$",
"id",
",",
"0",
",",
"3",
")",
";",
"$",
"dir2",
"=",
"substr",
"(",
"$",
"id",
",",
"3",
",",
"2",
")",
";",
"$",
"dir3",
"=",
"substr",
"(",
"$",
"id",
",",
"5",
",",
"2",
")",
";",
"return",
"'avatar'",
".",
"'/'",
".",
"$",
"dir1",
".",
"'/'",
".",
"$",
"dir2",
".",
"'/'",
".",
"$",
"dir3",
".",
"'/'",
".",
"substr",
"(",
"$",
"userId",
",",
"-",
"2",
")",
";",
"}"
] | 计算用户头像子路径
@param int $userId 用户ID
@return string | [
"计算用户头像子路径"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/AvatarHelper.php#L137-L144 |
nguyenanhung/nusoap | src/nusoap_client.php | nusoap_client.send | function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30)
{
$this->checkCookies();
// detect transport
switch (TRUE) {
// http(s)
case preg_match('/^http/', $this->endpoint):
$this->debug('transporting via HTTP');
if ($this->persistentConnection == TRUE && is_object($this->persistentConnection)) {
$http =& $this->persistentConnection;
} else {
$http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
if ($this->persistentConnection) {
$http->usePersistentConnection();
}
}
$http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
$http->setSOAPAction($soapaction);
if ($this->proxyhost && $this->proxyport) {
$http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
}
if ($this->authtype != '') {
$http->setCredentials($this->username, $this->password, $this->authtype, [], $this->certRequest);
}
if ($this->http_encoding != '') {
$http->setEncoding($this->http_encoding);
}
$this->debug('sending message, length=' . strlen($msg));
if (preg_match('/^http:/', $this->endpoint)) {
//if(strpos($this->endpoint,'http:')){
$this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies);
} elseif (preg_match('/^https/', $this->endpoint)) {
//} elseif(strpos($this->endpoint,'https:')){
//if(phpversion() == '4.3.0-dev'){
//$response = $http->send($msg,$timeout,$response_timeout);
//$this->request = $http->outgoing_payload;
//$this->response = $http->incoming_payload;
//} else
$this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies);
} else {
$this->setError('no http/s in endpoint url');
}
$this->request = $http->outgoing_payload;
$this->response = $http->incoming_payload;
$this->appendDebug($http->getDebug());
$this->UpdateCookies($http->incoming_cookies);
// save transport object if using persistent connections
if ($this->persistentConnection) {
$http->clearDebug();
if (!is_object($this->persistentConnection)) {
$this->persistentConnection = $http;
}
}
if ($err = $http->getError()) {
$this->setError('HTTP Error: ' . $err);
return FALSE;
} elseif ($this->getError()) {
return FALSE;
} else {
$this->debug('got response, length=' . strlen($this->responseData) . ' type=' . $http->incoming_headers['content-type']);
return $this->parseResponse($http->incoming_headers, $this->responseData);
}
break;
default:
$this->setError('no transport found, or selected transport is not yet supported!');
return FALSE;
break;
}
} | php | function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30)
{
$this->checkCookies();
// detect transport
switch (TRUE) {
// http(s)
case preg_match('/^http/', $this->endpoint):
$this->debug('transporting via HTTP');
if ($this->persistentConnection == TRUE && is_object($this->persistentConnection)) {
$http =& $this->persistentConnection;
} else {
$http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
if ($this->persistentConnection) {
$http->usePersistentConnection();
}
}
$http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
$http->setSOAPAction($soapaction);
if ($this->proxyhost && $this->proxyport) {
$http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
}
if ($this->authtype != '') {
$http->setCredentials($this->username, $this->password, $this->authtype, [], $this->certRequest);
}
if ($this->http_encoding != '') {
$http->setEncoding($this->http_encoding);
}
$this->debug('sending message, length=' . strlen($msg));
if (preg_match('/^http:/', $this->endpoint)) {
//if(strpos($this->endpoint,'http:')){
$this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies);
} elseif (preg_match('/^https/', $this->endpoint)) {
//} elseif(strpos($this->endpoint,'https:')){
//if(phpversion() == '4.3.0-dev'){
//$response = $http->send($msg,$timeout,$response_timeout);
//$this->request = $http->outgoing_payload;
//$this->response = $http->incoming_payload;
//} else
$this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies);
} else {
$this->setError('no http/s in endpoint url');
}
$this->request = $http->outgoing_payload;
$this->response = $http->incoming_payload;
$this->appendDebug($http->getDebug());
$this->UpdateCookies($http->incoming_cookies);
// save transport object if using persistent connections
if ($this->persistentConnection) {
$http->clearDebug();
if (!is_object($this->persistentConnection)) {
$this->persistentConnection = $http;
}
}
if ($err = $http->getError()) {
$this->setError('HTTP Error: ' . $err);
return FALSE;
} elseif ($this->getError()) {
return FALSE;
} else {
$this->debug('got response, length=' . strlen($this->responseData) . ' type=' . $http->incoming_headers['content-type']);
return $this->parseResponse($http->incoming_headers, $this->responseData);
}
break;
default:
$this->setError('no transport found, or selected transport is not yet supported!');
return FALSE;
break;
}
} | [
"function",
"send",
"(",
"$",
"msg",
",",
"$",
"soapaction",
"=",
"''",
",",
"$",
"timeout",
"=",
"0",
",",
"$",
"response_timeout",
"=",
"30",
")",
"{",
"$",
"this",
"->",
"checkCookies",
"(",
")",
";",
"// detect transport\r",
"switch",
"(",
"TRUE",
")",
"{",
"// http(s)\r",
"case",
"preg_match",
"(",
"'/^http/'",
",",
"$",
"this",
"->",
"endpoint",
")",
":",
"$",
"this",
"->",
"debug",
"(",
"'transporting via HTTP'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"persistentConnection",
"==",
"TRUE",
"&&",
"is_object",
"(",
"$",
"this",
"->",
"persistentConnection",
")",
")",
"{",
"$",
"http",
"=",
"&",
"$",
"this",
"->",
"persistentConnection",
";",
"}",
"else",
"{",
"$",
"http",
"=",
"new",
"soap_transport_http",
"(",
"$",
"this",
"->",
"endpoint",
",",
"$",
"this",
"->",
"curl_options",
",",
"$",
"this",
"->",
"use_curl",
")",
";",
"if",
"(",
"$",
"this",
"->",
"persistentConnection",
")",
"{",
"$",
"http",
"->",
"usePersistentConnection",
"(",
")",
";",
"}",
"}",
"$",
"http",
"->",
"setContentType",
"(",
"$",
"this",
"->",
"getHTTPContentType",
"(",
")",
",",
"$",
"this",
"->",
"getHTTPContentTypeCharset",
"(",
")",
")",
";",
"$",
"http",
"->",
"setSOAPAction",
"(",
"$",
"soapaction",
")",
";",
"if",
"(",
"$",
"this",
"->",
"proxyhost",
"&&",
"$",
"this",
"->",
"proxyport",
")",
"{",
"$",
"http",
"->",
"setProxy",
"(",
"$",
"this",
"->",
"proxyhost",
",",
"$",
"this",
"->",
"proxyport",
",",
"$",
"this",
"->",
"proxyusername",
",",
"$",
"this",
"->",
"proxypassword",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"authtype",
"!=",
"''",
")",
"{",
"$",
"http",
"->",
"setCredentials",
"(",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"this",
"->",
"authtype",
",",
"[",
"]",
",",
"$",
"this",
"->",
"certRequest",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"http_encoding",
"!=",
"''",
")",
"{",
"$",
"http",
"->",
"setEncoding",
"(",
"$",
"this",
"->",
"http_encoding",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"(",
"'sending message, length='",
".",
"strlen",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^http:/'",
",",
"$",
"this",
"->",
"endpoint",
")",
")",
"{",
"//if(strpos($this->endpoint,'http:')){\r",
"$",
"this",
"->",
"responseData",
"=",
"$",
"http",
"->",
"send",
"(",
"$",
"msg",
",",
"$",
"timeout",
",",
"$",
"response_timeout",
",",
"$",
"this",
"->",
"cookies",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^https/'",
",",
"$",
"this",
"->",
"endpoint",
")",
")",
"{",
"//} elseif(strpos($this->endpoint,'https:')){\r",
"//if(phpversion() == '4.3.0-dev'){\r",
"//$response = $http->send($msg,$timeout,$response_timeout);\r",
"//$this->request = $http->outgoing_payload;\r",
"//$this->response = $http->incoming_payload;\r",
"//} else\r",
"$",
"this",
"->",
"responseData",
"=",
"$",
"http",
"->",
"sendHTTPS",
"(",
"$",
"msg",
",",
"$",
"timeout",
",",
"$",
"response_timeout",
",",
"$",
"this",
"->",
"cookies",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setError",
"(",
"'no http/s in endpoint url'",
")",
";",
"}",
"$",
"this",
"->",
"request",
"=",
"$",
"http",
"->",
"outgoing_payload",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"http",
"->",
"incoming_payload",
";",
"$",
"this",
"->",
"appendDebug",
"(",
"$",
"http",
"->",
"getDebug",
"(",
")",
")",
";",
"$",
"this",
"->",
"UpdateCookies",
"(",
"$",
"http",
"->",
"incoming_cookies",
")",
";",
"// save transport object if using persistent connections\r",
"if",
"(",
"$",
"this",
"->",
"persistentConnection",
")",
"{",
"$",
"http",
"->",
"clearDebug",
"(",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"this",
"->",
"persistentConnection",
")",
")",
"{",
"$",
"this",
"->",
"persistentConnection",
"=",
"$",
"http",
";",
"}",
"}",
"if",
"(",
"$",
"err",
"=",
"$",
"http",
"->",
"getError",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'HTTP Error: '",
".",
"$",
"err",
")",
";",
"return",
"FALSE",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getError",
"(",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'got response, length='",
".",
"strlen",
"(",
"$",
"this",
"->",
"responseData",
")",
".",
"' type='",
".",
"$",
"http",
"->",
"incoming_headers",
"[",
"'content-type'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"http",
"->",
"incoming_headers",
",",
"$",
"this",
"->",
"responseData",
")",
";",
"}",
"break",
";",
"default",
":",
"$",
"this",
"->",
"setError",
"(",
"'no transport found, or selected transport is not yet supported!'",
")",
";",
"return",
"FALSE",
";",
"break",
";",
"}",
"}"
] | send the SOAP message
Note: if the operation has multiple return values
the return value of this method will be an array
of those values.
@param string $msg a SOAPx4 soapmsg object
@param string $soapaction SOAPAction value
@param integer $timeout set connection timeout in seconds
@param integer $response_timeout set response timeout in seconds
@return mixed native PHP types.
@access private | [
"send",
"the",
"SOAP",
"message"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src/nusoap_client.php#L436-L509 |
nguyenanhung/nusoap | src/nusoap_client.php | nusoap_client.setCookie | function setCookie($name, $value)
{
if (strlen($name) == 0) {
return FALSE;
}
$this->cookies[] = ['name' => $name, 'value' => $value];
return TRUE;
} | php | function setCookie($name, $value)
{
if (strlen($name) == 0) {
return FALSE;
}
$this->cookies[] = ['name' => $name, 'value' => $value];
return TRUE;
} | [
"function",
"setCookie",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"==",
"0",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"this",
"->",
"cookies",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'value'",
"=>",
"$",
"value",
"]",
";",
"return",
"TRUE",
";",
"}"
] | adds a new Cookie into $this->cookies array
@param string $name Cookie Name
@param string $value Cookie Value
@return boolean if cookie-set was successful returns true, else false
@access public | [
"adds",
"a",
"new",
"Cookie",
"into",
"$this",
"-",
">",
"cookies",
"array"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src/nusoap_client.php#L936-L944 |
nguyenanhung/nusoap | src/nusoap_client.php | nusoap_client.UpdateCookies | function UpdateCookies($cookies)
{
if (sizeof($this->cookies) == 0) {
// no existing cookies: take whatever is new
if (sizeof($cookies) > 0) {
$this->debug('Setting new cookie(s)');
$this->cookies = $cookies;
}
return TRUE;
}
if (sizeof($cookies) == 0) {
// no new cookies: keep what we've got
return TRUE;
}
// merge
foreach ($cookies as $newCookie) {
if (!is_array($newCookie)) {
continue;
}
if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
continue;
}
$newName = $newCookie['name'];
$found = FALSE;
for ($i = 0; $i < count($this->cookies); $i++) {
$cookie = $this->cookies[$i];
if (!is_array($cookie)) {
continue;
}
if (!isset($cookie['name'])) {
continue;
}
if ($newName != $cookie['name']) {
continue;
}
$newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
$domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
if ($newDomain != $domain) {
continue;
}
$newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
$path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
if ($newPath != $path) {
continue;
}
$this->cookies[$i] = $newCookie;
$found = TRUE;
$this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
break;
}
if (!$found) {
$this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
$this->cookies[] = $newCookie;
}
}
return TRUE;
} | php | function UpdateCookies($cookies)
{
if (sizeof($this->cookies) == 0) {
// no existing cookies: take whatever is new
if (sizeof($cookies) > 0) {
$this->debug('Setting new cookie(s)');
$this->cookies = $cookies;
}
return TRUE;
}
if (sizeof($cookies) == 0) {
// no new cookies: keep what we've got
return TRUE;
}
// merge
foreach ($cookies as $newCookie) {
if (!is_array($newCookie)) {
continue;
}
if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
continue;
}
$newName = $newCookie['name'];
$found = FALSE;
for ($i = 0; $i < count($this->cookies); $i++) {
$cookie = $this->cookies[$i];
if (!is_array($cookie)) {
continue;
}
if (!isset($cookie['name'])) {
continue;
}
if ($newName != $cookie['name']) {
continue;
}
$newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
$domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
if ($newDomain != $domain) {
continue;
}
$newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
$path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
if ($newPath != $path) {
continue;
}
$this->cookies[$i] = $newCookie;
$found = TRUE;
$this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
break;
}
if (!$found) {
$this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
$this->cookies[] = $newCookie;
}
}
return TRUE;
} | [
"function",
"UpdateCookies",
"(",
"$",
"cookies",
")",
"{",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"cookies",
")",
"==",
"0",
")",
"{",
"// no existing cookies: take whatever is new\r",
"if",
"(",
"sizeof",
"(",
"$",
"cookies",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Setting new cookie(s)'",
")",
";",
"$",
"this",
"->",
"cookies",
"=",
"$",
"cookies",
";",
"}",
"return",
"TRUE",
";",
"}",
"if",
"(",
"sizeof",
"(",
"$",
"cookies",
")",
"==",
"0",
")",
"{",
"// no new cookies: keep what we've got\r",
"return",
"TRUE",
";",
"}",
"// merge\r",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"newCookie",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"newCookie",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"(",
"!",
"isset",
"(",
"$",
"newCookie",
"[",
"'name'",
"]",
")",
")",
"||",
"(",
"!",
"isset",
"(",
"$",
"newCookie",
"[",
"'value'",
"]",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"newName",
"=",
"$",
"newCookie",
"[",
"'name'",
"]",
";",
"$",
"found",
"=",
"FALSE",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"cookies",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"cookies",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"cookie",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"cookie",
"[",
"'name'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"newName",
"!=",
"$",
"cookie",
"[",
"'name'",
"]",
")",
"{",
"continue",
";",
"}",
"$",
"newDomain",
"=",
"isset",
"(",
"$",
"newCookie",
"[",
"'domain'",
"]",
")",
"?",
"$",
"newCookie",
"[",
"'domain'",
"]",
":",
"'NODOMAIN'",
";",
"$",
"domain",
"=",
"isset",
"(",
"$",
"cookie",
"[",
"'domain'",
"]",
")",
"?",
"$",
"cookie",
"[",
"'domain'",
"]",
":",
"'NODOMAIN'",
";",
"if",
"(",
"$",
"newDomain",
"!=",
"$",
"domain",
")",
"{",
"continue",
";",
"}",
"$",
"newPath",
"=",
"isset",
"(",
"$",
"newCookie",
"[",
"'path'",
"]",
")",
"?",
"$",
"newCookie",
"[",
"'path'",
"]",
":",
"'NOPATH'",
";",
"$",
"path",
"=",
"isset",
"(",
"$",
"cookie",
"[",
"'path'",
"]",
")",
"?",
"$",
"cookie",
"[",
"'path'",
"]",
":",
"'NOPATH'",
";",
"if",
"(",
"$",
"newPath",
"!=",
"$",
"path",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"cookies",
"[",
"$",
"i",
"]",
"=",
"$",
"newCookie",
";",
"$",
"found",
"=",
"TRUE",
";",
"$",
"this",
"->",
"debug",
"(",
"'Update cookie '",
".",
"$",
"newName",
".",
"'='",
".",
"$",
"newCookie",
"[",
"'value'",
"]",
")",
";",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Add cookie '",
".",
"$",
"newName",
".",
"'='",
".",
"$",
"newCookie",
"[",
"'value'",
"]",
")",
";",
"$",
"this",
"->",
"cookies",
"[",
"]",
"=",
"$",
"newCookie",
";",
"}",
"}",
"return",
"TRUE",
";",
"}"
] | updates the current cookies with a new set
@param array $cookies new cookies with which to update current ones
@return boolean always return true
@access private | [
"updates",
"the",
"current",
"cookies",
"with",
"a",
"new",
"set"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src/nusoap_client.php#L999-L1058 |
yuncms/framework | src/user/models/User.php | User.scenarios | public function scenarios()
{
return ArrayHelper::merge(parent::scenarios(), [
static::SCENARIO_CREATE => ['nickname', 'email', 'password'],
static::SCENARIO_UPDATE => ['nickname', 'email', 'password'],
static::SCENARIO_REGISTER => ['nickname', 'password'],
static::SCENARIO_EMAIL_REGISTER => ['nickname', 'email', 'password'],
static::SCENARIO_MOBILE_REGISTER => ['mobile', 'password'],
static::SCENARIO_SETTINGS => ['username', 'email', 'password'],
static::SCENARIO_CONNECT => ['nickname', 'email', 'password'],//链接账户密码可以为空邮箱可以为空
static::SCENARIO_PASSWORD => ['password'],//只修改密码
]);
} | php | public function scenarios()
{
return ArrayHelper::merge(parent::scenarios(), [
static::SCENARIO_CREATE => ['nickname', 'email', 'password'],
static::SCENARIO_UPDATE => ['nickname', 'email', 'password'],
static::SCENARIO_REGISTER => ['nickname', 'password'],
static::SCENARIO_EMAIL_REGISTER => ['nickname', 'email', 'password'],
static::SCENARIO_MOBILE_REGISTER => ['mobile', 'password'],
static::SCENARIO_SETTINGS => ['username', 'email', 'password'],
static::SCENARIO_CONNECT => ['nickname', 'email', 'password'],//链接账户密码可以为空邮箱可以为空
static::SCENARIO_PASSWORD => ['password'],//只修改密码
]);
} | [
"public",
"function",
"scenarios",
"(",
")",
"{",
"return",
"ArrayHelper",
"::",
"merge",
"(",
"parent",
"::",
"scenarios",
"(",
")",
",",
"[",
"static",
"::",
"SCENARIO_CREATE",
"=>",
"[",
"'nickname'",
",",
"'email'",
",",
"'password'",
"]",
",",
"static",
"::",
"SCENARIO_UPDATE",
"=>",
"[",
"'nickname'",
",",
"'email'",
",",
"'password'",
"]",
",",
"static",
"::",
"SCENARIO_REGISTER",
"=>",
"[",
"'nickname'",
",",
"'password'",
"]",
",",
"static",
"::",
"SCENARIO_EMAIL_REGISTER",
"=>",
"[",
"'nickname'",
",",
"'email'",
",",
"'password'",
"]",
",",
"static",
"::",
"SCENARIO_MOBILE_REGISTER",
"=>",
"[",
"'mobile'",
",",
"'password'",
"]",
",",
"static",
"::",
"SCENARIO_SETTINGS",
"=>",
"[",
"'username'",
",",
"'email'",
",",
"'password'",
"]",
",",
"static",
"::",
"SCENARIO_CONNECT",
"=>",
"[",
"'nickname'",
",",
"'email'",
",",
"'password'",
"]",
",",
"//链接账户密码可以为空邮箱可以为空",
"static",
"::",
"SCENARIO_PASSWORD",
"=>",
"[",
"'password'",
"]",
",",
"//只修改密码",
"]",
")",
";",
"}"
] | 定义场景 | [
"定义场景"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L102-L114 |
yuncms/framework | src/user/models/User.php | User.rules | public function rules()
{
return ArrayHelper::merge(parent::rules(), [
// nickname rules
'nicknameRequired' => ['nickname', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER, self::SCENARIO_CONNECT]],
// email rules
'emailRequired' => ['email', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER]],
//mobile rules
'mobileRequired' => ['mobile', 'required', 'on' => [self::SCENARIO_MOBILE_REGISTER]],
// password rules
'passwordRequired' => ['password', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER, self::SCENARIO_MOBILE_REGISTER]],
// tags rules
'tags' => ['tagValues', 'safe'],
'transfer_balance' => ['transfer_balance', 'number'],
'balance' => ['balance', 'number'],
]);
} | php | public function rules()
{
return ArrayHelper::merge(parent::rules(), [
// nickname rules
'nicknameRequired' => ['nickname', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER, self::SCENARIO_CONNECT]],
// email rules
'emailRequired' => ['email', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER]],
//mobile rules
'mobileRequired' => ['mobile', 'required', 'on' => [self::SCENARIO_MOBILE_REGISTER]],
// password rules
'passwordRequired' => ['password', 'required', 'on' => [self::SCENARIO_EMAIL_REGISTER, self::SCENARIO_MOBILE_REGISTER]],
// tags rules
'tags' => ['tagValues', 'safe'],
'transfer_balance' => ['transfer_balance', 'number'],
'balance' => ['balance', 'number'],
]);
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"return",
"ArrayHelper",
"::",
"merge",
"(",
"parent",
"::",
"rules",
"(",
")",
",",
"[",
"// nickname rules",
"'nicknameRequired'",
"=>",
"[",
"'nickname'",
",",
"'required'",
",",
"'on'",
"=>",
"[",
"self",
"::",
"SCENARIO_EMAIL_REGISTER",
",",
"self",
"::",
"SCENARIO_CONNECT",
"]",
"]",
",",
"// email rules",
"'emailRequired'",
"=>",
"[",
"'email'",
",",
"'required'",
",",
"'on'",
"=>",
"[",
"self",
"::",
"SCENARIO_EMAIL_REGISTER",
"]",
"]",
",",
"//mobile rules",
"'mobileRequired'",
"=>",
"[",
"'mobile'",
",",
"'required'",
",",
"'on'",
"=>",
"[",
"self",
"::",
"SCENARIO_MOBILE_REGISTER",
"]",
"]",
",",
"// password rules",
"'passwordRequired'",
"=>",
"[",
"'password'",
",",
"'required'",
",",
"'on'",
"=>",
"[",
"self",
"::",
"SCENARIO_EMAIL_REGISTER",
",",
"self",
"::",
"SCENARIO_MOBILE_REGISTER",
"]",
"]",
",",
"// tags rules",
"'tags'",
"=>",
"[",
"'tagValues'",
",",
"'safe'",
"]",
",",
"'transfer_balance'",
"=>",
"[",
"'transfer_balance'",
",",
"'number'",
"]",
",",
"'balance'",
"=>",
"[",
"'balance'",
",",
"'number'",
"]",
",",
"]",
")",
";",
"}"
] | 验证规则
@return array | [
"验证规则"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L120-L137 |
yuncms/framework | src/user/models/User.php | User.getSocialAccounts | public function getSocialAccounts()
{
$connected = [];
/** @var UserSocialAccount[] $accounts */
$accounts = $this->hasMany(UserSocialAccount::class, ['user_id' => 'id'])->all();
/**
* @var UserSocialAccount $account
*/
foreach ($accounts as $account) {
$connected[$account->provider] = $account;
}
return $connected;
} | php | public function getSocialAccounts()
{
$connected = [];
/** @var UserSocialAccount[] $accounts */
$accounts = $this->hasMany(UserSocialAccount::class, ['user_id' => 'id'])->all();
/**
* @var UserSocialAccount $account
*/
foreach ($accounts as $account) {
$connected[$account->provider] = $account;
}
return $connected;
} | [
"public",
"function",
"getSocialAccounts",
"(",
")",
"{",
"$",
"connected",
"=",
"[",
"]",
";",
"/** @var UserSocialAccount[] $accounts */",
"$",
"accounts",
"=",
"$",
"this",
"->",
"hasMany",
"(",
"UserSocialAccount",
"::",
"class",
",",
"[",
"'user_id'",
"=>",
"'id'",
"]",
")",
"->",
"all",
"(",
")",
";",
"/**\n * @var UserSocialAccount $account\n */",
"foreach",
"(",
"$",
"accounts",
"as",
"$",
"account",
")",
"{",
"$",
"connected",
"[",
"$",
"account",
"->",
"provider",
"]",
"=",
"$",
"account",
";",
"}",
"return",
"$",
"connected",
";",
"}"
] | 返回所有已经连接的社交媒体账户
@return UserSocialAccount[] Connected accounts ($provider => $account) | [
"返回所有已经连接的社交媒体账户"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L176-L189 |
yuncms/framework | src/user/models/User.php | User.increaseTransferBalance | public function increaseTransferBalance($amount)
{
$this->transfer_balance = bcadd($this->transfer_balance, $amount);
if ($this->transfer_balance < 0) {//计算后如果余额小于0,那么结果不合法。
return false;
}
$transaction = static::getDb()->beginTransaction();//开始事务
try {
if ($this->save()) {
$transaction->commit();
return true;
} else {
$transaction->rollBack();
return false;
}
} catch (\Exception $e) {
$transaction->rollBack();
Yii::error($e->getMessage(), __METHOD__);
} catch (\yii\db\Exception $e) {
$transaction->rollBack();
Yii::error($e->getMessage(), __METHOD__);
}
return false;
} | php | public function increaseTransferBalance($amount)
{
$this->transfer_balance = bcadd($this->transfer_balance, $amount);
if ($this->transfer_balance < 0) {//计算后如果余额小于0,那么结果不合法。
return false;
}
$transaction = static::getDb()->beginTransaction();//开始事务
try {
if ($this->save()) {
$transaction->commit();
return true;
} else {
$transaction->rollBack();
return false;
}
} catch (\Exception $e) {
$transaction->rollBack();
Yii::error($e->getMessage(), __METHOD__);
} catch (\yii\db\Exception $e) {
$transaction->rollBack();
Yii::error($e->getMessage(), __METHOD__);
}
return false;
} | [
"public",
"function",
"increaseTransferBalance",
"(",
"$",
"amount",
")",
"{",
"$",
"this",
"->",
"transfer_balance",
"=",
"bcadd",
"(",
"$",
"this",
"->",
"transfer_balance",
",",
"$",
"amount",
")",
";",
"if",
"(",
"$",
"this",
"->",
"transfer_balance",
"<",
"0",
")",
"{",
"//计算后如果余额小于0,那么结果不合法。",
"return",
"false",
";",
"}",
"$",
"transaction",
"=",
"static",
"::",
"getDb",
"(",
")",
"->",
"beginTransaction",
"(",
")",
";",
"//开始事务",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"save",
"(",
")",
")",
"{",
"$",
"transaction",
"->",
"commit",
"(",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"transaction",
"->",
"rollBack",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"transaction",
"->",
"rollBack",
"(",
")",
";",
"Yii",
"::",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"__METHOD__",
")",
";",
"}",
"catch",
"(",
"\\",
"yii",
"\\",
"db",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"transaction",
"->",
"rollBack",
"(",
")",
";",
"Yii",
"::",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"__METHOD__",
")",
";",
"}",
"return",
"false",
";",
"}"
] | 增加或减少结算金额
@param float $amount
@return bool
@throws \yii\db\Exception | [
"增加或减少结算金额"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L360-L383 |
yuncms/framework | src/user/models/User.php | User.register | public function register()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$this->password = Yii::$app->settings->get('user.enableGeneratingPassword') ? PasswordHelper::generate(8) : $this->password;
if ($this->scenario == self::SCENARIO_EMAIL_REGISTER) {
$this->email_confirmed_at = Yii::$app->settings->get('user.enableConfirmation') ? null : time();
}
$this->trigger(self::BEFORE_REGISTER);
if (!$this->save()) {
return false;
}
if (Yii::$app->settings->get('user.enableConfirmation') && !empty($this->email)) {
/** @var UserToken $token */
$token = new UserToken(['type' => UserToken::TYPE_CONFIRMATION]);
$token->link('user', $this);
Yii::$app->sendMail($this->email, Yii::t('yuncms', 'Welcome to {0}', Yii::$app->name), 'user/welcome', ['user' => $this, 'token' => isset($token) ? $token : null, 'module' => Yii::$app->getModule('user'), 'showPassword' => false]);
} else {
Yii::$app->user->login($this, Yii::$app->settings->get('user.rememberFor'));
}
$this->trigger(self::AFTER_REGISTER);
return true;
} | php | public function register()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$this->password = Yii::$app->settings->get('user.enableGeneratingPassword') ? PasswordHelper::generate(8) : $this->password;
if ($this->scenario == self::SCENARIO_EMAIL_REGISTER) {
$this->email_confirmed_at = Yii::$app->settings->get('user.enableConfirmation') ? null : time();
}
$this->trigger(self::BEFORE_REGISTER);
if (!$this->save()) {
return false;
}
if (Yii::$app->settings->get('user.enableConfirmation') && !empty($this->email)) {
/** @var UserToken $token */
$token = new UserToken(['type' => UserToken::TYPE_CONFIRMATION]);
$token->link('user', $this);
Yii::$app->sendMail($this->email, Yii::t('yuncms', 'Welcome to {0}', Yii::$app->name), 'user/welcome', ['user' => $this, 'token' => isset($token) ? $token : null, 'module' => Yii::$app->getModule('user'), 'showPassword' => false]);
} else {
Yii::$app->user->login($this, Yii::$app->settings->get('user.rememberFor'));
}
$this->trigger(self::AFTER_REGISTER);
return true;
} | [
"public",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsNewRecord",
"(",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Calling \"'",
".",
"__CLASS__",
".",
"'::'",
".",
"__METHOD__",
".",
"'\" on existing user'",
")",
";",
"}",
"$",
"this",
"->",
"password",
"=",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"get",
"(",
"'user.enableGeneratingPassword'",
")",
"?",
"PasswordHelper",
"::",
"generate",
"(",
"8",
")",
":",
"$",
"this",
"->",
"password",
";",
"if",
"(",
"$",
"this",
"->",
"scenario",
"==",
"self",
"::",
"SCENARIO_EMAIL_REGISTER",
")",
"{",
"$",
"this",
"->",
"email_confirmed_at",
"=",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"get",
"(",
"'user.enableConfirmation'",
")",
"?",
"null",
":",
"time",
"(",
")",
";",
"}",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"BEFORE_REGISTER",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"save",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"get",
"(",
"'user.enableConfirmation'",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"email",
")",
")",
"{",
"/** @var UserToken $token */",
"$",
"token",
"=",
"new",
"UserToken",
"(",
"[",
"'type'",
"=>",
"UserToken",
"::",
"TYPE_CONFIRMATION",
"]",
")",
";",
"$",
"token",
"->",
"link",
"(",
"'user'",
",",
"$",
"this",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"sendMail",
"(",
"$",
"this",
"->",
"email",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Welcome to {0}'",
",",
"Yii",
"::",
"$",
"app",
"->",
"name",
")",
",",
"'user/welcome'",
",",
"[",
"'user'",
"=>",
"$",
"this",
",",
"'token'",
"=>",
"isset",
"(",
"$",
"token",
")",
"?",
"$",
"token",
":",
"null",
",",
"'module'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"getModule",
"(",
"'user'",
")",
",",
"'showPassword'",
"=>",
"false",
"]",
")",
";",
"}",
"else",
"{",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"login",
"(",
"$",
"this",
",",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"get",
"(",
"'user.rememberFor'",
")",
")",
";",
"}",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"AFTER_REGISTER",
")",
";",
"return",
"true",
";",
"}"
] | 此方法用于注册新用户帐户。 如果 enableConfirmation 设置为true,则此方法
将生成新的确认令牌,并使用邮件发送给用户。
@return boolean | [
"此方法用于注册新用户帐户。",
"如果",
"enableConfirmation",
"设置为true,则此方法",
"将生成新的确认令牌,并使用邮件发送给用户。"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L402-L425 |
yuncms/framework | src/user/models/User.php | User.createUser | public function createUser()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$this->password = $this->password == null ? PasswordHelper::generate(8) : $this->password;
$this->trigger(self::BEFORE_CREATE);
if (!$this->save()) {
return false;
}
$this->trigger(self::AFTER_CREATE);
return true;
} | php | public function createUser()
{
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$this->password = $this->password == null ? PasswordHelper::generate(8) : $this->password;
$this->trigger(self::BEFORE_CREATE);
if (!$this->save()) {
return false;
}
$this->trigger(self::AFTER_CREATE);
return true;
} | [
"public",
"function",
"createUser",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsNewRecord",
"(",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Calling \"'",
".",
"__CLASS__",
".",
"'::'",
".",
"__METHOD__",
".",
"'\" on existing user'",
")",
";",
"}",
"$",
"this",
"->",
"password",
"=",
"$",
"this",
"->",
"password",
"==",
"null",
"?",
"PasswordHelper",
"::",
"generate",
"(",
"8",
")",
":",
"$",
"this",
"->",
"password",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"BEFORE_CREATE",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"save",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"AFTER_CREATE",
")",
";",
"return",
"true",
";",
"}"
] | 创建新用户帐户。 如果用户不提供密码,则会生成密码。
@return boolean | [
"创建新用户帐户。",
"如果用户不提供密码,则会生成密码。"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L432-L444 |
yuncms/framework | src/user/models/User.php | User.getNotifications | public function getNotifications()
{
if ($this instanceof RESTUser) {
return $this->hasMany(RESTDatabaseNotification::class, ['notifiable_id' => 'id'])
->onCondition(['notifiable_class' => self::class])
->addOrderBy(['created_at' => SORT_DESC]);
} else {
return $this->hasMany(DatabaseNotification::class, ['notifiable_id' => 'id'])
->onCondition(['notifiable_class' => self::class])
->addOrderBy(['created_at' => SORT_DESC]);
}
} | php | public function getNotifications()
{
if ($this instanceof RESTUser) {
return $this->hasMany(RESTDatabaseNotification::class, ['notifiable_id' => 'id'])
->onCondition(['notifiable_class' => self::class])
->addOrderBy(['created_at' => SORT_DESC]);
} else {
return $this->hasMany(DatabaseNotification::class, ['notifiable_id' => 'id'])
->onCondition(['notifiable_class' => self::class])
->addOrderBy(['created_at' => SORT_DESC]);
}
} | [
"public",
"function",
"getNotifications",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"instanceof",
"RESTUser",
")",
"{",
"return",
"$",
"this",
"->",
"hasMany",
"(",
"RESTDatabaseNotification",
"::",
"class",
",",
"[",
"'notifiable_id'",
"=>",
"'id'",
"]",
")",
"->",
"onCondition",
"(",
"[",
"'notifiable_class'",
"=>",
"self",
"::",
"class",
"]",
")",
"->",
"addOrderBy",
"(",
"[",
"'created_at'",
"=>",
"SORT_DESC",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"hasMany",
"(",
"DatabaseNotification",
"::",
"class",
",",
"[",
"'notifiable_id'",
"=>",
"'id'",
"]",
")",
"->",
"onCondition",
"(",
"[",
"'notifiable_class'",
"=>",
"self",
"::",
"class",
"]",
")",
"->",
"addOrderBy",
"(",
"[",
"'created_at'",
"=>",
"SORT_DESC",
"]",
")",
";",
"}",
"}"
] | Get the entity's notifications.
@return \yii\db\ActiveQuery | [
"Get",
"the",
"entity",
"s",
"notifications",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/User.php#L459-L470 |
zodream/thirdparty | src/ALi/OAuth.php | OAuth.token | public function token($code) {
if (!is_array($code)) {
$code = [
'code' => $code,
];
}
return $this->getToken()->parameters($code)->text();
} | php | public function token($code) {
if (!is_array($code)) {
$code = [
'code' => $code,
];
}
return $this->getToken()->parameters($code)->text();
} | [
"public",
"function",
"token",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"code",
")",
")",
"{",
"$",
"code",
"=",
"[",
"'code'",
"=>",
"$",
"code",
",",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"getToken",
"(",
")",
"->",
"parameters",
"(",
"$",
"code",
")",
"->",
"text",
"(",
")",
";",
"}"
] | 获取token
@param $code
@return mixed
@throws \Exception | [
"获取token"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/ALi/OAuth.php#L29-L36 |
whisller/IrcBotBundle | EventListener/Plugins/Commands/DateTimeCommandListener.php | DateTimeCommandListener.onCommand | public function onCommand(BotCommandFoundEvent $event)
{
$arguments = $event->getArguments();
$timezone = date_default_timezone_get();
if (isset($arguments[0]) && ('' !== trim($arguments[0]))) {
if (in_array($arguments[0], \DateTimeZone::listIdentifiers())) {
$timezone = $arguments[0];
}
}
$dateTime = new \DateTime('now', new \DateTimeZone($timezone));
$this->sendMessage(array($event->getChannel()), $dateTime->format('Y-m-d H:i:s').' '.$timezone);
} | php | public function onCommand(BotCommandFoundEvent $event)
{
$arguments = $event->getArguments();
$timezone = date_default_timezone_get();
if (isset($arguments[0]) && ('' !== trim($arguments[0]))) {
if (in_array($arguments[0], \DateTimeZone::listIdentifiers())) {
$timezone = $arguments[0];
}
}
$dateTime = new \DateTime('now', new \DateTimeZone($timezone));
$this->sendMessage(array($event->getChannel()), $dateTime->format('Y-m-d H:i:s').' '.$timezone);
} | [
"public",
"function",
"onCommand",
"(",
"BotCommandFoundEvent",
"$",
"event",
")",
"{",
"$",
"arguments",
"=",
"$",
"event",
"->",
"getArguments",
"(",
")",
";",
"$",
"timezone",
"=",
"date_default_timezone_get",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
"&&",
"(",
"''",
"!==",
"trim",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"arguments",
"[",
"0",
"]",
",",
"\\",
"DateTimeZone",
"::",
"listIdentifiers",
"(",
")",
")",
")",
"{",
"$",
"timezone",
"=",
"$",
"arguments",
"[",
"0",
"]",
";",
"}",
"}",
"$",
"dateTime",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
",",
"new",
"\\",
"DateTimeZone",
"(",
"$",
"timezone",
")",
")",
";",
"$",
"this",
"->",
"sendMessage",
"(",
"array",
"(",
"$",
"event",
"->",
"getChannel",
"(",
")",
")",
",",
"$",
"dateTime",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
".",
"' '",
".",
"$",
"timezone",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/whisller/IrcBotBundle/blob/d8bcafc1599cbbc7756b0a59f51ee988a2de0f2e/EventListener/Plugins/Commands/DateTimeCommandListener.php#L17-L32 |
marcmascarell/arrayer | src/Arrayer.php | Arrayer.arrayDot | protected function arrayDot($array, $prepend = null)
{
if (function_exists('array_dot')) {
return array_dot($array);
}
$results = [];
foreach ($array as $key => $value) {
if (is_array($value)) {
$results = array_merge($results, $this->arrayDot($value, $prepend.$key.'.'));
} else {
$results[$prepend.$key] = $value;
}
}
return $results;
} | php | protected function arrayDot($array, $prepend = null)
{
if (function_exists('array_dot')) {
return array_dot($array);
}
$results = [];
foreach ($array as $key => $value) {
if (is_array($value)) {
$results = array_merge($results, $this->arrayDot($value, $prepend.$key.'.'));
} else {
$results[$prepend.$key] = $value;
}
}
return $results;
} | [
"protected",
"function",
"arrayDot",
"(",
"$",
"array",
",",
"$",
"prepend",
"=",
"null",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'array_dot'",
")",
")",
"{",
"return",
"array_dot",
"(",
"$",
"array",
")",
";",
"}",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"results",
"=",
"array_merge",
"(",
"$",
"results",
",",
"$",
"this",
"->",
"arrayDot",
"(",
"$",
"value",
",",
"$",
"prepend",
".",
"$",
"key",
".",
"'.'",
")",
")",
";",
"}",
"else",
"{",
"$",
"results",
"[",
"$",
"prepend",
".",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] | Flatten a multi-dimensional associative array with dots.
From Laravel framework.
@param array $array
@param string $prepend
@return array | [
"Flatten",
"a",
"multi",
"-",
"dimensional",
"associative",
"array",
"with",
"dots",
".",
"From",
"Laravel",
"framework",
"."
] | train | https://github.com/marcmascarell/arrayer/blob/7c8e8fa95fd15d8f2f7c6ddf1142aa7d32735b09/src/Arrayer.php#L145-L162 |
UnionOfRAD/li3_behaviors | data/model/Behavior.php | Behavior.config | public function config($key = null, $value = null) {
if (is_array($key)) {
return $this->_config = $key + $this->_config;
}
if ($key === null) {
return $this->_config;
}
if ($value !== null) {
return $this->_config[$key] = $value;
}
return isset($this->_config[$key]) ? $this->_config[$key] : null;
} | php | public function config($key = null, $value = null) {
if (is_array($key)) {
return $this->_config = $key + $this->_config;
}
if ($key === null) {
return $this->_config;
}
if ($value !== null) {
return $this->_config[$key] = $value;
}
return isset($this->_config[$key]) ? $this->_config[$key] : null;
} | [
"public",
"function",
"config",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_config",
"=",
"$",
"key",
"+",
"$",
"this",
"->",
"_config",
";",
"}",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_config",
";",
"}",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_config",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"_config",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"_config",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | Gets/sets the configuration, allows for introspecting and changing behavior configuration.
@param string|array $key A configuration key or if `null` (default) returns whole
configuration. If array will merge config values with existing.
@param mixed $value Configuration value if `null` (default) will return $key.
@return array|string Configuration array or configuration option value if $key was string. | [
"Gets",
"/",
"sets",
"the",
"configuration",
"allows",
"for",
"introspecting",
"and",
"changing",
"behavior",
"configuration",
"."
] | train | https://github.com/UnionOfRAD/li3_behaviors/blob/b7051a300f91323f8776088b20e84c79790015ea/data/model/Behavior.php#L170-L181 |
andrelohmann/silverstripe-geolocation | code/defaults/AddGeodistanceFunction.php | AddGeodistanceFunction.requireDefaultRecords | public function requireDefaultRecords() {
parent::requireDefaultRecords();
if(defined('CREATE_GEODISTANCE_UDF') && GEOFORM_CREATE_GEODISTANCE_UDF){
if(!defined('CreateGeodistanceOnce')){
define('CreateGeodistanceOnce', true);
$q1 = "DROP FUNCTION IF EXISTS geodistance;";
$q2 = "
CREATE FUNCTION `geodistance`(lat1 DOUBLE, lng1 DOUBLE, lat2 DOUBLE, lng2 DOUBLE) RETURNS double
NO SQL
BEGIN
DECLARE radius DOUBLE;
DECLARE distance DOUBLE;
DECLARE vara DOUBLE;
DECLARE varb DOUBLE;
DECLARE varc DOUBLE;
SET lat1 = RADIANS(lat1);
SET lng1 = RADIANS(lng1);
SET lat2 = RADIANS(lat2);
SET lng2 = RADIANS(lng2);
SET radius = 6371.0;
SET varb = SIN((lat2 - lat1) / 2.0);
SET varc = SIN((lng2 - lng1) / 2.0);
SET vara = SQRT((varb * varb) + (COS(lat1) * COS(lat2) * (varc * varc)));
SET distance = radius * (2.0 * ASIN(CASE WHEN 1.0 < vara THEN 1.0 ELSE vara END));
RETURN distance;
END
";
DB::query($q1);
DB::query($q2);
DB::alteration_message('MySQL geodistance function created', 'created');
}
}
} | php | public function requireDefaultRecords() {
parent::requireDefaultRecords();
if(defined('CREATE_GEODISTANCE_UDF') && GEOFORM_CREATE_GEODISTANCE_UDF){
if(!defined('CreateGeodistanceOnce')){
define('CreateGeodistanceOnce', true);
$q1 = "DROP FUNCTION IF EXISTS geodistance;";
$q2 = "
CREATE FUNCTION `geodistance`(lat1 DOUBLE, lng1 DOUBLE, lat2 DOUBLE, lng2 DOUBLE) RETURNS double
NO SQL
BEGIN
DECLARE radius DOUBLE;
DECLARE distance DOUBLE;
DECLARE vara DOUBLE;
DECLARE varb DOUBLE;
DECLARE varc DOUBLE;
SET lat1 = RADIANS(lat1);
SET lng1 = RADIANS(lng1);
SET lat2 = RADIANS(lat2);
SET lng2 = RADIANS(lng2);
SET radius = 6371.0;
SET varb = SIN((lat2 - lat1) / 2.0);
SET varc = SIN((lng2 - lng1) / 2.0);
SET vara = SQRT((varb * varb) + (COS(lat1) * COS(lat2) * (varc * varc)));
SET distance = radius * (2.0 * ASIN(CASE WHEN 1.0 < vara THEN 1.0 ELSE vara END));
RETURN distance;
END
";
DB::query($q1);
DB::query($q2);
DB::alteration_message('MySQL geodistance function created', 'created');
}
}
} | [
"public",
"function",
"requireDefaultRecords",
"(",
")",
"{",
"parent",
"::",
"requireDefaultRecords",
"(",
")",
";",
"if",
"(",
"defined",
"(",
"'CREATE_GEODISTANCE_UDF'",
")",
"&&",
"GEOFORM_CREATE_GEODISTANCE_UDF",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'CreateGeodistanceOnce'",
")",
")",
"{",
"define",
"(",
"'CreateGeodistanceOnce'",
",",
"true",
")",
";",
"$",
"q1",
"=",
"\"DROP FUNCTION IF EXISTS geodistance;\"",
";",
"$",
"q2",
"=",
"\"\nCREATE FUNCTION `geodistance`(lat1 DOUBLE, lng1 DOUBLE, lat2 DOUBLE, lng2 DOUBLE) RETURNS double\n NO SQL\nBEGIN\nDECLARE radius DOUBLE;\nDECLARE distance DOUBLE;\nDECLARE vara DOUBLE;\nDECLARE varb DOUBLE;\nDECLARE varc DOUBLE;\nSET lat1 = RADIANS(lat1);\nSET lng1 = RADIANS(lng1);\nSET lat2 = RADIANS(lat2);\nSET lng2 = RADIANS(lng2);\nSET radius = 6371.0;\nSET varb = SIN((lat2 - lat1) / 2.0);\nSET varc = SIN((lng2 - lng1) / 2.0);\nSET vara = SQRT((varb * varb) + (COS(lat1) * COS(lat2) * (varc * varc)));\nSET distance = radius * (2.0 * ASIN(CASE WHEN 1.0 < vara THEN 1.0 ELSE vara END));\nRETURN distance;\nEND\n\"",
";",
"DB",
"::",
"query",
"(",
"$",
"q1",
")",
";",
"DB",
"::",
"query",
"(",
"$",
"q2",
")",
";",
"DB",
"::",
"alteration_message",
"(",
"'MySQL geodistance function created'",
",",
"'created'",
")",
";",
"}",
"}",
"}"
] | Set Default Frontend group for new members | [
"Set",
"Default",
"Frontend",
"group",
"for",
"new",
"members"
] | train | https://github.com/andrelohmann/silverstripe-geolocation/blob/124062008d8fa25b631bf5bb69b2ca79b53ef81b/code/defaults/AddGeodistanceFunction.php#L9-L44 |
alanpich/slender | src/Core/ConfigParser/Stack.php | Stack.parseFile | public function parseFile($path)
{
// Check file exists
if (!is_readable((string) $path)) {
throw new ConfigFileNotFoundException("$path does not exist, or is not readable");
}
$extension = pathinfo($path,PATHINFO_EXTENSION);
if (isset($this->parsers[$extension])) {
return $this->parsers[$extension]->parseFile($path);
}
throw new ConfigFileFormatException("$extension is not a known config file format");
} | php | public function parseFile($path)
{
// Check file exists
if (!is_readable((string) $path)) {
throw new ConfigFileNotFoundException("$path does not exist, or is not readable");
}
$extension = pathinfo($path,PATHINFO_EXTENSION);
if (isset($this->parsers[$extension])) {
return $this->parsers[$extension]->parseFile($path);
}
throw new ConfigFileFormatException("$extension is not a known config file format");
} | [
"public",
"function",
"parseFile",
"(",
"$",
"path",
")",
"{",
"// Check file exists",
"if",
"(",
"!",
"is_readable",
"(",
"(",
"string",
")",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"ConfigFileNotFoundException",
"(",
"\"$path does not exist, or is not readable\"",
")",
";",
"}",
"$",
"extension",
"=",
"pathinfo",
"(",
"$",
"path",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parsers",
"[",
"$",
"extension",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parsers",
"[",
"$",
"extension",
"]",
"->",
"parseFile",
"(",
"$",
"path",
")",
";",
"}",
"throw",
"new",
"ConfigFileFormatException",
"(",
"\"$extension is not a known config file format\"",
")",
";",
"}"
] | Parse $path and return array of config from within
@param string $path Path to file
@throws \Slender\Exception\ConfigFileFormatException when unable to parse file
@throws \Slender\Exception\ConfigFileNotFoundException when $path does not exist
@return array | [
"Parse",
"$path",
"and",
"return",
"array",
"of",
"config",
"from",
"within"
] | train | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ConfigParser/Stack.php#L60-L73 |
devture/dbal | src/Devture/Component/DBAL/Repository/EavSqlRepository.php | EavSqlRepository.findAllByQuery | public function findAllByQuery($query, array $params = array()) {
//Not using the parent findAllByQuery() implementation, becaus
//it performs one-by-one EAV fetching, which is very bad for performance.
//Instead, we find all main records with 1 query. And then fine all EAV entries (for all),
//with a single additional query (instead of one per main record).
$records = array();
$recordIds = array();
foreach ($this->db->fetchAll($query, $params) as $data) {
$records[] = $data;
$recordIds[] = $data['_id'];
}
$dataPerNamespaceFlattened = $this->pullEavDataForAll($recordIds);
$results = array();
foreach ($records as $data) {
$data['__eav_data__'] = $dataPerNamespaceFlattened[$data['_id']];
$results[] = $this->loadModel($data);
}
return $results;
} | php | public function findAllByQuery($query, array $params = array()) {
//Not using the parent findAllByQuery() implementation, becaus
//it performs one-by-one EAV fetching, which is very bad for performance.
//Instead, we find all main records with 1 query. And then fine all EAV entries (for all),
//with a single additional query (instead of one per main record).
$records = array();
$recordIds = array();
foreach ($this->db->fetchAll($query, $params) as $data) {
$records[] = $data;
$recordIds[] = $data['_id'];
}
$dataPerNamespaceFlattened = $this->pullEavDataForAll($recordIds);
$results = array();
foreach ($records as $data) {
$data['__eav_data__'] = $dataPerNamespaceFlattened[$data['_id']];
$results[] = $this->loadModel($data);
}
return $results;
} | [
"public",
"function",
"findAllByQuery",
"(",
"$",
"query",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"//Not using the parent findAllByQuery() implementation, becaus",
"//it performs one-by-one EAV fetching, which is very bad for performance.",
"//Instead, we find all main records with 1 query. And then fine all EAV entries (for all),",
"//with a single additional query (instead of one per main record).",
"$",
"records",
"=",
"array",
"(",
")",
";",
"$",
"recordIds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"db",
"->",
"fetchAll",
"(",
"$",
"query",
",",
"$",
"params",
")",
"as",
"$",
"data",
")",
"{",
"$",
"records",
"[",
"]",
"=",
"$",
"data",
";",
"$",
"recordIds",
"[",
"]",
"=",
"$",
"data",
"[",
"'_id'",
"]",
";",
"}",
"$",
"dataPerNamespaceFlattened",
"=",
"$",
"this",
"->",
"pullEavDataForAll",
"(",
"$",
"recordIds",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"records",
"as",
"$",
"data",
")",
"{",
"$",
"data",
"[",
"'__eav_data__'",
"]",
"=",
"$",
"dataPerNamespaceFlattened",
"[",
"$",
"data",
"[",
"'_id'",
"]",
"]",
";",
"$",
"results",
"[",
"]",
"=",
"$",
"this",
"->",
"loadModel",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | {@inheritDoc}
@see \Devture\Component\DBAL\Repository\BaseSqlRepository::findAllByQuery() | [
"{"
] | train | https://github.com/devture/dbal/blob/e2538d13baf9220fc388a48596acd176cd2bb42f/src/Devture/Component/DBAL/Repository/EavSqlRepository.php#L111-L133 |
ARCANEDEV/Sanitizer | src/Entities/Rules.php | Rules.set | public function set(array $rules)
{
$this->items = array_merge(
$this->items,
$this->parseRules($rules)
);
return $this;
} | php | public function set(array $rules)
{
$this->items = array_merge(
$this->items,
$this->parseRules($rules)
);
return $this;
} | [
"public",
"function",
"set",
"(",
"array",
"$",
"rules",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"this",
"->",
"parseRules",
"(",
"$",
"rules",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set multiple rules.
@param array $rules
@return $this | [
"Set",
"multiple",
"rules",
"."
] | train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Entities/Rules.php#L43-L51 |
ARCANEDEV/Sanitizer | src/Entities/Rules.php | Rules.parseRules | protected function parseRules(array $rules)
{
$parsedRules = [];
foreach ($rules as $attribute => $filters) {
if (empty($filters)) {
throw new InvalidFilterException(
"The attribute [$attribute] must contain at least one filter."
);
}
$this->parseAttributeFilters($parsedRules, $attribute, $filters);
}
return $parsedRules;
} | php | protected function parseRules(array $rules)
{
$parsedRules = [];
foreach ($rules as $attribute => $filters) {
if (empty($filters)) {
throw new InvalidFilterException(
"The attribute [$attribute] must contain at least one filter."
);
}
$this->parseAttributeFilters($parsedRules, $attribute, $filters);
}
return $parsedRules;
} | [
"protected",
"function",
"parseRules",
"(",
"array",
"$",
"rules",
")",
"{",
"$",
"parsedRules",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"attribute",
"=>",
"$",
"filters",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"filters",
")",
")",
"{",
"throw",
"new",
"InvalidFilterException",
"(",
"\"The attribute [$attribute] must contain at least one filter.\"",
")",
";",
"}",
"$",
"this",
"->",
"parseAttributeFilters",
"(",
"$",
"parsedRules",
",",
"$",
"attribute",
",",
"$",
"filters",
")",
";",
"}",
"return",
"$",
"parsedRules",
";",
"}"
] | Parse a rules array.
@param array $rules
@return array
@throws \Arcanedev\Sanitizer\Exceptions\InvalidFilterException | [
"Parse",
"a",
"rules",
"array",
"."
] | train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Entities/Rules.php#L90-L105 |
ARCANEDEV/Sanitizer | src/Entities/Rules.php | Rules.parseAttributeFilters | protected function parseAttributeFilters(array &$parsedRules, $attribute, $filters)
{
foreach (explode('|', $filters) as $filter) {
$parsedFilter = $this->parseRule($filter);
if ( ! empty($parsedFilter)) {
$parsedRules[$attribute][] = $parsedFilter;
}
}
} | php | protected function parseAttributeFilters(array &$parsedRules, $attribute, $filters)
{
foreach (explode('|', $filters) as $filter) {
$parsedFilter = $this->parseRule($filter);
if ( ! empty($parsedFilter)) {
$parsedRules[$attribute][] = $parsedFilter;
}
}
} | [
"protected",
"function",
"parseAttributeFilters",
"(",
"array",
"&",
"$",
"parsedRules",
",",
"$",
"attribute",
",",
"$",
"filters",
")",
"{",
"foreach",
"(",
"explode",
"(",
"'|'",
",",
"$",
"filters",
")",
"as",
"$",
"filter",
")",
"{",
"$",
"parsedFilter",
"=",
"$",
"this",
"->",
"parseRule",
"(",
"$",
"filter",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsedFilter",
")",
")",
"{",
"$",
"parsedRules",
"[",
"$",
"attribute",
"]",
"[",
"]",
"=",
"$",
"parsedFilter",
";",
"}",
"}",
"}"
] | Parse attribute's filters.
@param array $parsedRules
@param string $attribute
@param string $filters | [
"Parse",
"attribute",
"s",
"filters",
"."
] | train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Entities/Rules.php#L114-L123 |
ARCANEDEV/Sanitizer | src/Entities/Rules.php | Rules.parseRule | protected function parseRule($rule)
{
$name = $rule;
$options = [];
if (str_contains($rule, ':')) {
list($name, $options) = explode(':', $rule, 2);
$options = array_map('trim', explode(',', $options));
}
return empty($name) ? [] : compact('name', 'options');
} | php | protected function parseRule($rule)
{
$name = $rule;
$options = [];
if (str_contains($rule, ':')) {
list($name, $options) = explode(':', $rule, 2);
$options = array_map('trim', explode(',', $options));
}
return empty($name) ? [] : compact('name', 'options');
} | [
"protected",
"function",
"parseRule",
"(",
"$",
"rule",
")",
"{",
"$",
"name",
"=",
"$",
"rule",
";",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"str_contains",
"(",
"$",
"rule",
",",
"':'",
")",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"options",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"rule",
",",
"2",
")",
";",
"$",
"options",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"','",
",",
"$",
"options",
")",
")",
";",
"}",
"return",
"empty",
"(",
"$",
"name",
")",
"?",
"[",
"]",
":",
"compact",
"(",
"'name'",
",",
"'options'",
")",
";",
"}"
] | Parse a rule.
@param string $rule
@return array | [
"Parse",
"a",
"rule",
"."
] | train | https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Entities/Rules.php#L132-L143 |
Chill-project/Main | Routing/MenuTwig.php | MenuTwig.chillMenu | public function chillMenu($menuId, array $params = array())
{
$resolvedParams = array_merge($this->defaultParams, $params);
$layout = $resolvedParams['layout'];
unset($resolvedParams['layout']);
$resolvedParams['routes'] = $this->menuComposer->getRoutesFor($menuId);
return $this->container->get('templating')
->render($layout, $resolvedParams);
} | php | public function chillMenu($menuId, array $params = array())
{
$resolvedParams = array_merge($this->defaultParams, $params);
$layout = $resolvedParams['layout'];
unset($resolvedParams['layout']);
$resolvedParams['routes'] = $this->menuComposer->getRoutesFor($menuId);
return $this->container->get('templating')
->render($layout, $resolvedParams);
} | [
"public",
"function",
"chillMenu",
"(",
"$",
"menuId",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"resolvedParams",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defaultParams",
",",
"$",
"params",
")",
";",
"$",
"layout",
"=",
"$",
"resolvedParams",
"[",
"'layout'",
"]",
";",
"unset",
"(",
"$",
"resolvedParams",
"[",
"'layout'",
"]",
")",
";",
"$",
"resolvedParams",
"[",
"'routes'",
"]",
"=",
"$",
"this",
"->",
"menuComposer",
"->",
"getRoutesFor",
"(",
"$",
"menuId",
")",
";",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"render",
"(",
"$",
"layout",
",",
"$",
"resolvedParams",
")",
";",
"}"
] | Render a Menu corresponding to $menuId
Expected params :
- args: the arguments to build the path (i.e: if pattern is /something/{bar}, args must contain {'bar': 'foo'}
- layout: the layout. Absolute path needed (i.e.: ChillXyzBundle:section:foo.html.twig)
- activeRouteKey : the key active, will render the menu differently.
see https://redmine.champs-libres.coop/issues/179 for more informations
@param string $menuId
@param mixed[] $params | [
"Render",
"a",
"Menu",
"corresponding",
"to",
"$menuId"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Routing/MenuTwig.php#L84-L95 |
ixocreate/application | src/Http/ErrorHandling/Factory/WhoopsFactory.php | WhoopsFactory.registerJsonHandler | private function registerJsonHandler(Whoops $whoops, $config) : void
{
if (empty($config['json_exceptions']['display'])) {
return;
}
$handler = new JsonResponseHandler();
if (! empty($config['json_exceptions']['show_trace'])) {
$handler->addTraceToOutput(true);
}
if (! empty($config['json_exceptions']['ajax_only'])) {
if (\method_exists(WhoopsUtil::class, 'isAjaxRequest')) {
// Whoops 2.x; don't push handler on stack unless we are in
// an XHR request.
if (! WhoopsUtil::isAjaxRequest()) {
return;
}
} elseif (\method_exists($handler, 'onlyForAjaxRequests')) {
// Whoops 1.x
$handler->onlyForAjaxRequests(true);
}
}
$whoops->pushHandler($handler);
} | php | private function registerJsonHandler(Whoops $whoops, $config) : void
{
if (empty($config['json_exceptions']['display'])) {
return;
}
$handler = new JsonResponseHandler();
if (! empty($config['json_exceptions']['show_trace'])) {
$handler->addTraceToOutput(true);
}
if (! empty($config['json_exceptions']['ajax_only'])) {
if (\method_exists(WhoopsUtil::class, 'isAjaxRequest')) {
// Whoops 2.x; don't push handler on stack unless we are in
// an XHR request.
if (! WhoopsUtil::isAjaxRequest()) {
return;
}
} elseif (\method_exists($handler, 'onlyForAjaxRequests')) {
// Whoops 1.x
$handler->onlyForAjaxRequests(true);
}
}
$whoops->pushHandler($handler);
} | [
"private",
"function",
"registerJsonHandler",
"(",
"Whoops",
"$",
"whoops",
",",
"$",
"config",
")",
":",
"void",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
"[",
"'json_exceptions'",
"]",
"[",
"'display'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"handler",
"=",
"new",
"JsonResponseHandler",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'json_exceptions'",
"]",
"[",
"'show_trace'",
"]",
")",
")",
"{",
"$",
"handler",
"->",
"addTraceToOutput",
"(",
"true",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'json_exceptions'",
"]",
"[",
"'ajax_only'",
"]",
")",
")",
"{",
"if",
"(",
"\\",
"method_exists",
"(",
"WhoopsUtil",
"::",
"class",
",",
"'isAjaxRequest'",
")",
")",
"{",
"// Whoops 2.x; don't push handler on stack unless we are in",
"// an XHR request.",
"if",
"(",
"!",
"WhoopsUtil",
"::",
"isAjaxRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"}",
"elseif",
"(",
"\\",
"method_exists",
"(",
"$",
"handler",
",",
"'onlyForAjaxRequests'",
")",
")",
"{",
"// Whoops 1.x",
"$",
"handler",
"->",
"onlyForAjaxRequests",
"(",
"true",
")",
";",
"}",
"}",
"$",
"whoops",
"->",
"pushHandler",
"(",
"$",
"handler",
")",
";",
"}"
] | If configuration indicates a JsonResponseHandler, configure and register it.
@param Whoops $whoops
@param array|\ArrayAccess $config
@return void | [
"If",
"configuration",
"indicates",
"a",
"JsonResponseHandler",
"configure",
"and",
"register",
"it",
"."
] | train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/ErrorHandling/Factory/WhoopsFactory.php#L54-L80 |
atkrad/data-tables | src/ArrayAccessTrait.php | ArrayAccessTrait.offsetGet | public function offsetGet($offset)
{
if (array_key_exists($offset, $this->properties)) {
return $this->properties[$offset];
} else {
return $this->properties;
}
} | php | public function offsetGet($offset)
{
if (array_key_exists($offset, $this->properties)) {
return $this->properties[$offset];
} else {
return $this->properties;
}
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"properties",
")",
")",
"{",
"return",
"$",
"this",
"->",
"properties",
"[",
"$",
"offset",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"properties",
";",
"}",
"}"
] | Offset to retrieve
@param mixed $offset The offset to retrieve.
@return mixed Can return all value types.
@link http://php.net/manual/en/arrayaccess.offsetget.php | [
"Offset",
"to",
"retrieve"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/ArrayAccessTrait.php#L34-L41 |
redaigbaria/oauth2 | src/Entity/EntityTrait.php | EntityTrait.hydrate | public function hydrate(array $properties)
{
foreach ($properties as $prop => $val) {
if (property_exists($this, $prop)) {
$this->{$prop} = $val;
}
}
return $this;
} | php | public function hydrate(array $properties)
{
foreach ($properties as $prop => $val) {
if (property_exists($this, $prop)) {
$this->{$prop} = $val;
}
}
return $this;
} | [
"public",
"function",
"hydrate",
"(",
"array",
"$",
"properties",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"prop",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"prop",
")",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"prop",
"}",
"=",
"$",
"val",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Hydrate an entity with properites
@param array $properties
@return self | [
"Hydrate",
"an",
"entity",
"with",
"properites"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/EntityTrait.php#L23-L32 |
webforge-labs/psc-cms | lib/Psc/Graph/Alg.php | Alg.BFS | public static function BFS(Graph $g, BFSVertice $s) {
if (!$g->has($s)) throw new Exception('Startknoten '.$s.' ist nicht im Graphen g vorhanden');
foreach($g->V() as $vertice) {
$vertice->color = 'weiss';
$vertice->d = PHP_INT_MAX;
$vertice->parent = NULL;
}
$s->color = 'grau';
$s->parent = NULL;
$s->d = 0;
$queue = array($s);
while (count($queue) > 0) {
$u = array_shift($queue);
foreach($g->N($u) as $v) {
if ($v->color == 'weiss') {
$v->color = 'grau';
$v->d = $u->d + 1;
$v->parent = $u;
$u->childs[] = $v;
array_push($queue,$v);
}
}
$u->color = 'schwarz';
}
} | php | public static function BFS(Graph $g, BFSVertice $s) {
if (!$g->has($s)) throw new Exception('Startknoten '.$s.' ist nicht im Graphen g vorhanden');
foreach($g->V() as $vertice) {
$vertice->color = 'weiss';
$vertice->d = PHP_INT_MAX;
$vertice->parent = NULL;
}
$s->color = 'grau';
$s->parent = NULL;
$s->d = 0;
$queue = array($s);
while (count($queue) > 0) {
$u = array_shift($queue);
foreach($g->N($u) as $v) {
if ($v->color == 'weiss') {
$v->color = 'grau';
$v->d = $u->d + 1;
$v->parent = $u;
$u->childs[] = $v;
array_push($queue,$v);
}
}
$u->color = 'schwarz';
}
} | [
"public",
"static",
"function",
"BFS",
"(",
"Graph",
"$",
"g",
",",
"BFSVertice",
"$",
"s",
")",
"{",
"if",
"(",
"!",
"$",
"g",
"->",
"has",
"(",
"$",
"s",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Startknoten '",
".",
"$",
"s",
".",
"' ist nicht im Graphen g vorhanden'",
")",
";",
"foreach",
"(",
"$",
"g",
"->",
"V",
"(",
")",
"as",
"$",
"vertice",
")",
"{",
"$",
"vertice",
"->",
"color",
"=",
"'weiss'",
";",
"$",
"vertice",
"->",
"d",
"=",
"PHP_INT_MAX",
";",
"$",
"vertice",
"->",
"parent",
"=",
"NULL",
";",
"}",
"$",
"s",
"->",
"color",
"=",
"'grau'",
";",
"$",
"s",
"->",
"parent",
"=",
"NULL",
";",
"$",
"s",
"->",
"d",
"=",
"0",
";",
"$",
"queue",
"=",
"array",
"(",
"$",
"s",
")",
";",
"while",
"(",
"count",
"(",
"$",
"queue",
")",
">",
"0",
")",
"{",
"$",
"u",
"=",
"array_shift",
"(",
"$",
"queue",
")",
";",
"foreach",
"(",
"$",
"g",
"->",
"N",
"(",
"$",
"u",
")",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"->",
"color",
"==",
"'weiss'",
")",
"{",
"$",
"v",
"->",
"color",
"=",
"'grau'",
";",
"$",
"v",
"->",
"d",
"=",
"$",
"u",
"->",
"d",
"+",
"1",
";",
"$",
"v",
"->",
"parent",
"=",
"$",
"u",
";",
"$",
"u",
"->",
"childs",
"[",
"]",
"=",
"$",
"v",
";",
"array_push",
"(",
"$",
"queue",
",",
"$",
"v",
")",
";",
"}",
"}",
"$",
"u",
"->",
"color",
"=",
"'schwarz'",
";",
"}",
"}"
] | Breitensuche
Algorithmus aus C. Cormen / E. Leiserson / R. Rivest / C. Stein: Algorithmen - Eine Einführung
@param Graph $g der Graph sollte nur aus GraphBFSVertice bestehen (das ist selber zu überprüfen aus Performancegründen)
@param GraphBFSVertice $s der Startknoten | [
"Breitensuche"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/Alg.php#L14-L42 |
webforge-labs/psc-cms | lib/Psc/Graph/Alg.php | Alg.TopologicalSort | public static function TopologicalSort(Graph $g) {
$list = array();
if (count($g->V()) == 0) return $list;
// rufe DFS auf $g auf
// füge jeden abgearbeiteten Knoten an den Kopf einer Liste ein
$dfsVisit = function (DependencyVertice $vertice) use ($g, &$list, &$dfsVisit) {
if (!$vertice->isVisited()) {
$vertice->setVisited(TRUE);
foreach ($g->N($vertice) as $adjacentVertice) {
$dfsVisit($adjacentVertice);
}
array_unshift($list,$vertice);
}
};
// wir beginnen nicht mit einem Startknoten sondern mit allen Startknoten, die keine dependencies haben
$s = array();
foreach ($g->V() as $vertice) {
if (count($vertice->getDependencies()) === 0) {
$s[] = $vertice;
$dfsVisit($vertice);
}
}
if (count($s) === 0) {
throw new TopologicalSortRuntimeException('Der Graph g kann nicht topologisch sortiert werden. Es wurden keine Startknoten gefunden die überhaupt keine Dependencies haben');
}
return $list;
} | php | public static function TopologicalSort(Graph $g) {
$list = array();
if (count($g->V()) == 0) return $list;
// rufe DFS auf $g auf
// füge jeden abgearbeiteten Knoten an den Kopf einer Liste ein
$dfsVisit = function (DependencyVertice $vertice) use ($g, &$list, &$dfsVisit) {
if (!$vertice->isVisited()) {
$vertice->setVisited(TRUE);
foreach ($g->N($vertice) as $adjacentVertice) {
$dfsVisit($adjacentVertice);
}
array_unshift($list,$vertice);
}
};
// wir beginnen nicht mit einem Startknoten sondern mit allen Startknoten, die keine dependencies haben
$s = array();
foreach ($g->V() as $vertice) {
if (count($vertice->getDependencies()) === 0) {
$s[] = $vertice;
$dfsVisit($vertice);
}
}
if (count($s) === 0) {
throw new TopologicalSortRuntimeException('Der Graph g kann nicht topologisch sortiert werden. Es wurden keine Startknoten gefunden die überhaupt keine Dependencies haben');
}
return $list;
} | [
"public",
"static",
"function",
"TopologicalSort",
"(",
"Graph",
"$",
"g",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"g",
"->",
"V",
"(",
")",
")",
"==",
"0",
")",
"return",
"$",
"list",
";",
"// rufe DFS auf $g auf",
"// füge jeden abgearbeiteten Knoten an den Kopf einer Liste ein",
"$",
"dfsVisit",
"=",
"function",
"(",
"DependencyVertice",
"$",
"vertice",
")",
"use",
"(",
"$",
"g",
",",
"&",
"$",
"list",
",",
"&",
"$",
"dfsVisit",
")",
"{",
"if",
"(",
"!",
"$",
"vertice",
"->",
"isVisited",
"(",
")",
")",
"{",
"$",
"vertice",
"->",
"setVisited",
"(",
"TRUE",
")",
";",
"foreach",
"(",
"$",
"g",
"->",
"N",
"(",
"$",
"vertice",
")",
"as",
"$",
"adjacentVertice",
")",
"{",
"$",
"dfsVisit",
"(",
"$",
"adjacentVertice",
")",
";",
"}",
"array_unshift",
"(",
"$",
"list",
",",
"$",
"vertice",
")",
";",
"}",
"}",
";",
"// wir beginnen nicht mit einem Startknoten sondern mit allen Startknoten, die keine dependencies haben",
"$",
"s",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"g",
"->",
"V",
"(",
")",
"as",
"$",
"vertice",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"vertice",
"->",
"getDependencies",
"(",
")",
")",
"===",
"0",
")",
"{",
"$",
"s",
"[",
"]",
"=",
"$",
"vertice",
";",
"$",
"dfsVisit",
"(",
"$",
"vertice",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"s",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"TopologicalSortRuntimeException",
"(",
"'Der Graph g kann nicht topologisch sortiert werden. Es wurden keine Startknoten gefunden die überhaupt keine Dependencies haben')",
";",
"",
"}",
"return",
"$",
"list",
";",
"}"
] | Der Graph muss aus DependencyVertices bestehen
die besonderen Knoten brauchen wir, da wir "hasOutgoingEdges()" nicht ganz easy berechnen können
(wir bräuchten die EdgesList flipped)
Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford (2001), "Section 22.4: Topological sort", Introduction to Algorithms (2nd ed.), MIT Press and McGraw-Hill, pp. 549–552, ISBN 0-262-03293-7.
gibt eine Liste aller Vertices in der topologischen Sortierung zurück
die elemente mit "den meisten dependencies" befinden sich hinten in der liste
@return array | [
"Der",
"Graph",
"muss",
"aus",
"DependencyVertices",
"bestehen"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/Alg.php#L57-L89 |
jfusion/org.jfusion.framework | src/User/Groups.php | Groups.get | public static function get($jname = '', $default = false) {
if (!isset($groups)) {
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('value')
->from('#__jfusion_settings')
->where($db->quoteName('key') . ' = ' . $db->quote('user.groups'));
$db->setQuery($query);
$groups = $db->loadResult();
if ($groups) {
$groups = new Registry($groups);
$groups = $groups->toObject();
} else {
$groups = false;
}
}
if ($jname) {
if (isset($groups->{$jname})) {
$usergroups = $groups->{$jname};
if ($default) {
if (isset($usergroups[0])) {
$usergroups = $usergroups[0];
} else {
$usergroups = null;
}
}
} else {
if ($default) {
$usergroups = null;
} else {
$usergroups = array();
}
}
} else {
$usergroups = $groups;
}
return $usergroups;
} | php | public static function get($jname = '', $default = false) {
if (!isset($groups)) {
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('value')
->from('#__jfusion_settings')
->where($db->quoteName('key') . ' = ' . $db->quote('user.groups'));
$db->setQuery($query);
$groups = $db->loadResult();
if ($groups) {
$groups = new Registry($groups);
$groups = $groups->toObject();
} else {
$groups = false;
}
}
if ($jname) {
if (isset($groups->{$jname})) {
$usergroups = $groups->{$jname};
if ($default) {
if (isset($usergroups[0])) {
$usergroups = $usergroups[0];
} else {
$usergroups = null;
}
}
} else {
if ($default) {
$usergroups = null;
} else {
$usergroups = array();
}
}
} else {
$usergroups = $groups;
}
return $usergroups;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"jname",
"=",
"''",
",",
"$",
"default",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"groups",
")",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDbo",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'value'",
")",
"->",
"from",
"(",
"'#__jfusion_settings'",
")",
"->",
"where",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'key'",
")",
".",
"' = '",
".",
"$",
"db",
"->",
"quote",
"(",
"'user.groups'",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"groups",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"if",
"(",
"$",
"groups",
")",
"{",
"$",
"groups",
"=",
"new",
"Registry",
"(",
"$",
"groups",
")",
";",
"$",
"groups",
"=",
"$",
"groups",
"->",
"toObject",
"(",
")",
";",
"}",
"else",
"{",
"$",
"groups",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"jname",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"groups",
"->",
"{",
"$",
"jname",
"}",
")",
")",
"{",
"$",
"usergroups",
"=",
"$",
"groups",
"->",
"{",
"$",
"jname",
"}",
";",
"if",
"(",
"$",
"default",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"usergroups",
"[",
"0",
"]",
")",
")",
"{",
"$",
"usergroups",
"=",
"$",
"usergroups",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"usergroups",
"=",
"null",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"default",
")",
"{",
"$",
"usergroups",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"usergroups",
"=",
"array",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"usergroups",
"=",
"$",
"groups",
";",
"}",
"return",
"$",
"usergroups",
";",
"}"
] | @param string $jname
@param bool $default
@return mixed; | [
"@param",
"string",
"$jname",
"@param",
"bool",
"$default"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Groups.php#L36-L79 |
jfusion/org.jfusion.framework | src/User/Groups.php | Groups.isUpdate | public static function isUpdate($jname) {
$updateusergroups = static::getUpdate();
$advanced = false;
if (isset($updateusergroups->{$jname}) && $updateusergroups->{$jname}) {
$master = Framework::getMaster();
if ($master && $master->name != $jname) {
$advanced = true;
}
}
return $advanced;
} | php | public static function isUpdate($jname) {
$updateusergroups = static::getUpdate();
$advanced = false;
if (isset($updateusergroups->{$jname}) && $updateusergroups->{$jname}) {
$master = Framework::getMaster();
if ($master && $master->name != $jname) {
$advanced = true;
}
}
return $advanced;
} | [
"public",
"static",
"function",
"isUpdate",
"(",
"$",
"jname",
")",
"{",
"$",
"updateusergroups",
"=",
"static",
"::",
"getUpdate",
"(",
")",
";",
"$",
"advanced",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"updateusergroups",
"->",
"{",
"$",
"jname",
"}",
")",
"&&",
"$",
"updateusergroups",
"->",
"{",
"$",
"jname",
"}",
")",
"{",
"$",
"master",
"=",
"Framework",
"::",
"getMaster",
"(",
")",
";",
"if",
"(",
"$",
"master",
"&&",
"$",
"master",
"->",
"name",
"!=",
"$",
"jname",
")",
"{",
"$",
"advanced",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"advanced",
";",
"}"
] | returns true / false if the plugin is in advanced usergroup mode or not...
@param string $jname plugin name
@return boolean | [
"returns",
"true",
"/",
"false",
"if",
"the",
"plugin",
"is",
"in",
"advanced",
"usergroup",
"mode",
"or",
"not",
"..."
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/Groups.php#L157-L167 |
shrink0r/workflux | src/Builder/Factory.php | Factory.createState | public function createState(string $name, array $state = null): StateInterface
{
$state = Maybe::unit($state);
$state_implementor = $this->resolveStateImplementor($state);
$settings = $state->settings->get() ?? [];
$settings['_output'] = $state->output->get() ?? [];
$state_instance = new $state_implementor(
$name,
new Settings($settings),
$this->createValidator($name, $state),
$this->expression_engine
);
if ($state->final->get() && !$state_instance->isFinal()) {
throw new ConfigError("Trying to provide custom state that isn't final but marked as final in config.");
}
if ($state->initial->get() && !$state_instance->isInitial()) {
throw new ConfigError("Trying to provide custom state that isn't initial but marked as initial in config.");
}
if ($state->interactive->get() && !$state_instance->isInteractive()) {
throw new ConfigError(
"Trying to provide custom state that isn't interactive but marked as interactive in config."
);
}
return $state_instance;
} | php | public function createState(string $name, array $state = null): StateInterface
{
$state = Maybe::unit($state);
$state_implementor = $this->resolveStateImplementor($state);
$settings = $state->settings->get() ?? [];
$settings['_output'] = $state->output->get() ?? [];
$state_instance = new $state_implementor(
$name,
new Settings($settings),
$this->createValidator($name, $state),
$this->expression_engine
);
if ($state->final->get() && !$state_instance->isFinal()) {
throw new ConfigError("Trying to provide custom state that isn't final but marked as final in config.");
}
if ($state->initial->get() && !$state_instance->isInitial()) {
throw new ConfigError("Trying to provide custom state that isn't initial but marked as initial in config.");
}
if ($state->interactive->get() && !$state_instance->isInteractive()) {
throw new ConfigError(
"Trying to provide custom state that isn't interactive but marked as interactive in config."
);
}
return $state_instance;
} | [
"public",
"function",
"createState",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"state",
"=",
"null",
")",
":",
"StateInterface",
"{",
"$",
"state",
"=",
"Maybe",
"::",
"unit",
"(",
"$",
"state",
")",
";",
"$",
"state_implementor",
"=",
"$",
"this",
"->",
"resolveStateImplementor",
"(",
"$",
"state",
")",
";",
"$",
"settings",
"=",
"$",
"state",
"->",
"settings",
"->",
"get",
"(",
")",
"??",
"[",
"]",
";",
"$",
"settings",
"[",
"'_output'",
"]",
"=",
"$",
"state",
"->",
"output",
"->",
"get",
"(",
")",
"??",
"[",
"]",
";",
"$",
"state_instance",
"=",
"new",
"$",
"state_implementor",
"(",
"$",
"name",
",",
"new",
"Settings",
"(",
"$",
"settings",
")",
",",
"$",
"this",
"->",
"createValidator",
"(",
"$",
"name",
",",
"$",
"state",
")",
",",
"$",
"this",
"->",
"expression_engine",
")",
";",
"if",
"(",
"$",
"state",
"->",
"final",
"->",
"get",
"(",
")",
"&&",
"!",
"$",
"state_instance",
"->",
"isFinal",
"(",
")",
")",
"{",
"throw",
"new",
"ConfigError",
"(",
"\"Trying to provide custom state that isn't final but marked as final in config.\"",
")",
";",
"}",
"if",
"(",
"$",
"state",
"->",
"initial",
"->",
"get",
"(",
")",
"&&",
"!",
"$",
"state_instance",
"->",
"isInitial",
"(",
")",
")",
"{",
"throw",
"new",
"ConfigError",
"(",
"\"Trying to provide custom state that isn't initial but marked as initial in config.\"",
")",
";",
"}",
"if",
"(",
"$",
"state",
"->",
"interactive",
"->",
"get",
"(",
")",
"&&",
"!",
"$",
"state_instance",
"->",
"isInteractive",
"(",
")",
")",
"{",
"throw",
"new",
"ConfigError",
"(",
"\"Trying to provide custom state that isn't interactive but marked as interactive in config.\"",
")",
";",
"}",
"return",
"$",
"state_instance",
";",
"}"
] | @param string $name
@param mixed[]|null $state
@return StateInterface | [
"@param",
"string",
"$name",
"@param",
"mixed",
"[]",
"|null",
"$state"
] | train | https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Builder/Factory.php#L68-L92 |
shrink0r/workflux | src/Builder/Factory.php | Factory.createTransition | public function createTransition(string $from, string $to, array $config = null): TransitionInterface
{
$transition = Maybe::unit($config);
if (is_string($transition->when->get())) {
$config['when'] = [ $transition->when->get() ];
}
$implementor = $transition->class->get() ?? $this->class_map->get('transition');
if (!in_array(TransitionInterface::CLASS, class_implements($implementor))) {
throw new MissingImplementation(
'Trying to create transition without implementing required '.TransitionInterface::CLASS
);
}
$constraints = [];
foreach (Maybe::unit($config)->when->get() ?? [] as $expression) {
if (!is_string($expression)) {
continue;
}
$constraints[] = new ExpressionConstraint($expression, $this->expression_engine);
}
$settings = new Settings(Maybe::unit($config)->settings->get() ?? []);
return new $implementor($from, $to, $settings, $constraints);
} | php | public function createTransition(string $from, string $to, array $config = null): TransitionInterface
{
$transition = Maybe::unit($config);
if (is_string($transition->when->get())) {
$config['when'] = [ $transition->when->get() ];
}
$implementor = $transition->class->get() ?? $this->class_map->get('transition');
if (!in_array(TransitionInterface::CLASS, class_implements($implementor))) {
throw new MissingImplementation(
'Trying to create transition without implementing required '.TransitionInterface::CLASS
);
}
$constraints = [];
foreach (Maybe::unit($config)->when->get() ?? [] as $expression) {
if (!is_string($expression)) {
continue;
}
$constraints[] = new ExpressionConstraint($expression, $this->expression_engine);
}
$settings = new Settings(Maybe::unit($config)->settings->get() ?? []);
return new $implementor($from, $to, $settings, $constraints);
} | [
"public",
"function",
"createTransition",
"(",
"string",
"$",
"from",
",",
"string",
"$",
"to",
",",
"array",
"$",
"config",
"=",
"null",
")",
":",
"TransitionInterface",
"{",
"$",
"transition",
"=",
"Maybe",
"::",
"unit",
"(",
"$",
"config",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"transition",
"->",
"when",
"->",
"get",
"(",
")",
")",
")",
"{",
"$",
"config",
"[",
"'when'",
"]",
"=",
"[",
"$",
"transition",
"->",
"when",
"->",
"get",
"(",
")",
"]",
";",
"}",
"$",
"implementor",
"=",
"$",
"transition",
"->",
"class",
"->",
"get",
"(",
")",
"??",
"$",
"this",
"->",
"class_map",
"->",
"get",
"(",
"'transition'",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"TransitionInterface",
"::",
"CLASS",
",",
"class_implements",
"(",
"$",
"implementor",
")",
")",
")",
"{",
"throw",
"new",
"MissingImplementation",
"(",
"'Trying to create transition without implementing required '",
".",
"TransitionInterface",
"::",
"CLASS",
")",
";",
"}",
"$",
"constraints",
"=",
"[",
"]",
";",
"foreach",
"(",
"Maybe",
"::",
"unit",
"(",
"$",
"config",
")",
"->",
"when",
"->",
"get",
"(",
")",
"??",
"[",
"]",
"as",
"$",
"expression",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"expression",
")",
")",
"{",
"continue",
";",
"}",
"$",
"constraints",
"[",
"]",
"=",
"new",
"ExpressionConstraint",
"(",
"$",
"expression",
",",
"$",
"this",
"->",
"expression_engine",
")",
";",
"}",
"$",
"settings",
"=",
"new",
"Settings",
"(",
"Maybe",
"::",
"unit",
"(",
"$",
"config",
")",
"->",
"settings",
"->",
"get",
"(",
")",
"??",
"[",
"]",
")",
";",
"return",
"new",
"$",
"implementor",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"settings",
",",
"$",
"constraints",
")",
";",
"}"
] | @param string $from
@param string $to
@param mixed[]|null $transition
@return TransitionInterface | [
"@param",
"string",
"$from",
"@param",
"string",
"$to",
"@param",
"mixed",
"[]",
"|null",
"$transition"
] | train | https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Builder/Factory.php#L101-L122 |
shrink0r/workflux | src/Builder/Factory.php | Factory.resolveStateImplementor | private function resolveStateImplementor(Maybe $state): string
{
switch (true) {
case $state->initial->get():
$state_implementor = $this->class_map->get('initial');
break;
case $state->final->get() === true || $state->get() === null: // cast null to final-state by convention
$state_implementor = $this->class_map->get('final');
break;
case $state->interactive->get():
$state_implementor = $this->class_map->get('interactive');
break;
default:
$state_implementor = $this->class_map->get('state');
}
$state_implementor = $state->class->get() ?? $state_implementor;
if (!in_array(StateInterface::CLASS, class_implements($state_implementor))) {
throw new MissingImplementation(
'Trying to use a custom-state that does not implement required '.StateInterface::CLASS
);
}
return $state_implementor;
} | php | private function resolveStateImplementor(Maybe $state): string
{
switch (true) {
case $state->initial->get():
$state_implementor = $this->class_map->get('initial');
break;
case $state->final->get() === true || $state->get() === null: // cast null to final-state by convention
$state_implementor = $this->class_map->get('final');
break;
case $state->interactive->get():
$state_implementor = $this->class_map->get('interactive');
break;
default:
$state_implementor = $this->class_map->get('state');
}
$state_implementor = $state->class->get() ?? $state_implementor;
if (!in_array(StateInterface::CLASS, class_implements($state_implementor))) {
throw new MissingImplementation(
'Trying to use a custom-state that does not implement required '.StateInterface::CLASS
);
}
return $state_implementor;
} | [
"private",
"function",
"resolveStateImplementor",
"(",
"Maybe",
"$",
"state",
")",
":",
"string",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"state",
"->",
"initial",
"->",
"get",
"(",
")",
":",
"$",
"state_implementor",
"=",
"$",
"this",
"->",
"class_map",
"->",
"get",
"(",
"'initial'",
")",
";",
"break",
";",
"case",
"$",
"state",
"->",
"final",
"->",
"get",
"(",
")",
"===",
"true",
"||",
"$",
"state",
"->",
"get",
"(",
")",
"===",
"null",
":",
"// cast null to final-state by convention",
"$",
"state_implementor",
"=",
"$",
"this",
"->",
"class_map",
"->",
"get",
"(",
"'final'",
")",
";",
"break",
";",
"case",
"$",
"state",
"->",
"interactive",
"->",
"get",
"(",
")",
":",
"$",
"state_implementor",
"=",
"$",
"this",
"->",
"class_map",
"->",
"get",
"(",
"'interactive'",
")",
";",
"break",
";",
"default",
":",
"$",
"state_implementor",
"=",
"$",
"this",
"->",
"class_map",
"->",
"get",
"(",
"'state'",
")",
";",
"}",
"$",
"state_implementor",
"=",
"$",
"state",
"->",
"class",
"->",
"get",
"(",
")",
"??",
"$",
"state_implementor",
";",
"if",
"(",
"!",
"in_array",
"(",
"StateInterface",
"::",
"CLASS",
",",
"class_implements",
"(",
"$",
"state_implementor",
")",
")",
")",
"{",
"throw",
"new",
"MissingImplementation",
"(",
"'Trying to use a custom-state that does not implement required '",
".",
"StateInterface",
"::",
"CLASS",
")",
";",
"}",
"return",
"$",
"state_implementor",
";",
"}"
] | @param Maybe $state
@return string | [
"@param",
"Maybe",
"$state"
] | train | https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Builder/Factory.php#L129-L151 |
shrink0r/workflux | src/Builder/Factory.php | Factory.createValidator | private function createValidator(string $name, Maybe $state): ValidatorInterface
{
return new Validator(
$this->createValidationSchema(
$name.self::SUFFIX_IN,
$state->input_schema->get() ?? self::$default_validation_schema
),
$this->createValidationSchema(
$name.self::SUFFIX_OUT,
$state->output_schema->get() ?? self::$default_validation_schema
)
);
} | php | private function createValidator(string $name, Maybe $state): ValidatorInterface
{
return new Validator(
$this->createValidationSchema(
$name.self::SUFFIX_IN,
$state->input_schema->get() ?? self::$default_validation_schema
),
$this->createValidationSchema(
$name.self::SUFFIX_OUT,
$state->output_schema->get() ?? self::$default_validation_schema
)
);
} | [
"private",
"function",
"createValidator",
"(",
"string",
"$",
"name",
",",
"Maybe",
"$",
"state",
")",
":",
"ValidatorInterface",
"{",
"return",
"new",
"Validator",
"(",
"$",
"this",
"->",
"createValidationSchema",
"(",
"$",
"name",
".",
"self",
"::",
"SUFFIX_IN",
",",
"$",
"state",
"->",
"input_schema",
"->",
"get",
"(",
")",
"??",
"self",
"::",
"$",
"default_validation_schema",
")",
",",
"$",
"this",
"->",
"createValidationSchema",
"(",
"$",
"name",
".",
"self",
"::",
"SUFFIX_OUT",
",",
"$",
"state",
"->",
"output_schema",
"->",
"get",
"(",
")",
"??",
"self",
"::",
"$",
"default_validation_schema",
")",
")",
";",
"}"
] | @param string $name
@param Maybe $state
@return ValidatorInterface | [
"@param",
"string",
"$name",
"@param",
"Maybe",
"$state"
] | train | https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Builder/Factory.php#L159-L171 |
yuncms/framework | src/sms/Messenger.php | Messenger.send | public function send($to, $message, array $gateways = [])
{
$message = $this->formatMessage($message);
if (empty($gateways)) {
$gateways = $message->getGateways();
}
if (empty($gateways)) {
$gateways = $this->sms->defaultGateway;
}
$strategyAppliedGateways = $this->sms->strategy()->apply($gateways);
$results = [];
$isSuccessful = false;
foreach ($strategyAppliedGateways as $gateway) {
try {
$results[$gateway] = [
'status' => self::STATUS_SUCCESS,
'result' => $this->sms->get($gateway)->send($to, $message),
];
$isSuccessful = true;
break;
} catch (GatewayErrorException $e) {
$results[$gateway] = [
'status' => self::STATUS_FAILURE,
'exception' => $e,
];
continue;
}
}
if (!$isSuccessful) {
throw new NoGatewayAvailableException($results);
}
return $results;
} | php | public function send($to, $message, array $gateways = [])
{
$message = $this->formatMessage($message);
if (empty($gateways)) {
$gateways = $message->getGateways();
}
if (empty($gateways)) {
$gateways = $this->sms->defaultGateway;
}
$strategyAppliedGateways = $this->sms->strategy()->apply($gateways);
$results = [];
$isSuccessful = false;
foreach ($strategyAppliedGateways as $gateway) {
try {
$results[$gateway] = [
'status' => self::STATUS_SUCCESS,
'result' => $this->sms->get($gateway)->send($to, $message),
];
$isSuccessful = true;
break;
} catch (GatewayErrorException $e) {
$results[$gateway] = [
'status' => self::STATUS_FAILURE,
'exception' => $e,
];
continue;
}
}
if (!$isSuccessful) {
throw new NoGatewayAvailableException($results);
}
return $results;
} | [
"public",
"function",
"send",
"(",
"$",
"to",
",",
"$",
"message",
",",
"array",
"$",
"gateways",
"=",
"[",
"]",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"formatMessage",
"(",
"$",
"message",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"gateways",
")",
")",
"{",
"$",
"gateways",
"=",
"$",
"message",
"->",
"getGateways",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"gateways",
")",
")",
"{",
"$",
"gateways",
"=",
"$",
"this",
"->",
"sms",
"->",
"defaultGateway",
";",
"}",
"$",
"strategyAppliedGateways",
"=",
"$",
"this",
"->",
"sms",
"->",
"strategy",
"(",
")",
"->",
"apply",
"(",
"$",
"gateways",
")",
";",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"isSuccessful",
"=",
"false",
";",
"foreach",
"(",
"$",
"strategyAppliedGateways",
"as",
"$",
"gateway",
")",
"{",
"try",
"{",
"$",
"results",
"[",
"$",
"gateway",
"]",
"=",
"[",
"'status'",
"=>",
"self",
"::",
"STATUS_SUCCESS",
",",
"'result'",
"=>",
"$",
"this",
"->",
"sms",
"->",
"get",
"(",
"$",
"gateway",
")",
"->",
"send",
"(",
"$",
"to",
",",
"$",
"message",
")",
",",
"]",
";",
"$",
"isSuccessful",
"=",
"true",
";",
"break",
";",
"}",
"catch",
"(",
"GatewayErrorException",
"$",
"e",
")",
"{",
"$",
"results",
"[",
"$",
"gateway",
"]",
"=",
"[",
"'status'",
"=>",
"self",
"::",
"STATUS_FAILURE",
",",
"'exception'",
"=>",
"$",
"e",
",",
"]",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"isSuccessful",
")",
"{",
"throw",
"new",
"NoGatewayAvailableException",
"(",
"$",
"results",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | Send a message.
@param string|array $to
@param string|array|MessageInterface $message
@param array $gateways
@return array
@throws InvalidArgumentException
@throws NoGatewayAvailableException
@throws \yii\base\InvalidConfigException | [
"Send",
"a",
"message",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Messenger.php#L52-L84 |
titon/db | src/Titon/Db/Query/Join.php | Join.fields | public function fields($fields) {
if (!is_array($fields)) {
$fields = func_get_args();
}
$this->_fields = $fields;
return $this;
} | php | public function fields($fields) {
if (!is_array($fields)) {
$fields = func_get_args();
}
$this->_fields = $fields;
return $this;
} | [
"public",
"function",
"fields",
"(",
"$",
"fields",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"func_get_args",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_fields",
"=",
"$",
"fields",
";",
"return",
"$",
"this",
";",
"}"
] | Set the list of fields to return.
@param string|array $fields
@return $this | [
"Set",
"the",
"list",
"of",
"fields",
"to",
"return",
"."
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Join.php#L74-L82 |
titon/db | src/Titon/Db/Query/Join.php | Join.from | public function from($table, $alias = null) {
$this->_table = (string) $table;
$this->asAlias($alias);
return $this;
} | php | public function from($table, $alias = null) {
$this->_table = (string) $table;
$this->asAlias($alias);
return $this;
} | [
"public",
"function",
"from",
"(",
"$",
"table",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_table",
"=",
"(",
"string",
")",
"$",
"table",
";",
"$",
"this",
"->",
"asAlias",
"(",
"$",
"alias",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the table to join against.
@param string $table
@param string $alias
@return $this | [
"Set",
"the",
"table",
"to",
"join",
"against",
"."
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Join.php#L91-L96 |
titon/db | src/Titon/Db/Query/Join.php | Join.on | public function on($foreignKey, $key = null) {
if (is_array($foreignKey)) {
$this->_conditions = array_replace($this->_conditions, $foreignKey);
} else {
$this->_conditions[$foreignKey] = $key;
}
return $this;
} | php | public function on($foreignKey, $key = null) {
if (is_array($foreignKey)) {
$this->_conditions = array_replace($this->_conditions, $foreignKey);
} else {
$this->_conditions[$foreignKey] = $key;
}
return $this;
} | [
"public",
"function",
"on",
"(",
"$",
"foreignKey",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"foreignKey",
")",
")",
"{",
"$",
"this",
"->",
"_conditions",
"=",
"array_replace",
"(",
"$",
"this",
"->",
"_conditions",
",",
"$",
"foreignKey",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_conditions",
"[",
"$",
"foreignKey",
"]",
"=",
"$",
"key",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the conditions to join on.
@param string $foreignKey
@param string $key
@return $this | [
"Set",
"the",
"conditions",
"to",
"join",
"on",
"."
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query/Join.php#L141-L149 |
Lansoweb/LosReCaptcha | src/ConfigProvider.php | ConfigProvider.getViewHelperConfig | public function getViewHelperConfig()
{
return [
'aliases' => [
'losrecaptcha/recaptcha' => Form\View\Helper\Captcha\ReCaptcha::class,
'losrecaptcha/invisible' => Form\View\Helper\Captcha\Invisible::class,
],
'factories' => [
Form\View\Helper\Captcha\ReCaptcha::class => InvokableFactory::class,
Form\View\Helper\Captcha\Invisible::class => InvokableFactory::class,
],
];
} | php | public function getViewHelperConfig()
{
return [
'aliases' => [
'losrecaptcha/recaptcha' => Form\View\Helper\Captcha\ReCaptcha::class,
'losrecaptcha/invisible' => Form\View\Helper\Captcha\Invisible::class,
],
'factories' => [
Form\View\Helper\Captcha\ReCaptcha::class => InvokableFactory::class,
Form\View\Helper\Captcha\Invisible::class => InvokableFactory::class,
],
];
} | [
"public",
"function",
"getViewHelperConfig",
"(",
")",
"{",
"return",
"[",
"'aliases'",
"=>",
"[",
"'losrecaptcha/recaptcha'",
"=>",
"Form",
"\\",
"View",
"\\",
"Helper",
"\\",
"Captcha",
"\\",
"ReCaptcha",
"::",
"class",
",",
"'losrecaptcha/invisible'",
"=>",
"Form",
"\\",
"View",
"\\",
"Helper",
"\\",
"Captcha",
"\\",
"Invisible",
"::",
"class",
",",
"]",
",",
"'factories'",
"=>",
"[",
"Form",
"\\",
"View",
"\\",
"Helper",
"\\",
"Captcha",
"\\",
"ReCaptcha",
"::",
"class",
"=>",
"InvokableFactory",
"::",
"class",
",",
"Form",
"\\",
"View",
"\\",
"Helper",
"\\",
"Captcha",
"\\",
"Invisible",
"::",
"class",
"=>",
"InvokableFactory",
"::",
"class",
",",
"]",
",",
"]",
";",
"}"
] | Return zend-view helper configuration.
@return array | [
"Return",
"zend",
"-",
"view",
"helper",
"configuration",
"."
] | train | https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/ConfigProvider.php#L23-L35 |
AndreyKluev/yii2-shop-basket | models/SessionBasket.php | SessionBasket.loadProducts | public function loadProducts()
{
$this->basketProducts = Yii::$app->session->get($this->owner->storageName, []);
} | php | public function loadProducts()
{
$this->basketProducts = Yii::$app->session->get($this->owner->storageName, []);
} | [
"public",
"function",
"loadProducts",
"(",
")",
"{",
"$",
"this",
"->",
"basketProducts",
"=",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"owner",
"->",
"storageName",
",",
"[",
"]",
")",
";",
"}"
] | Загружает товары из сессии | [
"Загружает",
"товары",
"из",
"сессии"
] | train | https://github.com/AndreyKluev/yii2-shop-basket/blob/3bc529fd576a18403096f911112d5337cb5b1069/models/SessionBasket.php#L31-L34 |
AndreyKluev/yii2-shop-basket | models/SessionBasket.php | SessionBasket.insertProduct | public function insertProduct($hash, $pid, $price, $params=[], $count=1)
{
$this->loadProducts();
if(!$this->isProductInBasket($hash)) {
$this->basketProducts[$hash] = [
'count' => $count,
'id_product' => $pid,
'price' => $price,
'params' => Json::encode($params),
'created_at' => time(),
'updated_at' => time()
];
} else {
// Если кол-во == 0, то удаляем из корзины
if(0<$count) {
$this->basketProducts[$hash]['count'] = $count;
$this->basketProducts[$hash]['price'] = $price;
$this->basketProducts[$hash]['updated_at'] = time();
} else {
unset($this->basketProducts[$hash]);
}
}
Yii::$app->session->set($this->owner->storageName, $this->basketProducts);
// После изменения товара в корзине, нужно обновить наш кеш
$this->owner->cache = $this->getBasketProducts();
return [
'global' => [
'count' => Yii::$app->formatter->asInteger($this->getBasketCount()),
'total' => Yii::$app->formatter->asInteger($this->getBasketTotal()),
'cost' => Yii::$app->formatter->asCurrency($this->getBasketCost()),
],
'current' => [
'price' => Yii::$app->formatter->asCurrency($price),
'count' => $count,
'cost' => Yii::$app->formatter->asCurrency($price*$count),
],
'result' => $this->isProductInBasket($hash)
];
} | php | public function insertProduct($hash, $pid, $price, $params=[], $count=1)
{
$this->loadProducts();
if(!$this->isProductInBasket($hash)) {
$this->basketProducts[$hash] = [
'count' => $count,
'id_product' => $pid,
'price' => $price,
'params' => Json::encode($params),
'created_at' => time(),
'updated_at' => time()
];
} else {
// Если кол-во == 0, то удаляем из корзины
if(0<$count) {
$this->basketProducts[$hash]['count'] = $count;
$this->basketProducts[$hash]['price'] = $price;
$this->basketProducts[$hash]['updated_at'] = time();
} else {
unset($this->basketProducts[$hash]);
}
}
Yii::$app->session->set($this->owner->storageName, $this->basketProducts);
// После изменения товара в корзине, нужно обновить наш кеш
$this->owner->cache = $this->getBasketProducts();
return [
'global' => [
'count' => Yii::$app->formatter->asInteger($this->getBasketCount()),
'total' => Yii::$app->formatter->asInteger($this->getBasketTotal()),
'cost' => Yii::$app->formatter->asCurrency($this->getBasketCost()),
],
'current' => [
'price' => Yii::$app->formatter->asCurrency($price),
'count' => $count,
'cost' => Yii::$app->formatter->asCurrency($price*$count),
],
'result' => $this->isProductInBasket($hash)
];
} | [
"public",
"function",
"insertProduct",
"(",
"$",
"hash",
",",
"$",
"pid",
",",
"$",
"price",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"count",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"loadProducts",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isProductInBasket",
"(",
"$",
"hash",
")",
")",
"{",
"$",
"this",
"->",
"basketProducts",
"[",
"$",
"hash",
"]",
"=",
"[",
"'count'",
"=>",
"$",
"count",
",",
"'id_product'",
"=>",
"$",
"pid",
",",
"'price'",
"=>",
"$",
"price",
",",
"'params'",
"=>",
"Json",
"::",
"encode",
"(",
"$",
"params",
")",
",",
"'created_at'",
"=>",
"time",
"(",
")",
",",
"'updated_at'",
"=>",
"time",
"(",
")",
"]",
";",
"}",
"else",
"{",
"// Если кол-во == 0, то удаляем из корзины",
"if",
"(",
"0",
"<",
"$",
"count",
")",
"{",
"$",
"this",
"->",
"basketProducts",
"[",
"$",
"hash",
"]",
"[",
"'count'",
"]",
"=",
"$",
"count",
";",
"$",
"this",
"->",
"basketProducts",
"[",
"$",
"hash",
"]",
"[",
"'price'",
"]",
"=",
"$",
"price",
";",
"$",
"this",
"->",
"basketProducts",
"[",
"$",
"hash",
"]",
"[",
"'updated_at'",
"]",
"=",
"time",
"(",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"basketProducts",
"[",
"$",
"hash",
"]",
")",
";",
"}",
"}",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"set",
"(",
"$",
"this",
"->",
"owner",
"->",
"storageName",
",",
"$",
"this",
"->",
"basketProducts",
")",
";",
"// После изменения товара в корзине, нужно обновить наш кеш",
"$",
"this",
"->",
"owner",
"->",
"cache",
"=",
"$",
"this",
"->",
"getBasketProducts",
"(",
")",
";",
"return",
"[",
"'global'",
"=>",
"[",
"'count'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
"->",
"asInteger",
"(",
"$",
"this",
"->",
"getBasketCount",
"(",
")",
")",
",",
"'total'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
"->",
"asInteger",
"(",
"$",
"this",
"->",
"getBasketTotal",
"(",
")",
")",
",",
"'cost'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
"->",
"asCurrency",
"(",
"$",
"this",
"->",
"getBasketCost",
"(",
")",
")",
",",
"]",
",",
"'current'",
"=>",
"[",
"'price'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
"->",
"asCurrency",
"(",
"$",
"price",
")",
",",
"'count'",
"=>",
"$",
"count",
",",
"'cost'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
"->",
"asCurrency",
"(",
"$",
"price",
"*",
"$",
"count",
")",
",",
"]",
",",
"'result'",
"=>",
"$",
"this",
"->",
"isProductInBasket",
"(",
"$",
"hash",
")",
"]",
";",
"}"
] | Добавляет товар в корзину
@param $hash - уникальный Хэш товара
@param $pid - id товара
@param $price - цена товара
@param $params - дополнительные параметры товара
@param $count - количество
@return array
@throws HttpException
@throws \yii\base\InvalidParamException
@throws \yii\base\InvalidConfigException | [
"Добавляет",
"товар",
"в",
"корзину"
] | train | https://github.com/AndreyKluev/yii2-shop-basket/blob/3bc529fd576a18403096f911112d5337cb5b1069/models/SessionBasket.php#L58-L100 |
AndreyKluev/yii2-shop-basket | models/SessionBasket.php | SessionBasket.getBasketProducts | public function getBasketProducts()
{
$this->loadProducts();
return array_map(
function($item) {
$item['params'] = Json::decode($item['params']);
return $item;
},
$this->basketProducts
);
} | php | public function getBasketProducts()
{
$this->loadProducts();
return array_map(
function($item) {
$item['params'] = Json::decode($item['params']);
return $item;
},
$this->basketProducts
);
} | [
"public",
"function",
"getBasketProducts",
"(",
")",
"{",
"$",
"this",
"->",
"loadProducts",
"(",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"$",
"item",
"[",
"'params'",
"]",
"=",
"Json",
"::",
"decode",
"(",
"$",
"item",
"[",
"'params'",
"]",
")",
";",
"return",
"$",
"item",
";",
"}",
",",
"$",
"this",
"->",
"basketProducts",
")",
";",
"}"
] | Возвращает список товаров в корзине
@return array
@throws \yii\base\InvalidParamException | [
"Возвращает",
"список",
"товаров",
"в",
"корзине"
] | train | https://github.com/AndreyKluev/yii2-shop-basket/blob/3bc529fd576a18403096f911112d5337cb5b1069/models/SessionBasket.php#L107-L117 |
AndreyKluev/yii2-shop-basket | models/SessionBasket.php | SessionBasket.getBasketTotal | public function getBasketTotal()
{
$this->loadProducts();
$total = 0;
foreach($this->basketProducts as $bp) {
$total += $bp['count'];
}
return $total;
} | php | public function getBasketTotal()
{
$this->loadProducts();
$total = 0;
foreach($this->basketProducts as $bp) {
$total += $bp['count'];
}
return $total;
} | [
"public",
"function",
"getBasketTotal",
"(",
")",
"{",
"$",
"this",
"->",
"loadProducts",
"(",
")",
";",
"$",
"total",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"basketProducts",
"as",
"$",
"bp",
")",
"{",
"$",
"total",
"+=",
"$",
"bp",
"[",
"'count'",
"]",
";",
"}",
"return",
"$",
"total",
";",
"}"
] | Возвращает количество единиц товаров в корзине
@return int | [
"Возвращает",
"количество",
"единиц",
"товаров",
"в",
"корзине"
] | train | https://github.com/AndreyKluev/yii2-shop-basket/blob/3bc529fd576a18403096f911112d5337cb5b1069/models/SessionBasket.php#L150-L160 |
AndreyKluev/yii2-shop-basket | models/SessionBasket.php | SessionBasket.getBasketCost | public function getBasketCost()
{
$this->loadProducts();
$cost = 0;
foreach($this->basketProducts as $bp) {
$cost += $bp['count'] * $bp['price'];
}
return $cost;
} | php | public function getBasketCost()
{
$this->loadProducts();
$cost = 0;
foreach($this->basketProducts as $bp) {
$cost += $bp['count'] * $bp['price'];
}
return $cost;
} | [
"public",
"function",
"getBasketCost",
"(",
")",
"{",
"$",
"this",
"->",
"loadProducts",
"(",
")",
";",
"$",
"cost",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"basketProducts",
"as",
"$",
"bp",
")",
"{",
"$",
"cost",
"+=",
"$",
"bp",
"[",
"'count'",
"]",
"*",
"$",
"bp",
"[",
"'price'",
"]",
";",
"}",
"return",
"$",
"cost",
";",
"}"
] | Возвращает сумму товаров в корзине
@return float | [
"Возвращает",
"сумму",
"товаров",
"в",
"корзине"
] | train | https://github.com/AndreyKluev/yii2-shop-basket/blob/3bc529fd576a18403096f911112d5337cb5b1069/models/SessionBasket.php#L166-L176 |
nexusnetsoftgmbh/nexuscli | src/Nexus/DynamicModules/Business/Model/Hydrator/CommandHydrator.php | CommandHydrator.hydrateCommands | public function hydrateCommands(array $commands) : array
{
$modulesDone = [];
foreach ($this->finder->getModuleList() as $module) {
$moduleName = basename($module);
if (!\in_array($moduleName, $modulesDone, true)) {
$facade = Locator::getInstance()->{$moduleName}()->facade();
if (method_exists($facade, 'getCommands')) {
$commands = \array_merge($commands, $facade->getCommands());
}
$modulesDone[] = $moduleName;
}
}
return $commands;
} | php | public function hydrateCommands(array $commands) : array
{
$modulesDone = [];
foreach ($this->finder->getModuleList() as $module) {
$moduleName = basename($module);
if (!\in_array($moduleName, $modulesDone, true)) {
$facade = Locator::getInstance()->{$moduleName}()->facade();
if (method_exists($facade, 'getCommands')) {
$commands = \array_merge($commands, $facade->getCommands());
}
$modulesDone[] = $moduleName;
}
}
return $commands;
} | [
"public",
"function",
"hydrateCommands",
"(",
"array",
"$",
"commands",
")",
":",
"array",
"{",
"$",
"modulesDone",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"finder",
"->",
"getModuleList",
"(",
")",
"as",
"$",
"module",
")",
"{",
"$",
"moduleName",
"=",
"basename",
"(",
"$",
"module",
")",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"moduleName",
",",
"$",
"modulesDone",
",",
"true",
")",
")",
"{",
"$",
"facade",
"=",
"Locator",
"::",
"getInstance",
"(",
")",
"->",
"{",
"$",
"moduleName",
"}",
"(",
")",
"->",
"facade",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"facade",
",",
"'getCommands'",
")",
")",
"{",
"$",
"commands",
"=",
"\\",
"array_merge",
"(",
"$",
"commands",
",",
"$",
"facade",
"->",
"getCommands",
"(",
")",
")",
";",
"}",
"$",
"modulesDone",
"[",
"]",
"=",
"$",
"moduleName",
";",
"}",
"}",
"return",
"$",
"commands",
";",
"}"
] | @param array $commands
@return array | [
"@param",
"array",
"$commands"
] | train | https://github.com/nexusnetsoftgmbh/nexuscli/blob/8416b43d31ad56ea379ae2b0bf85d456e78ba67a/src/Nexus/DynamicModules/Business/Model/Hydrator/CommandHydrator.php#L32-L49 |
VincentChalnot/SidusEAVFilterBundle | Factory/EAVQueryHandlerFactory.php | EAVQueryHandlerFactory.createQueryHandler | public function createQueryHandler(
QueryHandlerConfigurationInterface $queryHandlerConfiguration
): QueryHandlerInterface {
return new EAVQueryHandler(
$this->filterTypeRegistry,
$queryHandlerConfiguration,
$this->entityManager,
$this->familyRegistry,
$this->filterHelper,
$this->dataLoader
);
} | php | public function createQueryHandler(
QueryHandlerConfigurationInterface $queryHandlerConfiguration
): QueryHandlerInterface {
return new EAVQueryHandler(
$this->filterTypeRegistry,
$queryHandlerConfiguration,
$this->entityManager,
$this->familyRegistry,
$this->filterHelper,
$this->dataLoader
);
} | [
"public",
"function",
"createQueryHandler",
"(",
"QueryHandlerConfigurationInterface",
"$",
"queryHandlerConfiguration",
")",
":",
"QueryHandlerInterface",
"{",
"return",
"new",
"EAVQueryHandler",
"(",
"$",
"this",
"->",
"filterTypeRegistry",
",",
"$",
"queryHandlerConfiguration",
",",
"$",
"this",
"->",
"entityManager",
",",
"$",
"this",
"->",
"familyRegistry",
",",
"$",
"this",
"->",
"filterHelper",
",",
"$",
"this",
"->",
"dataLoader",
")",
";",
"}"
] | @param QueryHandlerConfigurationInterface $queryHandlerConfiguration
@throws \UnexpectedValueException
@return QueryHandlerInterface | [
"@param",
"QueryHandlerConfigurationInterface",
"$queryHandlerConfiguration"
] | train | https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Factory/EAVQueryHandlerFactory.php#L63-L74 |
tomphp/patch-builder | spec/TomPHP/PatchBuilder/PatchBufferSpec.php | PatchBufferSpec.it_calls_delete_if_no_lines_are_given | public function it_calls_delete_if_no_lines_are_given()
{
$range = LineRange::createFromNumbers(5, 7);
$this->modified->delete($range)->shouldBeCalled();
$this->replace($range, array());
} | php | public function it_calls_delete_if_no_lines_are_given()
{
$range = LineRange::createFromNumbers(5, 7);
$this->modified->delete($range)->shouldBeCalled();
$this->replace($range, array());
} | [
"public",
"function",
"it_calls_delete_if_no_lines_are_given",
"(",
")",
"{",
"$",
"range",
"=",
"LineRange",
"::",
"createFromNumbers",
"(",
"5",
",",
"7",
")",
";",
"$",
"this",
"->",
"modified",
"->",
"delete",
"(",
"$",
"range",
")",
"->",
"shouldBeCalled",
"(",
")",
";",
"$",
"this",
"->",
"replace",
"(",
"$",
"range",
",",
"array",
"(",
")",
")",
";",
"}"
] | /*
replace() | [
"/",
"*",
"replace",
"()"
] | train | https://github.com/tomphp/patch-builder/blob/4419eaad23016c7db1deffc6cce3f539096c11ce/spec/TomPHP/PatchBuilder/PatchBufferSpec.php#L69-L76 |
tomphp/patch-builder | spec/TomPHP/PatchBuilder/PatchBufferSpec.php | PatchBufferSpec.it_skips_if_trying_to_insert_nothing | public function it_skips_if_trying_to_insert_nothing(LineNumber $line)
{
$this->modified->insert()->shouldNotBeCalled();
$this->insert($line, array());
} | php | public function it_skips_if_trying_to_insert_nothing(LineNumber $line)
{
$this->modified->insert()->shouldNotBeCalled();
$this->insert($line, array());
} | [
"public",
"function",
"it_skips_if_trying_to_insert_nothing",
"(",
"LineNumber",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"modified",
"->",
"insert",
"(",
")",
"->",
"shouldNotBeCalled",
"(",
")",
";",
"$",
"this",
"->",
"insert",
"(",
"$",
"line",
",",
"array",
"(",
")",
")",
";",
"}"
] | /*
insert() | [
"/",
"*",
"insert",
"()"
] | train | https://github.com/tomphp/patch-builder/blob/4419eaad23016c7db1deffc6cce3f539096c11ce/spec/TomPHP/PatchBuilder/PatchBufferSpec.php#L131-L136 |
tomphp/patch-builder | spec/TomPHP/PatchBuilder/PatchBufferSpec.php | PatchBufferSpec.it_skips_if_trying_to_append_nothing | public function it_skips_if_trying_to_append_nothing(LineNumber $line)
{
$this->modified->insert()->shouldNotBeCalled();
$this->append($line, array());
} | php | public function it_skips_if_trying_to_append_nothing(LineNumber $line)
{
$this->modified->insert()->shouldNotBeCalled();
$this->append($line, array());
} | [
"public",
"function",
"it_skips_if_trying_to_append_nothing",
"(",
"LineNumber",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"modified",
"->",
"insert",
"(",
")",
"->",
"shouldNotBeCalled",
"(",
")",
";",
"$",
"this",
"->",
"append",
"(",
"$",
"line",
",",
"array",
"(",
")",
")",
";",
"}"
] | /*
append() | [
"/",
"*",
"append",
"()"
] | train | https://github.com/tomphp/patch-builder/blob/4419eaad23016c7db1deffc6cce3f539096c11ce/spec/TomPHP/PatchBuilder/PatchBufferSpec.php#L179-L184 |
tomphp/patch-builder | spec/TomPHP/PatchBuilder/PatchBufferSpec.php | PatchBufferSpec.it_calls_delete_on_modified_content | public function it_calls_delete_on_modified_content(LineRange $range)
{
$this->modified->delete($range)->shouldBeCalled();
$this->delete($range);
} | php | public function it_calls_delete_on_modified_content(LineRange $range)
{
$this->modified->delete($range)->shouldBeCalled();
$this->delete($range);
} | [
"public",
"function",
"it_calls_delete_on_modified_content",
"(",
"LineRange",
"$",
"range",
")",
"{",
"$",
"this",
"->",
"modified",
"->",
"delete",
"(",
"$",
"range",
")",
"->",
"shouldBeCalled",
"(",
")",
";",
"$",
"this",
"->",
"delete",
"(",
"$",
"range",
")",
";",
"}"
] | /*
delete() | [
"/",
"*",
"delete",
"()"
] | train | https://github.com/tomphp/patch-builder/blob/4419eaad23016c7db1deffc6cce3f539096c11ce/spec/TomPHP/PatchBuilder/PatchBufferSpec.php#L228-L233 |
tomphp/patch-builder | spec/TomPHP/PatchBuilder/PatchBufferSpec.php | PatchBufferSpec.it_fetches_a_single_line_from_modified_buffer | public function it_fetches_a_single_line_from_modified_buffer()
{
$this->modified
->getLines(LineRange::createSingleLine(7))
->shouldBeCalled()
->willReturn(array());
$this->getLine(new LineNumber(7));
} | php | public function it_fetches_a_single_line_from_modified_buffer()
{
$this->modified
->getLines(LineRange::createSingleLine(7))
->shouldBeCalled()
->willReturn(array());
$this->getLine(new LineNumber(7));
} | [
"public",
"function",
"it_fetches_a_single_line_from_modified_buffer",
"(",
")",
"{",
"$",
"this",
"->",
"modified",
"->",
"getLines",
"(",
"LineRange",
"::",
"createSingleLine",
"(",
"7",
")",
")",
"->",
"shouldBeCalled",
"(",
")",
"->",
"willReturn",
"(",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"getLine",
"(",
"new",
"LineNumber",
"(",
"7",
")",
")",
";",
"}"
] | /*
getLine() | [
"/",
"*",
"getLine",
"()"
] | train | https://github.com/tomphp/patch-builder/blob/4419eaad23016c7db1deffc6cce3f539096c11ce/spec/TomPHP/PatchBuilder/PatchBufferSpec.php#L264-L272 |
tomphp/patch-builder | spec/TomPHP/PatchBuilder/PatchBufferSpec.php | PatchBufferSpec.it_is_not_modified_if_contents_of_buffers_match | public function it_is_not_modified_if_contents_of_buffers_match()
{
$content = array('blah');
$this->original->getContents()->willReturn($content);
$this->modified->getContents()->willReturn($content);
$this->shouldNotBeModified();
} | php | public function it_is_not_modified_if_contents_of_buffers_match()
{
$content = array('blah');
$this->original->getContents()->willReturn($content);
$this->modified->getContents()->willReturn($content);
$this->shouldNotBeModified();
} | [
"public",
"function",
"it_is_not_modified_if_contents_of_buffers_match",
"(",
")",
"{",
"$",
"content",
"=",
"array",
"(",
"'blah'",
")",
";",
"$",
"this",
"->",
"original",
"->",
"getContents",
"(",
")",
"->",
"willReturn",
"(",
"$",
"content",
")",
";",
"$",
"this",
"->",
"modified",
"->",
"getContents",
"(",
")",
"->",
"willReturn",
"(",
"$",
"content",
")",
";",
"$",
"this",
"->",
"shouldNotBeModified",
"(",
")",
";",
"}"
] | /*
isModified() | [
"/",
"*",
"isModified",
"()"
] | train | https://github.com/tomphp/patch-builder/blob/4419eaad23016c7db1deffc6cce3f539096c11ce/spec/TomPHP/PatchBuilder/PatchBufferSpec.php#L304-L312 |
nexusnetsoftgmbh/nexuscli | src/Nexus/CustomCommand/Business/CustomCommandBusinessFactory.php | CustomCommandBusinessFactory.createCommandHydrator | public function createCommandHydrator(string $directory, bool $recursive) : CommandHydratorInterface
{
return new CommandHydrator(
$this->createCommandFinder(
$directory,
$recursive
)
);
} | php | public function createCommandHydrator(string $directory, bool $recursive) : CommandHydratorInterface
{
return new CommandHydrator(
$this->createCommandFinder(
$directory,
$recursive
)
);
} | [
"public",
"function",
"createCommandHydrator",
"(",
"string",
"$",
"directory",
",",
"bool",
"$",
"recursive",
")",
":",
"CommandHydratorInterface",
"{",
"return",
"new",
"CommandHydrator",
"(",
"$",
"this",
"->",
"createCommandFinder",
"(",
"$",
"directory",
",",
"$",
"recursive",
")",
")",
";",
"}"
] | @param string $directory
@param bool $recursive
@return \Nexus\CustomCommand\Business\Model\Hydrator\CommandHydratorInterface | [
"@param",
"string",
"$directory",
"@param",
"bool",
"$recursive"
] | train | https://github.com/nexusnetsoftgmbh/nexuscli/blob/8416b43d31ad56ea379ae2b0bf85d456e78ba67a/src/Nexus/CustomCommand/Business/CustomCommandBusinessFactory.php#L25-L33 |
xinix-technology/norm | src/Norm/Filter/Filter.php | Filter.fromSchema | public static function fromSchema($schema, $preFilter = array(), $postFilter = array())
{
$rules = array();
foreach ($preFilter as $key => $filter) {
$filter = explode('|', $filter);
foreach ($filter as $f) {
$rules[$key][] = trim($f);
}
}
foreach ($schema as $k => $field) {
if (is_null($field)) {
continue;
}
$rules[$k] = array(
'label' => $field['label'],
'filter' => $field->filter(),
);
}
foreach ($postFilter as $key => $filter) {
$filter = explode('|', $filter);
foreach ($filter as $f) {
$rules[$key]['filter'][] = trim($f);
}
}
return new static($rules);
} | php | public static function fromSchema($schema, $preFilter = array(), $postFilter = array())
{
$rules = array();
foreach ($preFilter as $key => $filter) {
$filter = explode('|', $filter);
foreach ($filter as $f) {
$rules[$key][] = trim($f);
}
}
foreach ($schema as $k => $field) {
if (is_null($field)) {
continue;
}
$rules[$k] = array(
'label' => $field['label'],
'filter' => $field->filter(),
);
}
foreach ($postFilter as $key => $filter) {
$filter = explode('|', $filter);
foreach ($filter as $f) {
$rules[$key]['filter'][] = trim($f);
}
}
return new static($rules);
} | [
"public",
"static",
"function",
"fromSchema",
"(",
"$",
"schema",
",",
"$",
"preFilter",
"=",
"array",
"(",
")",
",",
"$",
"postFilter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"rules",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"preFilter",
"as",
"$",
"key",
"=>",
"$",
"filter",
")",
"{",
"$",
"filter",
"=",
"explode",
"(",
"'|'",
",",
"$",
"filter",
")",
";",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"f",
")",
"{",
"$",
"rules",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"trim",
"(",
"$",
"f",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"schema",
"as",
"$",
"k",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"field",
")",
")",
"{",
"continue",
";",
"}",
"$",
"rules",
"[",
"$",
"k",
"]",
"=",
"array",
"(",
"'label'",
"=>",
"$",
"field",
"[",
"'label'",
"]",
",",
"'filter'",
"=>",
"$",
"field",
"->",
"filter",
"(",
")",
",",
")",
";",
"}",
"foreach",
"(",
"$",
"postFilter",
"as",
"$",
"key",
"=>",
"$",
"filter",
")",
"{",
"$",
"filter",
"=",
"explode",
"(",
"'|'",
",",
"$",
"filter",
")",
";",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"f",
")",
"{",
"$",
"rules",
"[",
"$",
"key",
"]",
"[",
"'filter'",
"]",
"[",
"]",
"=",
"trim",
"(",
"$",
"f",
")",
";",
"}",
"}",
"return",
"new",
"static",
"(",
"$",
"rules",
")",
";",
"}"
] | Static method to create instance of filter from database schema configuration.
@param array $schema Database schema configuration
@param array $preFilter Filters that will be run before the filter
@param array $postFilter Filters that will be run after the filter
@return \Norm\Filter\Filter | [
"Static",
"method",
"to",
"create",
"instance",
"of",
"filter",
"from",
"database",
"schema",
"configuration",
"."
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Filter/Filter.php#L51-L83 |
datasift/php_webdriver | src/php/DataSift/BrowserMobProxy/BrowserMobProxyClient.php | BrowserMobProxyClient.createProxy | public function createProxy($port = null)
{
if ($port !== null) {
// we want a specific port
// willing to bet that this ends in tears!
$response = $this->curl(
'POST',
'/proxy',
array ('port' => $port)
);
}
else {
// we just want the next port available
$response = $this->curl(
'POST',
'/proxy'
);
}
// did it work?
if (isset($response->port)) {
// yes! return a session object to the caller
$session = new BrowserMobProxySession($this->getUrl(), $response->port);
return $session;
}
// if we get here, things went pear-shaped
//
// unfortunately, browsermob-proxy does not appear to support
// a sane error results payload, so if this goes wrong, we're
// a bit stuffed to understand why :(
throw new E5xx_CannotCreateBrowserMobProxySession();
} | php | public function createProxy($port = null)
{
if ($port !== null) {
// we want a specific port
// willing to bet that this ends in tears!
$response = $this->curl(
'POST',
'/proxy',
array ('port' => $port)
);
}
else {
// we just want the next port available
$response = $this->curl(
'POST',
'/proxy'
);
}
// did it work?
if (isset($response->port)) {
// yes! return a session object to the caller
$session = new BrowserMobProxySession($this->getUrl(), $response->port);
return $session;
}
// if we get here, things went pear-shaped
//
// unfortunately, browsermob-proxy does not appear to support
// a sane error results payload, so if this goes wrong, we're
// a bit stuffed to understand why :(
throw new E5xx_CannotCreateBrowserMobProxySession();
} | [
"public",
"function",
"createProxy",
"(",
"$",
"port",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"port",
"!==",
"null",
")",
"{",
"// we want a specific port",
"// willing to bet that this ends in tears!",
"$",
"response",
"=",
"$",
"this",
"->",
"curl",
"(",
"'POST'",
",",
"'/proxy'",
",",
"array",
"(",
"'port'",
"=>",
"$",
"port",
")",
")",
";",
"}",
"else",
"{",
"// we just want the next port available",
"$",
"response",
"=",
"$",
"this",
"->",
"curl",
"(",
"'POST'",
",",
"'/proxy'",
")",
";",
"}",
"// did it work?",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"port",
")",
")",
"{",
"// yes! return a session object to the caller",
"$",
"session",
"=",
"new",
"BrowserMobProxySession",
"(",
"$",
"this",
"->",
"getUrl",
"(",
")",
",",
"$",
"response",
"->",
"port",
")",
";",
"return",
"$",
"session",
";",
"}",
"// if we get here, things went pear-shaped",
"//",
"// unfortunately, browsermob-proxy does not appear to support",
"// a sane error results payload, so if this goes wrong, we're",
"// a bit stuffed to understand why :(",
"throw",
"new",
"E5xx_CannotCreateBrowserMobProxySession",
"(",
")",
";",
"}"
] | Create a new proxy, running on an (optionally specified) port
If the stated port is in use, browsermob-proxy will allocate the
next available port for you
@param integer $port the preferred port for the proxy
@return BrowserMobProxySession a wrapper around the API for the
proxy instance that has been created | [
"Create",
"a",
"new",
"proxy",
"running",
"on",
"an",
"(",
"optionally",
"specified",
")",
"port"
] | train | https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/BrowserMobProxy/BrowserMobProxyClient.php#L51-L83 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.create | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof RemoteHistoryContaoQuery) {
return $criteria;
}
$query = new RemoteHistoryContaoQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | php | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof RemoteHistoryContaoQuery) {
return $criteria;
}
$query = new RemoteHistoryContaoQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelAlias",
"=",
"null",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"criteria",
"instanceof",
"RemoteHistoryContaoQuery",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"query",
"=",
"new",
"RemoteHistoryContaoQuery",
"(",
"null",
",",
"null",
",",
"$",
"modelAlias",
")",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"query",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Returns a new RemoteHistoryContaoQuery object.
@param string $modelAlias The alias of a model in the query
@param RemoteHistoryContaoQuery|Criteria $criteria Optional Criteria to build the query from
@return RemoteHistoryContaoQuery | [
"Returns",
"a",
"new",
"RemoteHistoryContaoQuery",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L139-L151 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByRemoteAppId | public function filterByRemoteAppId($remoteAppId = null, $comparison = null)
{
if (is_array($remoteAppId)) {
$useMinMax = false;
if (isset($remoteAppId['min'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::REMOTE_APP_ID, $remoteAppId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($remoteAppId['max'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::REMOTE_APP_ID, $remoteAppId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::REMOTE_APP_ID, $remoteAppId, $comparison);
} | php | public function filterByRemoteAppId($remoteAppId = null, $comparison = null)
{
if (is_array($remoteAppId)) {
$useMinMax = false;
if (isset($remoteAppId['min'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::REMOTE_APP_ID, $remoteAppId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($remoteAppId['max'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::REMOTE_APP_ID, $remoteAppId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::REMOTE_APP_ID, $remoteAppId, $comparison);
} | [
"public",
"function",
"filterByRemoteAppId",
"(",
"$",
"remoteAppId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"remoteAppId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"remoteAppId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"REMOTE_APP_ID",
",",
"$",
"remoteAppId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"remoteAppId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"REMOTE_APP_ID",
",",
"$",
"remoteAppId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"REMOTE_APP_ID",
",",
"$",
"remoteAppId",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the remote_app_id column
Example usage:
<code>
$query->filterByRemoteAppId(1234); // WHERE remote_app_id = 1234
$query->filterByRemoteAppId(array(12, 34)); // WHERE remote_app_id IN (12, 34)
$query->filterByRemoteAppId(array('min' => 12)); // WHERE remote_app_id >= 12
$query->filterByRemoteAppId(array('max' => 12)); // WHERE remote_app_id <= 12
</code>
@see filterByRemoteApp()
@param mixed $remoteAppId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"remote_app_id",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L367-L388 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByApiversion | public function filterByApiversion($apiversion = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiversion)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiversion)) {
$apiversion = str_replace('*', '%', $apiversion);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::APIVERSION, $apiversion, $comparison);
} | php | public function filterByApiversion($apiversion = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiversion)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiversion)) {
$apiversion = str_replace('*', '%', $apiversion);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::APIVERSION, $apiversion, $comparison);
} | [
"public",
"function",
"filterByApiversion",
"(",
"$",
"apiversion",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"apiversion",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"apiversion",
")",
")",
"{",
"$",
"apiversion",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"apiversion",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"APIVERSION",
",",
"$",
"apiversion",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the apiVersion column
Example usage:
<code>
$query->filterByApiversion('fooValue'); // WHERE apiVersion = 'fooValue'
$query->filterByApiversion('%fooValue%'); // WHERE apiVersion LIKE '%fooValue%'
</code>
@param string $apiversion The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"apiVersion",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L405-L417 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByName | public function filterByName($name = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($name)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $name)) {
$name = str_replace('*', '%', $name);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::NAME, $name, $comparison);
} | php | public function filterByName($name = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($name)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $name)) {
$name = str_replace('*', '%', $name);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::NAME, $name, $comparison);
} | [
"public",
"function",
"filterByName",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"name",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"NAME",
",",
"$",
"name",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the name column
Example usage:
<code>
$query->filterByName('fooValue'); // WHERE name = 'fooValue'
$query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
</code>
@param string $name The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"name",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L434-L446 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByVersion | public function filterByVersion($version = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($version)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $version)) {
$version = str_replace('*', '%', $version);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::VERSION, $version, $comparison);
} | php | public function filterByVersion($version = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($version)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $version)) {
$version = str_replace('*', '%', $version);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::VERSION, $version, $comparison);
} | [
"public",
"function",
"filterByVersion",
"(",
"$",
"version",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"version",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"version",
")",
")",
"{",
"$",
"version",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"version",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"VERSION",
",",
"$",
"version",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the version column
Example usage:
<code>
$query->filterByVersion('fooValue'); // WHERE version = 'fooValue'
$query->filterByVersion('%fooValue%'); // WHERE version LIKE '%fooValue%'
</code>
@param string $version The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"version",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L463-L475 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigDisplayerrors | public function filterByConfigDisplayerrors($configDisplayerrors = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configDisplayerrors)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configDisplayerrors)) {
$configDisplayerrors = str_replace('*', '%', $configDisplayerrors);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_DISPLAYERRORS, $configDisplayerrors, $comparison);
} | php | public function filterByConfigDisplayerrors($configDisplayerrors = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configDisplayerrors)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configDisplayerrors)) {
$configDisplayerrors = str_replace('*', '%', $configDisplayerrors);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_DISPLAYERRORS, $configDisplayerrors, $comparison);
} | [
"public",
"function",
"filterByConfigDisplayerrors",
"(",
"$",
"configDisplayerrors",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configDisplayerrors",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configDisplayerrors",
")",
")",
"{",
"$",
"configDisplayerrors",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configDisplayerrors",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_DISPLAYERRORS",
",",
"$",
"configDisplayerrors",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_displayErrors column
Example usage:
<code>
$query->filterByConfigDisplayerrors('fooValue'); // WHERE config_displayErrors = 'fooValue'
$query->filterByConfigDisplayerrors('%fooValue%'); // WHERE config_displayErrors LIKE '%fooValue%'
</code>
@param string $configDisplayerrors The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_displayErrors",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L492-L504 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigBypasscache | public function filterByConfigBypasscache($configBypasscache = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configBypasscache)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configBypasscache)) {
$configBypasscache = str_replace('*', '%', $configBypasscache);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_BYPASSCACHE, $configBypasscache, $comparison);
} | php | public function filterByConfigBypasscache($configBypasscache = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configBypasscache)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configBypasscache)) {
$configBypasscache = str_replace('*', '%', $configBypasscache);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_BYPASSCACHE, $configBypasscache, $comparison);
} | [
"public",
"function",
"filterByConfigBypasscache",
"(",
"$",
"configBypasscache",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configBypasscache",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configBypasscache",
")",
")",
"{",
"$",
"configBypasscache",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configBypasscache",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_BYPASSCACHE",
",",
"$",
"configBypasscache",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_bypassCache column
Example usage:
<code>
$query->filterByConfigBypasscache('fooValue'); // WHERE config_bypassCache = 'fooValue'
$query->filterByConfigBypasscache('%fooValue%'); // WHERE config_bypassCache LIKE '%fooValue%'
</code>
@param string $configBypasscache The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_bypassCache",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L521-L533 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigMinifymarkup | public function filterByConfigMinifymarkup($configMinifymarkup = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configMinifymarkup)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configMinifymarkup)) {
$configMinifymarkup = str_replace('*', '%', $configMinifymarkup);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_MINIFYMARKUP, $configMinifymarkup, $comparison);
} | php | public function filterByConfigMinifymarkup($configMinifymarkup = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configMinifymarkup)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configMinifymarkup)) {
$configMinifymarkup = str_replace('*', '%', $configMinifymarkup);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_MINIFYMARKUP, $configMinifymarkup, $comparison);
} | [
"public",
"function",
"filterByConfigMinifymarkup",
"(",
"$",
"configMinifymarkup",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configMinifymarkup",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configMinifymarkup",
")",
")",
"{",
"$",
"configMinifymarkup",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configMinifymarkup",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_MINIFYMARKUP",
",",
"$",
"configMinifymarkup",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_minifyMarkup column
Example usage:
<code>
$query->filterByConfigMinifymarkup('fooValue'); // WHERE config_minifyMarkup = 'fooValue'
$query->filterByConfigMinifymarkup('%fooValue%'); // WHERE config_minifyMarkup LIKE '%fooValue%'
</code>
@param string $configMinifymarkup The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_minifyMarkup",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L550-L562 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigDebugmode | public function filterByConfigDebugmode($configDebugmode = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configDebugmode)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configDebugmode)) {
$configDebugmode = str_replace('*', '%', $configDebugmode);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_DEBUGMODE, $configDebugmode, $comparison);
} | php | public function filterByConfigDebugmode($configDebugmode = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configDebugmode)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configDebugmode)) {
$configDebugmode = str_replace('*', '%', $configDebugmode);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_DEBUGMODE, $configDebugmode, $comparison);
} | [
"public",
"function",
"filterByConfigDebugmode",
"(",
"$",
"configDebugmode",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configDebugmode",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configDebugmode",
")",
")",
"{",
"$",
"configDebugmode",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configDebugmode",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_DEBUGMODE",
",",
"$",
"configDebugmode",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_debugMode column
Example usage:
<code>
$query->filterByConfigDebugmode('fooValue'); // WHERE config_debugMode = 'fooValue'
$query->filterByConfigDebugmode('%fooValue%'); // WHERE config_debugMode LIKE '%fooValue%'
</code>
@param string $configDebugmode The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_debugMode",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L579-L591 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigMaintenancemode | public function filterByConfigMaintenancemode($configMaintenancemode = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configMaintenancemode)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configMaintenancemode)) {
$configMaintenancemode = str_replace('*', '%', $configMaintenancemode);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_MAINTENANCEMODE, $configMaintenancemode, $comparison);
} | php | public function filterByConfigMaintenancemode($configMaintenancemode = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configMaintenancemode)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configMaintenancemode)) {
$configMaintenancemode = str_replace('*', '%', $configMaintenancemode);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_MAINTENANCEMODE, $configMaintenancemode, $comparison);
} | [
"public",
"function",
"filterByConfigMaintenancemode",
"(",
"$",
"configMaintenancemode",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configMaintenancemode",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configMaintenancemode",
")",
")",
"{",
"$",
"configMaintenancemode",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configMaintenancemode",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_MAINTENANCEMODE",
",",
"$",
"configMaintenancemode",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_maintenanceMode column
Example usage:
<code>
$query->filterByConfigMaintenancemode('fooValue'); // WHERE config_maintenanceMode = 'fooValue'
$query->filterByConfigMaintenancemode('%fooValue%'); // WHERE config_maintenanceMode LIKE '%fooValue%'
</code>
@param string $configMaintenancemode The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_maintenanceMode",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L608-L620 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigGzipscripts | public function filterByConfigGzipscripts($configGzipscripts = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configGzipscripts)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configGzipscripts)) {
$configGzipscripts = str_replace('*', '%', $configGzipscripts);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_GZIPSCRIPTS, $configGzipscripts, $comparison);
} | php | public function filterByConfigGzipscripts($configGzipscripts = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configGzipscripts)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configGzipscripts)) {
$configGzipscripts = str_replace('*', '%', $configGzipscripts);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_GZIPSCRIPTS, $configGzipscripts, $comparison);
} | [
"public",
"function",
"filterByConfigGzipscripts",
"(",
"$",
"configGzipscripts",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configGzipscripts",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configGzipscripts",
")",
")",
"{",
"$",
"configGzipscripts",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configGzipscripts",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_GZIPSCRIPTS",
",",
"$",
"configGzipscripts",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_gzipScripts column
Example usage:
<code>
$query->filterByConfigGzipscripts('fooValue'); // WHERE config_gzipScripts = 'fooValue'
$query->filterByConfigGzipscripts('%fooValue%'); // WHERE config_gzipScripts LIKE '%fooValue%'
</code>
@param string $configGzipscripts The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_gzipScripts",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L637-L649 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigRewriteurl | public function filterByConfigRewriteurl($configRewriteurl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configRewriteurl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configRewriteurl)) {
$configRewriteurl = str_replace('*', '%', $configRewriteurl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_REWRITEURL, $configRewriteurl, $comparison);
} | php | public function filterByConfigRewriteurl($configRewriteurl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configRewriteurl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configRewriteurl)) {
$configRewriteurl = str_replace('*', '%', $configRewriteurl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_REWRITEURL, $configRewriteurl, $comparison);
} | [
"public",
"function",
"filterByConfigRewriteurl",
"(",
"$",
"configRewriteurl",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configRewriteurl",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configRewriteurl",
")",
")",
"{",
"$",
"configRewriteurl",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configRewriteurl",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_REWRITEURL",
",",
"$",
"configRewriteurl",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_rewriteURL column
Example usage:
<code>
$query->filterByConfigRewriteurl('fooValue'); // WHERE config_rewriteURL = 'fooValue'
$query->filterByConfigRewriteurl('%fooValue%'); // WHERE config_rewriteURL LIKE '%fooValue%'
</code>
@param string $configRewriteurl The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_rewriteURL",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L666-L678 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigAdminemail | public function filterByConfigAdminemail($configAdminemail = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configAdminemail)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configAdminemail)) {
$configAdminemail = str_replace('*', '%', $configAdminemail);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_ADMINEMAIL, $configAdminemail, $comparison);
} | php | public function filterByConfigAdminemail($configAdminemail = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configAdminemail)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configAdminemail)) {
$configAdminemail = str_replace('*', '%', $configAdminemail);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_ADMINEMAIL, $configAdminemail, $comparison);
} | [
"public",
"function",
"filterByConfigAdminemail",
"(",
"$",
"configAdminemail",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configAdminemail",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configAdminemail",
")",
")",
"{",
"$",
"configAdminemail",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configAdminemail",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_ADMINEMAIL",
",",
"$",
"configAdminemail",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_adminEmail column
Example usage:
<code>
$query->filterByConfigAdminemail('fooValue'); // WHERE config_adminEmail = 'fooValue'
$query->filterByConfigAdminemail('%fooValue%'); // WHERE config_adminEmail LIKE '%fooValue%'
</code>
@param string $configAdminemail The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_adminEmail",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L695-L707 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByConfigCachemode | public function filterByConfigCachemode($configCachemode = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configCachemode)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configCachemode)) {
$configCachemode = str_replace('*', '%', $configCachemode);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_CACHEMODE, $configCachemode, $comparison);
} | php | public function filterByConfigCachemode($configCachemode = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($configCachemode)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $configCachemode)) {
$configCachemode = str_replace('*', '%', $configCachemode);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::CONFIG_CACHEMODE, $configCachemode, $comparison);
} | [
"public",
"function",
"filterByConfigCachemode",
"(",
"$",
"configCachemode",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configCachemode",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"configCachemode",
")",
")",
"{",
"$",
"configCachemode",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"configCachemode",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"CONFIG_CACHEMODE",
",",
"$",
"configCachemode",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the config_cacheMode column
Example usage:
<code>
$query->filterByConfigCachemode('fooValue'); // WHERE config_cacheMode = 'fooValue'
$query->filterByConfigCachemode('%fooValue%'); // WHERE config_cacheMode LIKE '%fooValue%'
</code>
@param string $configCachemode The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"config_cacheMode",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L724-L736 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByStatuscode | public function filterByStatuscode($statuscode = null, $comparison = null)
{
if (is_array($statuscode)) {
$useMinMax = false;
if (isset($statuscode['min'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::STATUSCODE, $statuscode['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($statuscode['max'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::STATUSCODE, $statuscode['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::STATUSCODE, $statuscode, $comparison);
} | php | public function filterByStatuscode($statuscode = null, $comparison = null)
{
if (is_array($statuscode)) {
$useMinMax = false;
if (isset($statuscode['min'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::STATUSCODE, $statuscode['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($statuscode['max'])) {
$this->addUsingAlias(RemoteHistoryContaoPeer::STATUSCODE, $statuscode['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::STATUSCODE, $statuscode, $comparison);
} | [
"public",
"function",
"filterByStatuscode",
"(",
"$",
"statuscode",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"statuscode",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"statuscode",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"STATUSCODE",
",",
"$",
"statuscode",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"statuscode",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"STATUSCODE",
",",
"$",
"statuscode",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"STATUSCODE",
",",
"$",
"statuscode",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the statuscode column
Example usage:
<code>
$query->filterByStatuscode(1234); // WHERE statuscode = 1234
$query->filterByStatuscode(array(12, 34)); // WHERE statuscode IN (12, 34)
$query->filterByStatuscode(array('min' => 12)); // WHERE statuscode >= 12
$query->filterByStatuscode(array('max' => 12)); // WHERE statuscode <= 12
</code>
@param mixed $statuscode The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"statuscode",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L757-L778 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByExtensions | public function filterByExtensions($extensions = null, $comparison = null)
{
if (is_object($extensions)) {
$extensions = serialize($extensions);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::EXTENSIONS, $extensions, $comparison);
} | php | public function filterByExtensions($extensions = null, $comparison = null)
{
if (is_object($extensions)) {
$extensions = serialize($extensions);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::EXTENSIONS, $extensions, $comparison);
} | [
"public",
"function",
"filterByExtensions",
"(",
"$",
"extensions",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"extensions",
")",
")",
"{",
"$",
"extensions",
"=",
"serialize",
"(",
"$",
"extensions",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"EXTENSIONS",
",",
"$",
"extensions",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the extensions column
@param mixed $extensions The value to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"extensions",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L788-L795 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByLog | public function filterByLog($log = null, $comparison = null)
{
if (is_object($log)) {
$log = serialize($log);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::LOG, $log, $comparison);
} | php | public function filterByLog($log = null, $comparison = null)
{
if (is_object($log)) {
$log = serialize($log);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::LOG, $log, $comparison);
} | [
"public",
"function",
"filterByLog",
"(",
"$",
"log",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"log",
")",
")",
"{",
"$",
"log",
"=",
"serialize",
"(",
"$",
"log",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"LOG",
",",
"$",
"log",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the log column
@param mixed $log The value to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"log",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L805-L812 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByPHP | public function filterByPHP($pHP = null, $comparison = null)
{
if (is_object($pHP)) {
$pHP = serialize($pHP);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::PHP, $pHP, $comparison);
} | php | public function filterByPHP($pHP = null, $comparison = null)
{
if (is_object($pHP)) {
$pHP = serialize($pHP);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::PHP, $pHP, $comparison);
} | [
"public",
"function",
"filterByPHP",
"(",
"$",
"pHP",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"pHP",
")",
")",
"{",
"$",
"pHP",
"=",
"serialize",
"(",
"$",
"pHP",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"PHP",
",",
"$",
"pHP",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the php column
@param mixed $pHP The value to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"php",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L822-L829 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.filterByMySQL | public function filterByMySQL($mySQL = null, $comparison = null)
{
if (is_object($mySQL)) {
$mySQL = serialize($mySQL);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::MYSQL, $mySQL, $comparison);
} | php | public function filterByMySQL($mySQL = null, $comparison = null)
{
if (is_object($mySQL)) {
$mySQL = serialize($mySQL);
}
return $this->addUsingAlias(RemoteHistoryContaoPeer::MYSQL, $mySQL, $comparison);
} | [
"public",
"function",
"filterByMySQL",
"(",
"$",
"mySQL",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"mySQL",
")",
")",
"{",
"$",
"mySQL",
"=",
"serialize",
"(",
"$",
"mySQL",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"MYSQL",
",",
"$",
"mySQL",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the mysql column
@param mixed $mySQL The value to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"mysql",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L839-L846 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.useRemoteAppQuery | public function useRemoteAppQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinRemoteApp($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'RemoteApp', '\Slashworks\AppBundle\Model\RemoteAppQuery');
} | php | public function useRemoteAppQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinRemoteApp($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'RemoteApp', '\Slashworks\AppBundle\Model\RemoteAppQuery');
} | [
"public",
"function",
"useRemoteAppQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinRemoteApp",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'RemoteApp'",
",",
"'\\Slashworks\\AppBundle\\Model\\RemoteAppQuery'",
")",
";",
"}"
] | Use the RemoteApp relation RemoteApp object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \Slashworks\AppBundle\Model\RemoteAppQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"RemoteApp",
"relation",
"RemoteApp",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L917-L922 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php | BaseRemoteHistoryContaoQuery.prune | public function prune($remoteHistoryContao = null)
{
if ($remoteHistoryContao) {
$this->addUsingAlias(RemoteHistoryContaoPeer::ID, $remoteHistoryContao->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | php | public function prune($remoteHistoryContao = null)
{
if ($remoteHistoryContao) {
$this->addUsingAlias(RemoteHistoryContaoPeer::ID, $remoteHistoryContao->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | [
"public",
"function",
"prune",
"(",
"$",
"remoteHistoryContao",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"remoteHistoryContao",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteHistoryContaoPeer",
"::",
"ID",
",",
"$",
"remoteHistoryContao",
"->",
"getId",
"(",
")",
",",
"Criteria",
"::",
"NOT_EQUAL",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Exclude object from result
@param RemoteHistoryContao $remoteHistoryContao Object to remove from the list of results
@return RemoteHistoryContaoQuery The current query, for fluid interface | [
"Exclude",
"object",
"from",
"result"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteHistoryContaoQuery.php#L931-L938 |
OpenClassrooms/Akismet | src/Services/Impl/AkismetServiceImpl.php | AkismetServiceImpl.commentCheck | public function commentCheck(Comment $comment)
{
return 'true' === $this->apiClient->post(self::COMMENT_CHECK, $comment->toArray());
} | php | public function commentCheck(Comment $comment)
{
return 'true' === $this->apiClient->post(self::COMMENT_CHECK, $comment->toArray());
} | [
"public",
"function",
"commentCheck",
"(",
"Comment",
"$",
"comment",
")",
"{",
"return",
"'true'",
"===",
"$",
"this",
"->",
"apiClient",
"->",
"post",
"(",
"self",
"::",
"COMMENT_CHECK",
",",
"$",
"comment",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/OpenClassrooms/Akismet/blob/b1bd35128f5dfe028481adf338d5eb752a09b90e/src/Services/Impl/AkismetServiceImpl.php#L36-L39 |
OpenClassrooms/Akismet | src/Services/Impl/AkismetServiceImpl.php | AkismetServiceImpl.submitSpam | public function submitSpam(Comment $comment)
{
$this->apiClient->post(self::SUBMIT_SPAM, $comment->toArray());
} | php | public function submitSpam(Comment $comment)
{
$this->apiClient->post(self::SUBMIT_SPAM, $comment->toArray());
} | [
"public",
"function",
"submitSpam",
"(",
"Comment",
"$",
"comment",
")",
"{",
"$",
"this",
"->",
"apiClient",
"->",
"post",
"(",
"self",
"::",
"SUBMIT_SPAM",
",",
"$",
"comment",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/OpenClassrooms/Akismet/blob/b1bd35128f5dfe028481adf338d5eb752a09b90e/src/Services/Impl/AkismetServiceImpl.php#L44-L47 |
OpenClassrooms/Akismet | src/Services/Impl/AkismetServiceImpl.php | AkismetServiceImpl.submitHam | public function submitHam(Comment $comment)
{
$this->apiClient->post(self::SUBMIT_HAM, $comment->toArray());
} | php | public function submitHam(Comment $comment)
{
$this->apiClient->post(self::SUBMIT_HAM, $comment->toArray());
} | [
"public",
"function",
"submitHam",
"(",
"Comment",
"$",
"comment",
")",
"{",
"$",
"this",
"->",
"apiClient",
"->",
"post",
"(",
"self",
"::",
"SUBMIT_HAM",
",",
"$",
"comment",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/OpenClassrooms/Akismet/blob/b1bd35128f5dfe028481adf338d5eb752a09b90e/src/Services/Impl/AkismetServiceImpl.php#L52-L55 |
left-right/center | src/libraries/Table.php | Table.column | public function column($name, $type, $label=false, $width=false, $height=false) {
if ($label === false) $label = $name;
$this->columns[] = compact('name', 'type', 'label', 'width', 'height');
} | php | public function column($name, $type, $label=false, $width=false, $height=false) {
if ($label === false) $label = $name;
$this->columns[] = compact('name', 'type', 'label', 'width', 'height');
} | [
"public",
"function",
"column",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"label",
"=",
"false",
",",
"$",
"width",
"=",
"false",
",",
"$",
"height",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"label",
"===",
"false",
")",
"$",
"label",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"columns",
"[",
"]",
"=",
"compact",
"(",
"'name'",
",",
"'type'",
",",
"'label'",
",",
"'width'",
",",
"'height'",
")",
";",
"}"
] | add a column. $trans is translation file key | [
"add",
"a",
"column",
".",
"$trans",
"is",
"translation",
"file",
"key"
] | train | https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/libraries/Table.php#L23-L26 |
left-right/center | src/libraries/Table.php | Table.draw | public function draw($id='untitled') {
//start up
if ($this->draggable) array_unshift($this->columns, ['label'=>'', 'type'=>'draggy', 'name'=>'draggy']);
if ($this->deletable) self::column('delete', 'delete', '');
if ($this->grouped) $last_group = '';
$colspan = count($this->columns);
$rowspan = count($this->rows);
//build <thead>
$columns = [];
foreach ($this->columns as $column) {
$columns[] = '<th class="type-' . $column['type'] . ' ' . $column['name'] . '">' . $column['label'] . '</th>';
}
$head = '<thead><tr>' . implode($columns) . '</tr></thead>';
//build rows
$bodies = $rows = [];
foreach ($this->rows as $row) {
$columns = [];
$link = true;
foreach ($this->columns as $column) {
//handle groupings
if ($this->grouped && ($last_group != $row->{$this->grouped})) {
$last_group = $row->{$this->grouped};
if (count($rows)) $bodies[] = '<tbody>' . implode($rows) . '</tbody>';
$bodies[] = '<tr class="group"><td colspan=' . $colspan . '">' . $last_group . '</td></tr>';
$rows = [];
}
//process value if necessary
if ($column['type'] == 'draggy') {
$value = config('center.icons.drag');
} elseif ($column['type'] == 'delete') {
$value = '<a href="' . $row->delete . '">' . ($row->deleted_at ? config('center.icons.deleted') : config('center.icons.undeleted')) . '</a>';
} elseif ($column['type'] == 'image') {
$value = '<img src="' . $row->{$column['name'] . '_url'} . '" width="' . $column['width'] . '" height="' . $column['height'] . '">';
if (isset($row->link)) $value = '<a href="' . $row->link . '">' . $value . '</a>';
} elseif ($column['type'] == 'stripe_charge') {
$value = $row->{$column['name']} ? '<a href="https://dashboard.stripe.com/payments/' . $row->{$column['name']} . '" target="_blank">' . config('center.icons.new_window') . ' ' . trans('center::site.stripe_open') . '</a>' : '';
} else {
$value = Str::limit(strip_tags($row->{$column['name']}));
if ($column['type'] == 'updated_at') {
$value = Dates::relative($value);
} elseif ($column['type'] == 'time') {
$value = Dates::time($value);
} elseif ($column['type'] == 'date') {
$value = Dates::absolute($value);
} elseif ($column['type'] == 'date-relative') {
$value = Dates::relative($value);
} elseif (in_array($column['type'], ['datetime', 'timestamp'])) {
$value = Dates::absolute($value);
} elseif ($column['type'] == 'checkbox') {
$value = $value ? trans('center::site.yes') : trans('center::site.no');
} elseif ($column['type'] == 'money') {
$value = '$' . number_format($value, 2);
}
if (isset($row->link) && $link) {
if ($column['type'] == 'color') {
$value = '<a href="' . $row->link . '" style="background-color: ' . $value . '"></a>';
} else {
if ($value == '') $value = '…';
$value = '<a href="' . $row->link . '">' . $value . '</a>';
$link = false;
}
}
}
//create cell
$columns[] = '<td class="type-' . $column['type'] . ' ' . $column['name'] . '">' . $value . '</td>';
}
//create row
$rows[] = '<tr' . (empty($row->id) ? '' : ' id="' . $row->id . '"') . ($this->deletable && $row->deleted_at ? ' class="inactive"' : '') . '>' . implode($columns) . '</tr>';
}
$bodies[] = '<tbody>' . implode($rows) . '</tbody>';
//output
return '<table id="' . $id . '" class="table table-condensed' . ($this->draggable ? ' draggable" data-draggable-url="' . $this->draggable : '') . '" data-csrf-token="' . Session::token() . '">' .
$head .
implode($bodies) .
'</table>';
} | php | public function draw($id='untitled') {
//start up
if ($this->draggable) array_unshift($this->columns, ['label'=>'', 'type'=>'draggy', 'name'=>'draggy']);
if ($this->deletable) self::column('delete', 'delete', '');
if ($this->grouped) $last_group = '';
$colspan = count($this->columns);
$rowspan = count($this->rows);
//build <thead>
$columns = [];
foreach ($this->columns as $column) {
$columns[] = '<th class="type-' . $column['type'] . ' ' . $column['name'] . '">' . $column['label'] . '</th>';
}
$head = '<thead><tr>' . implode($columns) . '</tr></thead>';
//build rows
$bodies = $rows = [];
foreach ($this->rows as $row) {
$columns = [];
$link = true;
foreach ($this->columns as $column) {
//handle groupings
if ($this->grouped && ($last_group != $row->{$this->grouped})) {
$last_group = $row->{$this->grouped};
if (count($rows)) $bodies[] = '<tbody>' . implode($rows) . '</tbody>';
$bodies[] = '<tr class="group"><td colspan=' . $colspan . '">' . $last_group . '</td></tr>';
$rows = [];
}
//process value if necessary
if ($column['type'] == 'draggy') {
$value = config('center.icons.drag');
} elseif ($column['type'] == 'delete') {
$value = '<a href="' . $row->delete . '">' . ($row->deleted_at ? config('center.icons.deleted') : config('center.icons.undeleted')) . '</a>';
} elseif ($column['type'] == 'image') {
$value = '<img src="' . $row->{$column['name'] . '_url'} . '" width="' . $column['width'] . '" height="' . $column['height'] . '">';
if (isset($row->link)) $value = '<a href="' . $row->link . '">' . $value . '</a>';
} elseif ($column['type'] == 'stripe_charge') {
$value = $row->{$column['name']} ? '<a href="https://dashboard.stripe.com/payments/' . $row->{$column['name']} . '" target="_blank">' . config('center.icons.new_window') . ' ' . trans('center::site.stripe_open') . '</a>' : '';
} else {
$value = Str::limit(strip_tags($row->{$column['name']}));
if ($column['type'] == 'updated_at') {
$value = Dates::relative($value);
} elseif ($column['type'] == 'time') {
$value = Dates::time($value);
} elseif ($column['type'] == 'date') {
$value = Dates::absolute($value);
} elseif ($column['type'] == 'date-relative') {
$value = Dates::relative($value);
} elseif (in_array($column['type'], ['datetime', 'timestamp'])) {
$value = Dates::absolute($value);
} elseif ($column['type'] == 'checkbox') {
$value = $value ? trans('center::site.yes') : trans('center::site.no');
} elseif ($column['type'] == 'money') {
$value = '$' . number_format($value, 2);
}
if (isset($row->link) && $link) {
if ($column['type'] == 'color') {
$value = '<a href="' . $row->link . '" style="background-color: ' . $value . '"></a>';
} else {
if ($value == '') $value = '…';
$value = '<a href="' . $row->link . '">' . $value . '</a>';
$link = false;
}
}
}
//create cell
$columns[] = '<td class="type-' . $column['type'] . ' ' . $column['name'] . '">' . $value . '</td>';
}
//create row
$rows[] = '<tr' . (empty($row->id) ? '' : ' id="' . $row->id . '"') . ($this->deletable && $row->deleted_at ? ' class="inactive"' : '') . '>' . implode($columns) . '</tr>';
}
$bodies[] = '<tbody>' . implode($rows) . '</tbody>';
//output
return '<table id="' . $id . '" class="table table-condensed' . ($this->draggable ? ' draggable" data-draggable-url="' . $this->draggable : '') . '" data-csrf-token="' . Session::token() . '">' .
$head .
implode($bodies) .
'</table>';
} | [
"public",
"function",
"draw",
"(",
"$",
"id",
"=",
"'untitled'",
")",
"{",
"//start up",
"if",
"(",
"$",
"this",
"->",
"draggable",
")",
"array_unshift",
"(",
"$",
"this",
"->",
"columns",
",",
"[",
"'label'",
"=>",
"''",
",",
"'type'",
"=>",
"'draggy'",
",",
"'name'",
"=>",
"'draggy'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"deletable",
")",
"self",
"::",
"column",
"(",
"'delete'",
",",
"'delete'",
",",
"''",
")",
";",
"if",
"(",
"$",
"this",
"->",
"grouped",
")",
"$",
"last_group",
"=",
"''",
";",
"$",
"colspan",
"=",
"count",
"(",
"$",
"this",
"->",
"columns",
")",
";",
"$",
"rowspan",
"=",
"count",
"(",
"$",
"this",
"->",
"rows",
")",
";",
"//build <thead>",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"'<th class=\"type-'",
".",
"$",
"column",
"[",
"'type'",
"]",
".",
"' '",
".",
"$",
"column",
"[",
"'name'",
"]",
".",
"'\">'",
".",
"$",
"column",
"[",
"'label'",
"]",
".",
"'</th>'",
";",
"}",
"$",
"head",
"=",
"'<thead><tr>'",
".",
"implode",
"(",
"$",
"columns",
")",
".",
"'</tr></thead>'",
";",
"//build rows",
"$",
"bodies",
"=",
"$",
"rows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"$",
"link",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"//handle groupings",
"if",
"(",
"$",
"this",
"->",
"grouped",
"&&",
"(",
"$",
"last_group",
"!=",
"$",
"row",
"->",
"{",
"$",
"this",
"->",
"grouped",
"}",
")",
")",
"{",
"$",
"last_group",
"=",
"$",
"row",
"->",
"{",
"$",
"this",
"->",
"grouped",
"}",
";",
"if",
"(",
"count",
"(",
"$",
"rows",
")",
")",
"$",
"bodies",
"[",
"]",
"=",
"'<tbody>'",
".",
"implode",
"(",
"$",
"rows",
")",
".",
"'</tbody>'",
";",
"$",
"bodies",
"[",
"]",
"=",
"'<tr class=\"group\"><td colspan='",
".",
"$",
"colspan",
".",
"'\">'",
".",
"$",
"last_group",
".",
"'</td></tr>'",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"}",
"//process value if necessary",
"if",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'draggy'",
")",
"{",
"$",
"value",
"=",
"config",
"(",
"'center.icons.drag'",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'delete'",
")",
"{",
"$",
"value",
"=",
"'<a href=\"'",
".",
"$",
"row",
"->",
"delete",
".",
"'\">'",
".",
"(",
"$",
"row",
"->",
"deleted_at",
"?",
"config",
"(",
"'center.icons.deleted'",
")",
":",
"config",
"(",
"'center.icons.undeleted'",
")",
")",
".",
"'</a>'",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'image'",
")",
"{",
"$",
"value",
"=",
"'<img src=\"'",
".",
"$",
"row",
"->",
"{",
"$",
"column",
"[",
"'name'",
"]",
".",
"'_url'",
"}",
".",
"'\" width=\"'",
".",
"$",
"column",
"[",
"'width'",
"]",
".",
"'\" height=\"'",
".",
"$",
"column",
"[",
"'height'",
"]",
".",
"'\">'",
";",
"if",
"(",
"isset",
"(",
"$",
"row",
"->",
"link",
")",
")",
"$",
"value",
"=",
"'<a href=\"'",
".",
"$",
"row",
"->",
"link",
".",
"'\">'",
".",
"$",
"value",
".",
"'</a>'",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'stripe_charge'",
")",
"{",
"$",
"value",
"=",
"$",
"row",
"->",
"{",
"$",
"column",
"[",
"'name'",
"]",
"}",
"?",
"'<a href=\"https://dashboard.stripe.com/payments/'",
".",
"$",
"row",
"->",
"{",
"$",
"column",
"[",
"'name'",
"]",
"}",
".",
"'\" target=\"_blank\">'",
".",
"config",
"(",
"'center.icons.new_window'",
")",
".",
"' '",
".",
"trans",
"(",
"'center::site.stripe_open'",
")",
".",
"'</a>'",
":",
"''",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"Str",
"::",
"limit",
"(",
"strip_tags",
"(",
"$",
"row",
"->",
"{",
"$",
"column",
"[",
"'name'",
"]",
"}",
")",
")",
";",
"if",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'updated_at'",
")",
"{",
"$",
"value",
"=",
"Dates",
"::",
"relative",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'time'",
")",
"{",
"$",
"value",
"=",
"Dates",
"::",
"time",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'date'",
")",
"{",
"$",
"value",
"=",
"Dates",
"::",
"absolute",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'date-relative'",
")",
"{",
"$",
"value",
"=",
"Dates",
"::",
"relative",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"column",
"[",
"'type'",
"]",
",",
"[",
"'datetime'",
",",
"'timestamp'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"Dates",
"::",
"absolute",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'checkbox'",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"?",
"trans",
"(",
"'center::site.yes'",
")",
":",
"trans",
"(",
"'center::site.no'",
")",
";",
"}",
"elseif",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'money'",
")",
"{",
"$",
"value",
"=",
"'$'",
".",
"number_format",
"(",
"$",
"value",
",",
"2",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"row",
"->",
"link",
")",
"&&",
"$",
"link",
")",
"{",
"if",
"(",
"$",
"column",
"[",
"'type'",
"]",
"==",
"'color'",
")",
"{",
"$",
"value",
"=",
"'<a href=\"'",
".",
"$",
"row",
"->",
"link",
".",
"'\" style=\"background-color: '",
".",
"$",
"value",
".",
"'\"></a>'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"value",
"==",
"''",
")",
"$",
"value",
"=",
"'…'",
";",
"$",
"value",
"=",
"'<a href=\"'",
".",
"$",
"row",
"->",
"link",
".",
"'\">'",
".",
"$",
"value",
".",
"'</a>'",
";",
"$",
"link",
"=",
"false",
";",
"}",
"}",
"}",
"//create cell",
"$",
"columns",
"[",
"]",
"=",
"'<td class=\"type-'",
".",
"$",
"column",
"[",
"'type'",
"]",
".",
"' '",
".",
"$",
"column",
"[",
"'name'",
"]",
".",
"'\">'",
".",
"$",
"value",
".",
"'</td>'",
";",
"}",
"//create row",
"$",
"rows",
"[",
"]",
"=",
"'<tr'",
".",
"(",
"empty",
"(",
"$",
"row",
"->",
"id",
")",
"?",
"''",
":",
"' id=\"'",
".",
"$",
"row",
"->",
"id",
".",
"'\"'",
")",
".",
"(",
"$",
"this",
"->",
"deletable",
"&&",
"$",
"row",
"->",
"deleted_at",
"?",
"' class=\"inactive\"'",
":",
"''",
")",
".",
"'>'",
".",
"implode",
"(",
"$",
"columns",
")",
".",
"'</tr>'",
";",
"}",
"$",
"bodies",
"[",
"]",
"=",
"'<tbody>'",
".",
"implode",
"(",
"$",
"rows",
")",
".",
"'</tbody>'",
";",
"//output",
"return",
"'<table id=\"'",
".",
"$",
"id",
".",
"'\" class=\"table table-condensed'",
".",
"(",
"$",
"this",
"->",
"draggable",
"?",
"' draggable\" data-draggable-url=\"'",
".",
"$",
"this",
"->",
"draggable",
":",
"''",
")",
".",
"'\" data-csrf-token=\"'",
".",
"Session",
"::",
"token",
"(",
")",
".",
"'\">'",
".",
"$",
"head",
".",
"implode",
"(",
"$",
"bodies",
")",
".",
"'</table>'",
";",
"}"
] | draw the table | [
"draw",
"the",
"table"
] | train | https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/libraries/Table.php#L39-L124 |
xinix-technology/norm | src/Norm/Type/Collection.php | Collection.compare | public function compare($another)
{
if ($another instanceof Collection) {
$another = $another->toArray();
}
$me = $this->toArray();
if ($me == $another) {
return 0;
} else {
return 1;
}
} | php | public function compare($another)
{
if ($another instanceof Collection) {
$another = $another->toArray();
}
$me = $this->toArray();
if ($me == $another) {
return 0;
} else {
return 1;
}
} | [
"public",
"function",
"compare",
"(",
"$",
"another",
")",
"{",
"if",
"(",
"$",
"another",
"instanceof",
"Collection",
")",
"{",
"$",
"another",
"=",
"$",
"another",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"me",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"$",
"me",
"==",
"$",
"another",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"1",
";",
"}",
"}"
] | Perform comparison between this implementation and another implementation of `\Norm\Type\Collection` or an array.
@param mixed $another
@return int | [
"Perform",
"comparison",
"between",
"this",
"implementation",
"and",
"another",
"implementation",
"of",
"\\",
"Norm",
"\\",
"Type",
"\\",
"Collection",
"or",
"an",
"array",
"."
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Type/Collection.php#L186-L199 |
webignition/website-sitemap-finder | src/WebsiteSitemapFinder.php | WebsiteSitemapFinder.findSitemapUrls | public function findSitemapUrls(UriInterface $uri): array
{
$sitemapUrls = $this->findSitemapUrlsFromRobotsTxt($uri);
if (empty($sitemapUrls)) {
$sitemapUrls = [
AbsoluteUrlDeriver::derive(new Uri($uri), new Uri('/' . self::DEFAULT_SITEMAP_XML_FILE_NAME)),
AbsoluteUrlDeriver::derive(new Uri($uri), new Uri('/' . self::DEFAULT_SITEMAP_TXT_FILE_NAME)),
];
}
return $sitemapUrls;
} | php | public function findSitemapUrls(UriInterface $uri): array
{
$sitemapUrls = $this->findSitemapUrlsFromRobotsTxt($uri);
if (empty($sitemapUrls)) {
$sitemapUrls = [
AbsoluteUrlDeriver::derive(new Uri($uri), new Uri('/' . self::DEFAULT_SITEMAP_XML_FILE_NAME)),
AbsoluteUrlDeriver::derive(new Uri($uri), new Uri('/' . self::DEFAULT_SITEMAP_TXT_FILE_NAME)),
];
}
return $sitemapUrls;
} | [
"public",
"function",
"findSitemapUrls",
"(",
"UriInterface",
"$",
"uri",
")",
":",
"array",
"{",
"$",
"sitemapUrls",
"=",
"$",
"this",
"->",
"findSitemapUrlsFromRobotsTxt",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"sitemapUrls",
")",
")",
"{",
"$",
"sitemapUrls",
"=",
"[",
"AbsoluteUrlDeriver",
"::",
"derive",
"(",
"new",
"Uri",
"(",
"$",
"uri",
")",
",",
"new",
"Uri",
"(",
"'/'",
".",
"self",
"::",
"DEFAULT_SITEMAP_XML_FILE_NAME",
")",
")",
",",
"AbsoluteUrlDeriver",
"::",
"derive",
"(",
"new",
"Uri",
"(",
"$",
"uri",
")",
",",
"new",
"Uri",
"(",
"'/'",
".",
"self",
"::",
"DEFAULT_SITEMAP_TXT_FILE_NAME",
")",
")",
",",
"]",
";",
"}",
"return",
"$",
"sitemapUrls",
";",
"}"
] | @param UriInterface $uri
@return UriInterface[] | [
"@param",
"UriInterface",
"$uri"
] | train | https://github.com/webignition/website-sitemap-finder/blob/980f2fea4990c7bd942ebc28be7c79906997f187/src/WebsiteSitemapFinder.php#L38-L49 |
webignition/website-sitemap-finder | src/WebsiteSitemapFinder.php | WebsiteSitemapFinder.findSitemapUrlsFromRobotsTxt | private function findSitemapUrlsFromRobotsTxt(UriInterface $uri): array
{
$sitemapUris = [];
$robotsTxtContent = $this->retrieveRobotsTxtContent($uri);
if (empty($robotsTxtContent)) {
return $sitemapUris;
}
$robotsTxtFileParser = new RobotsTxtFileParser();
$robotsTxtFileParser->setSource($robotsTxtContent);
$robotsTxtFile = $robotsTxtFileParser->getFile();
$sitemapDirectives = $robotsTxtFile->getNonGroupDirectives()->getByField('sitemap');
foreach ($sitemapDirectives->getDirectives() as $sitemapDirective) {
$sitemapUrlValue = $sitemapDirective->getValue()->get();
$sitemapUri = AbsoluteUrlDeriver::derive($uri, new Uri($sitemapUrlValue));
$sitemapUri = Normalizer::normalize($sitemapUri);
$sitemapUris[(string) $sitemapUri] = $sitemapUri;
}
return array_values($sitemapUris);
} | php | private function findSitemapUrlsFromRobotsTxt(UriInterface $uri): array
{
$sitemapUris = [];
$robotsTxtContent = $this->retrieveRobotsTxtContent($uri);
if (empty($robotsTxtContent)) {
return $sitemapUris;
}
$robotsTxtFileParser = new RobotsTxtFileParser();
$robotsTxtFileParser->setSource($robotsTxtContent);
$robotsTxtFile = $robotsTxtFileParser->getFile();
$sitemapDirectives = $robotsTxtFile->getNonGroupDirectives()->getByField('sitemap');
foreach ($sitemapDirectives->getDirectives() as $sitemapDirective) {
$sitemapUrlValue = $sitemapDirective->getValue()->get();
$sitemapUri = AbsoluteUrlDeriver::derive($uri, new Uri($sitemapUrlValue));
$sitemapUri = Normalizer::normalize($sitemapUri);
$sitemapUris[(string) $sitemapUri] = $sitemapUri;
}
return array_values($sitemapUris);
} | [
"private",
"function",
"findSitemapUrlsFromRobotsTxt",
"(",
"UriInterface",
"$",
"uri",
")",
":",
"array",
"{",
"$",
"sitemapUris",
"=",
"[",
"]",
";",
"$",
"robotsTxtContent",
"=",
"$",
"this",
"->",
"retrieveRobotsTxtContent",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"robotsTxtContent",
")",
")",
"{",
"return",
"$",
"sitemapUris",
";",
"}",
"$",
"robotsTxtFileParser",
"=",
"new",
"RobotsTxtFileParser",
"(",
")",
";",
"$",
"robotsTxtFileParser",
"->",
"setSource",
"(",
"$",
"robotsTxtContent",
")",
";",
"$",
"robotsTxtFile",
"=",
"$",
"robotsTxtFileParser",
"->",
"getFile",
"(",
")",
";",
"$",
"sitemapDirectives",
"=",
"$",
"robotsTxtFile",
"->",
"getNonGroupDirectives",
"(",
")",
"->",
"getByField",
"(",
"'sitemap'",
")",
";",
"foreach",
"(",
"$",
"sitemapDirectives",
"->",
"getDirectives",
"(",
")",
"as",
"$",
"sitemapDirective",
")",
"{",
"$",
"sitemapUrlValue",
"=",
"$",
"sitemapDirective",
"->",
"getValue",
"(",
")",
"->",
"get",
"(",
")",
";",
"$",
"sitemapUri",
"=",
"AbsoluteUrlDeriver",
"::",
"derive",
"(",
"$",
"uri",
",",
"new",
"Uri",
"(",
"$",
"sitemapUrlValue",
")",
")",
";",
"$",
"sitemapUri",
"=",
"Normalizer",
"::",
"normalize",
"(",
"$",
"sitemapUri",
")",
";",
"$",
"sitemapUris",
"[",
"(",
"string",
")",
"$",
"sitemapUri",
"]",
"=",
"$",
"sitemapUri",
";",
"}",
"return",
"array_values",
"(",
"$",
"sitemapUris",
")",
";",
"}"
] | @param UriInterface $uri
@return UriInterface[] | [
"@param",
"UriInterface",
"$uri"
] | train | https://github.com/webignition/website-sitemap-finder/blob/980f2fea4990c7bd942ebc28be7c79906997f187/src/WebsiteSitemapFinder.php#L56-L82 |
npbtrac/yii2-enpii-cms | libs/helpers/NpDateTimeHelper.php | NpDateTimeHelper.toDbFormat | public static function toDbFormat($format = "Y-m-d H:i:s", $timestamp = null)
{
if ($timestamp === null) {
$timestamp = time();
}
return date($format, $timestamp);
} | php | public static function toDbFormat($format = "Y-m-d H:i:s", $timestamp = null)
{
if ($timestamp === null) {
$timestamp = time();
}
return date($format, $timestamp);
} | [
"public",
"static",
"function",
"toDbFormat",
"(",
"$",
"format",
"=",
"\"Y-m-d H:i:s\"",
",",
"$",
"timestamp",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"timestamp",
"===",
"null",
")",
"{",
"$",
"timestamp",
"=",
"time",
"(",
")",
";",
"}",
"return",
"date",
"(",
"$",
"format",
",",
"$",
"timestamp",
")",
";",
"}"
] | Get datetime format to put to database. Use GMT time for database
@param string $format
@param null $timestamp
@return string | [
"Get",
"datetime",
"format",
"to",
"put",
"to",
"database",
".",
"Use",
"GMT",
"time",
"for",
"database"
] | train | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/helpers/NpDateTimeHelper.php#L19-L25 |
npbtrac/yii2-enpii-cms | libs/helpers/NpDateTimeHelper.php | NpDateTimeHelper.toDbFormatGmt | public static function toDbFormatGmt($format = "Y-m-d H:i:s", $timestamp = null)
{
if ($timestamp === null) {
$timestamp = time();
}
return gmdate($format, $timestamp);
} | php | public static function toDbFormatGmt($format = "Y-m-d H:i:s", $timestamp = null)
{
if ($timestamp === null) {
$timestamp = time();
}
return gmdate($format, $timestamp);
} | [
"public",
"static",
"function",
"toDbFormatGmt",
"(",
"$",
"format",
"=",
"\"Y-m-d H:i:s\"",
",",
"$",
"timestamp",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"timestamp",
"===",
"null",
")",
"{",
"$",
"timestamp",
"=",
"time",
"(",
")",
";",
"}",
"return",
"gmdate",
"(",
"$",
"format",
",",
"$",
"timestamp",
")",
";",
"}"
] | Get datetime format to put to database. Use GMT time for database
@param string $format
@param null $timestamp
@return string | [
"Get",
"datetime",
"format",
"to",
"put",
"to",
"database",
".",
"Use",
"GMT",
"time",
"for",
"database"
] | train | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/helpers/NpDateTimeHelper.php#L33-L39 |
qcubed/orm | src/Query/Condition/ConditionBase.php | ConditionBase.getWhereClause | public function getWhereClause(Builder $objBuilder, $blnProcessOnce = false)
{
if ($blnProcessOnce && $this->blnProcessed) {
return null;
}
$this->blnProcessed = true;
try {
$objConditionBuilder = new PartialBuilder($objBuilder);
$this->updateQueryBuilder($objConditionBuilder);
return $objConditionBuilder->getWhereStatement();
} catch (Caller $objExc) {
$objExc->incrementOffset();
$objExc->incrementOffset();
throw $objExc;
}
} | php | public function getWhereClause(Builder $objBuilder, $blnProcessOnce = false)
{
if ($blnProcessOnce && $this->blnProcessed) {
return null;
}
$this->blnProcessed = true;
try {
$objConditionBuilder = new PartialBuilder($objBuilder);
$this->updateQueryBuilder($objConditionBuilder);
return $objConditionBuilder->getWhereStatement();
} catch (Caller $objExc) {
$objExc->incrementOffset();
$objExc->incrementOffset();
throw $objExc;
}
} | [
"public",
"function",
"getWhereClause",
"(",
"Builder",
"$",
"objBuilder",
",",
"$",
"blnProcessOnce",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"blnProcessOnce",
"&&",
"$",
"this",
"->",
"blnProcessed",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"blnProcessed",
"=",
"true",
";",
"try",
"{",
"$",
"objConditionBuilder",
"=",
"new",
"PartialBuilder",
"(",
"$",
"objBuilder",
")",
";",
"$",
"this",
"->",
"updateQueryBuilder",
"(",
"$",
"objConditionBuilder",
")",
";",
"return",
"$",
"objConditionBuilder",
"->",
"getWhereStatement",
"(",
")",
";",
"}",
"catch",
"(",
"Caller",
"$",
"objExc",
")",
"{",
"$",
"objExc",
"->",
"incrementOffset",
"(",
")",
";",
"$",
"objExc",
"->",
"incrementOffset",
"(",
")",
";",
"throw",
"$",
"objExc",
";",
"}",
"}"
] | Used internally by QCubed Query to get an individual where clause for a given condition
Mostly used for conditional joins.
@param Builder $objBuilder
@param bool|false $blnProcessOnce
@return null|string
@throws \Exception
@throws Caller | [
"Used",
"internally",
"by",
"QCubed",
"Query",
"to",
"get",
"an",
"individual",
"where",
"clause",
"for",
"a",
"given",
"condition",
"Mostly",
"used",
"for",
"conditional",
"joins",
"."
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Condition/ConditionBase.php#L46-L63 |
Chill-project/Main | Form/Type/CenterType.php | CenterType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($this->getParent() === 'hidden') {
$builder->addModelTransformer($this->transformer);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($this->getParent() === 'hidden') {
$builder->addModelTransformer($this->transformer);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getParent",
"(",
")",
"===",
"'hidden'",
")",
"{",
"$",
"builder",
"->",
"addModelTransformer",
"(",
"$",
"this",
"->",
"transformer",
")",
";",
"}",
"}"
] | add a data transformer if user can reach only one center
@param FormBuilderInterface $builder
@param array $options | [
"add",
"a",
"data",
"transformer",
"if",
"user",
"can",
"reach",
"only",
"one",
"center"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Form/Type/CenterType.php#L111-L116 |
Chill-project/Main | Form/Type/CenterType.php | CenterType.prepareReachableCenterByUser | private function prepareReachableCenterByUser()
{
$groupCenters = $this->user->getGroupCenters();
foreach ($groupCenters as $groupCenter) {
$center = $groupCenter->getCenter();
if (!array_key_exists($center->getId(),
$this->reachableCenters)) {
$this->reachableCenters[$center->getId()] = $center;
}
}
} | php | private function prepareReachableCenterByUser()
{
$groupCenters = $this->user->getGroupCenters();
foreach ($groupCenters as $groupCenter) {
$center = $groupCenter->getCenter();
if (!array_key_exists($center->getId(),
$this->reachableCenters)) {
$this->reachableCenters[$center->getId()] = $center;
}
}
} | [
"private",
"function",
"prepareReachableCenterByUser",
"(",
")",
"{",
"$",
"groupCenters",
"=",
"$",
"this",
"->",
"user",
"->",
"getGroupCenters",
"(",
")",
";",
"foreach",
"(",
"$",
"groupCenters",
"as",
"$",
"groupCenter",
")",
"{",
"$",
"center",
"=",
"$",
"groupCenter",
"->",
"getCenter",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"center",
"->",
"getId",
"(",
")",
",",
"$",
"this",
"->",
"reachableCenters",
")",
")",
"{",
"$",
"this",
"->",
"reachableCenters",
"[",
"$",
"center",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"center",
";",
"}",
"}",
"}"
] | populate reachableCenters as an associative array where
keys are center.id and value are center entities. | [
"populate",
"reachableCenters",
"as",
"an",
"associative",
"array",
"where",
"keys",
"are",
"center",
".",
"id",
"and",
"value",
"are",
"center",
"entities",
"."
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Form/Type/CenterType.php#L123-L136 |
ClanCats/Core | src/classes/CCJson.php | CCJson.encode | public static function encode( $array, $beautify = false )
{
// php53 fix
if ( defined( 'JSON_UNESCAPED_SLASHES' ) )
{
$json = json_encode( $array, JSON_UNESCAPED_SLASHES );
}
else
{
$json = json_encode( $array );
}
if ( $beautify )
{
return static::beautify( $json );
}
return $json;
} | php | public static function encode( $array, $beautify = false )
{
// php53 fix
if ( defined( 'JSON_UNESCAPED_SLASHES' ) )
{
$json = json_encode( $array, JSON_UNESCAPED_SLASHES );
}
else
{
$json = json_encode( $array );
}
if ( $beautify )
{
return static::beautify( $json );
}
return $json;
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"array",
",",
"$",
"beautify",
"=",
"false",
")",
"{",
"// php53 fix",
"if",
"(",
"defined",
"(",
"'JSON_UNESCAPED_SLASHES'",
")",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"array",
",",
"JSON_UNESCAPED_SLASHES",
")",
";",
"}",
"else",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"array",
")",
";",
"}",
"if",
"(",
"$",
"beautify",
")",
"{",
"return",
"static",
"::",
"beautify",
"(",
"$",
"json",
")",
";",
"}",
"return",
"$",
"json",
";",
"}"
] | encode json
@param array $array
@param bool $beautify
@return string | [
"encode",
"json"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCJson.php#L25-L43 |
ClanCats/Core | src/classes/CCJson.php | CCJson.beautify | public static function beautify( $json, $tab = "\t", $break = "\n" ) {
$buffer = "";
$level = 0;
$in_string = false;
$len = strlen( $json );
for($c = 0; $c < $len; $c++) {
$char = $json[$c];
switch( $char ) {
case '{':
case '[':
if( !$in_string ) {
$buffer .= $char . "\n" . str_repeat($tab, $level+1); $level++;
} else {
$buffer .= $char;
}
break;
case '}':
case ']':
if( !$in_string ) {
$level--; $buffer .= "\n" . str_repeat($tab, $level) . $char;
} else {
$buffer .= $char;
}
break;
case ',':
if( !$in_string ) {
$buffer .= ",\n" . str_repeat($tab, $level);
} else {
$buffer .= $char;
}
break;
case ':':
if( !$in_string ) {
$buffer .= ": ";
} else {
$buffer .= $char;
}
break;
case '"':
if( $c > 0 && $json[$c-1] != '\\' ) {
$in_string = !$in_string;
}
default:
$buffer .= $char;
break;
}
}
return $buffer;
} | php | public static function beautify( $json, $tab = "\t", $break = "\n" ) {
$buffer = "";
$level = 0;
$in_string = false;
$len = strlen( $json );
for($c = 0; $c < $len; $c++) {
$char = $json[$c];
switch( $char ) {
case '{':
case '[':
if( !$in_string ) {
$buffer .= $char . "\n" . str_repeat($tab, $level+1); $level++;
} else {
$buffer .= $char;
}
break;
case '}':
case ']':
if( !$in_string ) {
$level--; $buffer .= "\n" . str_repeat($tab, $level) . $char;
} else {
$buffer .= $char;
}
break;
case ',':
if( !$in_string ) {
$buffer .= ",\n" . str_repeat($tab, $level);
} else {
$buffer .= $char;
}
break;
case ':':
if( !$in_string ) {
$buffer .= ": ";
} else {
$buffer .= $char;
}
break;
case '"':
if( $c > 0 && $json[$c-1] != '\\' ) {
$in_string = !$in_string;
}
default:
$buffer .= $char;
break;
}
}
return $buffer;
} | [
"public",
"static",
"function",
"beautify",
"(",
"$",
"json",
",",
"$",
"tab",
"=",
"\"\\t\"",
",",
"$",
"break",
"=",
"\"\\n\"",
")",
"{",
"$",
"buffer",
"=",
"\"\"",
";",
"$",
"level",
"=",
"0",
";",
"$",
"in_string",
"=",
"false",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"json",
")",
";",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"$",
"len",
";",
"$",
"c",
"++",
")",
"{",
"$",
"char",
"=",
"$",
"json",
"[",
"$",
"c",
"]",
";",
"switch",
"(",
"$",
"char",
")",
"{",
"case",
"'{'",
":",
"case",
"'['",
":",
"if",
"(",
"!",
"$",
"in_string",
")",
"{",
"$",
"buffer",
".=",
"$",
"char",
".",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"tab",
",",
"$",
"level",
"+",
"1",
")",
";",
"$",
"level",
"++",
";",
"}",
"else",
"{",
"$",
"buffer",
".=",
"$",
"char",
";",
"}",
"break",
";",
"case",
"'}'",
":",
"case",
"']'",
":",
"if",
"(",
"!",
"$",
"in_string",
")",
"{",
"$",
"level",
"--",
";",
"$",
"buffer",
".=",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"tab",
",",
"$",
"level",
")",
".",
"$",
"char",
";",
"}",
"else",
"{",
"$",
"buffer",
".=",
"$",
"char",
";",
"}",
"break",
";",
"case",
"','",
":",
"if",
"(",
"!",
"$",
"in_string",
")",
"{",
"$",
"buffer",
".=",
"\",\\n\"",
".",
"str_repeat",
"(",
"$",
"tab",
",",
"$",
"level",
")",
";",
"}",
"else",
"{",
"$",
"buffer",
".=",
"$",
"char",
";",
"}",
"break",
";",
"case",
"':'",
":",
"if",
"(",
"!",
"$",
"in_string",
")",
"{",
"$",
"buffer",
".=",
"\": \"",
";",
"}",
"else",
"{",
"$",
"buffer",
".=",
"$",
"char",
";",
"}",
"break",
";",
"case",
"'\"'",
":",
"if",
"(",
"$",
"c",
">",
"0",
"&&",
"$",
"json",
"[",
"$",
"c",
"-",
"1",
"]",
"!=",
"'\\\\'",
")",
"{",
"$",
"in_string",
"=",
"!",
"$",
"in_string",
";",
"}",
"default",
":",
"$",
"buffer",
".=",
"$",
"char",
";",
"break",
";",
"}",
"}",
"return",
"$",
"buffer",
";",
"}"
] | beautifier
@param string $json
@param string $tab
@param strgin $break
@return string | [
"beautifier"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCJson.php#L87-L141 |
webforge-labs/psc-cms | lib/Psc/System/SimpleRarArchive.php | SimpleRarArchive.extractTo | public function extractTo(WebforgeDir $dir = NULL) {
if (!isset($dir))
$dir = $this->rar->getDirectory();
else
$dir->create();
$this->exec('x', array('y'), (string) $dir);
return $this;
} | php | public function extractTo(WebforgeDir $dir = NULL) {
if (!isset($dir))
$dir = $this->rar->getDirectory();
else
$dir->create();
$this->exec('x', array('y'), (string) $dir);
return $this;
} | [
"public",
"function",
"extractTo",
"(",
"WebforgeDir",
"$",
"dir",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"dir",
")",
")",
"$",
"dir",
"=",
"$",
"this",
"->",
"rar",
"->",
"getDirectory",
"(",
")",
";",
"else",
"$",
"dir",
"->",
"create",
"(",
")",
";",
"$",
"this",
"->",
"exec",
"(",
"'x'",
",",
"array",
"(",
"'y'",
")",
",",
"(",
"string",
")",
"$",
"dir",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Entpackt alle Dateien des Archives in ein Verzeichnis
wird das Verzeichnis nicht angegeben, so wird das Verzeichnis genommen in dem sich das Archiv befindet
existiert das Verzeichnis nicht, wird es angelegt | [
"Entpackt",
"alle",
"Dateien",
"des",
"Archives",
"in",
"ein",
"Verzeichnis"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/System/SimpleRarArchive.php#L38-L46 |
jfusion/org.jfusion.framework | src/Installer/Plugin.php | Plugin.install | function install($dir = null, &$result)
{
// Get a database connector object
$db = Factory::getDBO();
$result['status'] = false;
$result['name'] = null;
if (!$dir && !is_dir(Path::clean($dir))) {
$this->installer->abort(Text::_('INSTALL_INVALID_PATH'));
throw new RuntimeException(Text::_('INSTALL_INVALID_PATH'));
} else {
$this->installer->setPath('source', $dir);
// Get the extension manifest object
$manifest = $this->getManifest($dir);
if (is_null($manifest)) {
$this->installer->abort(Text::_('INSTALL_NOT_VALID_PLUGIN'));
throw new RuntimeException(Text::_('INSTALL_NOT_VALID_PLUGIN'));
} else {
$this->manifest = $manifest;
$framework = JFusionFramework::getComposerInfo();
$version = $this->getAttribute($this->manifest, 'version');
/**
* ---------------------------------------------------------------------------------------------
* Manifest Document Setup Section
* ---------------------------------------------------------------------------------------------
*/
// Set the extensions name
/**
* Check that the plugin is an actual JFusion plugin
*/
$name = $this->manifest->name;
$name = $this->filterInput->clean($name, 'string');
if (!$framework || !$version || version_compare($framework->version, $version) >= 0 || $framework->version == 'dev-master') {
$result['name'] = $name;
$this->name = $name;
// installation path
$this->installer->setPath('extension_root', JFusionFramework::getPluginPath($name));
// get files to copy
/**
* ---------------------------------------------------------------------------------------------
* Filesystem Processing Section
* ---------------------------------------------------------------------------------------------
*/
// If the plugin directory does not exist, lets create it
$created = false;
if (!file_exists($this->installer->getPath('extension_root'))) {
if (!$created = Folder::create($this->installer->getPath('extension_root'))) {
$msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('INSTALL_FAILED_DIRECTORY') . ': "' . $this->installer->getPath('extension_root') . '"';
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
}
}
/**
* If we created the plugin directory and will want to remove it if we
* have to roll back the installation, lets add it to the installation
* step stack
*/
if ($created) {
$this->installer->pushStep(array('type' => 'folder', 'path' => $this->installer->getPath('extension_root')));
}
// Copy all necessary files
if ($this->installer->parseFiles($this->manifest->files[0], -1) === false) {
// Install failed, roll back changes
$this->installer->abort();
throw new RuntimeException($name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('FAILED'));
} else {
$vendor = $dir . '/vendor';
if (is_dir(Path::clean($vendor))) {
Folder::copy($vendor, $this->installer->getPath('extension_root') . '/vendor', '', true);
}
$language = $dir . '/language';
if (is_dir(Path::clean($language))) {
Folder::copy($language, $this->installer->getPath('extension_root') . '/language', '', true);
}
/**
* ---------------------------------------------------------------------------------------------
* Database Processing Section
* ---------------------------------------------------------------------------------------------
*/
//let's check to see if a plugin with the same name is already installed
$query = $db->getQuery(true)
->select('id')
->from('#__jfusion')
->where('name = ' . $db->quote($name));
$db->setQuery($query);
$plugin = $db->loadObject();
if (!empty($plugin)) {
if (!$this->installer->isOverwrite()) {
// Install failed, roll back changes
$msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('PLUGIN') . ' "' . $name . '" ' . Text::_('ALREADY_EXISTS');
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
} else {
//set the overwrite tag
$result['overwrite'] = 1;
}
} else {
//prepare the variables
$result['overwrite'] = 0;
$plugin_entry = new stdClass;
$plugin_entry->id = null;
$plugin_entry->name = $name;
$plugin_entry->dual_login = 0;
//now append the new plugin data
try {
$db->insertObject('#__jfusion', $plugin_entry, 'id');
} catch (Exception $e) {
// Install failed, roll back changes
$msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ' ' . Text::_('ERROR') . ': ' . $e->getMessage();
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
}
$this->installer->pushStep(array('type' => 'plugin', 'id' => $plugin_entry->id));
}
/**
* ---------------------------------------------------------------------------------------------
* Finalization and Cleanup Section
* ---------------------------------------------------------------------------------------------
*/
//check to see if this is updating a plugin that has been copied
$query = $db->getQuery(true)
->select('name')
->from('#__jfusion')
->where('original_name = ' . $db->quote($name));
$db->setQuery($query);
$copiedPlugins = $db->loadObjectList();
foreach ($copiedPlugins as $plugin) {
//update the copied version with the new files
// $this->copy($name, $plugin->name, true);
}
if ($result['overwrite'] == 1) {
$msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UPDATE') . ': ' . Text::_('SUCCESS');
} else {
$msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('SUCCESS');
}
$result['message'] = $name . ': ' . $msg;
$result['status'] = true;
}
} else {
$msg = Text::_('PLUGIN') . ' ' . $name . ': ' . Text::_('FAILED') . ' ' . Text::_('NEED_JFUSION_VERSION') . ' "' . $version . '" ' . Text::_('OR_HIGHER');
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
}
}
}
return $result;
} | php | function install($dir = null, &$result)
{
// Get a database connector object
$db = Factory::getDBO();
$result['status'] = false;
$result['name'] = null;
if (!$dir && !is_dir(Path::clean($dir))) {
$this->installer->abort(Text::_('INSTALL_INVALID_PATH'));
throw new RuntimeException(Text::_('INSTALL_INVALID_PATH'));
} else {
$this->installer->setPath('source', $dir);
// Get the extension manifest object
$manifest = $this->getManifest($dir);
if (is_null($manifest)) {
$this->installer->abort(Text::_('INSTALL_NOT_VALID_PLUGIN'));
throw new RuntimeException(Text::_('INSTALL_NOT_VALID_PLUGIN'));
} else {
$this->manifest = $manifest;
$framework = JFusionFramework::getComposerInfo();
$version = $this->getAttribute($this->manifest, 'version');
/**
* ---------------------------------------------------------------------------------------------
* Manifest Document Setup Section
* ---------------------------------------------------------------------------------------------
*/
// Set the extensions name
/**
* Check that the plugin is an actual JFusion plugin
*/
$name = $this->manifest->name;
$name = $this->filterInput->clean($name, 'string');
if (!$framework || !$version || version_compare($framework->version, $version) >= 0 || $framework->version == 'dev-master') {
$result['name'] = $name;
$this->name = $name;
// installation path
$this->installer->setPath('extension_root', JFusionFramework::getPluginPath($name));
// get files to copy
/**
* ---------------------------------------------------------------------------------------------
* Filesystem Processing Section
* ---------------------------------------------------------------------------------------------
*/
// If the plugin directory does not exist, lets create it
$created = false;
if (!file_exists($this->installer->getPath('extension_root'))) {
if (!$created = Folder::create($this->installer->getPath('extension_root'))) {
$msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('INSTALL_FAILED_DIRECTORY') . ': "' . $this->installer->getPath('extension_root') . '"';
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
}
}
/**
* If we created the plugin directory and will want to remove it if we
* have to roll back the installation, lets add it to the installation
* step stack
*/
if ($created) {
$this->installer->pushStep(array('type' => 'folder', 'path' => $this->installer->getPath('extension_root')));
}
// Copy all necessary files
if ($this->installer->parseFiles($this->manifest->files[0], -1) === false) {
// Install failed, roll back changes
$this->installer->abort();
throw new RuntimeException($name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('FAILED'));
} else {
$vendor = $dir . '/vendor';
if (is_dir(Path::clean($vendor))) {
Folder::copy($vendor, $this->installer->getPath('extension_root') . '/vendor', '', true);
}
$language = $dir . '/language';
if (is_dir(Path::clean($language))) {
Folder::copy($language, $this->installer->getPath('extension_root') . '/language', '', true);
}
/**
* ---------------------------------------------------------------------------------------------
* Database Processing Section
* ---------------------------------------------------------------------------------------------
*/
//let's check to see if a plugin with the same name is already installed
$query = $db->getQuery(true)
->select('id')
->from('#__jfusion')
->where('name = ' . $db->quote($name));
$db->setQuery($query);
$plugin = $db->loadObject();
if (!empty($plugin)) {
if (!$this->installer->isOverwrite()) {
// Install failed, roll back changes
$msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('PLUGIN') . ' "' . $name . '" ' . Text::_('ALREADY_EXISTS');
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
} else {
//set the overwrite tag
$result['overwrite'] = 1;
}
} else {
//prepare the variables
$result['overwrite'] = 0;
$plugin_entry = new stdClass;
$plugin_entry->id = null;
$plugin_entry->name = $name;
$plugin_entry->dual_login = 0;
//now append the new plugin data
try {
$db->insertObject('#__jfusion', $plugin_entry, 'id');
} catch (Exception $e) {
// Install failed, roll back changes
$msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ' ' . Text::_('ERROR') . ': ' . $e->getMessage();
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
}
$this->installer->pushStep(array('type' => 'plugin', 'id' => $plugin_entry->id));
}
/**
* ---------------------------------------------------------------------------------------------
* Finalization and Cleanup Section
* ---------------------------------------------------------------------------------------------
*/
//check to see if this is updating a plugin that has been copied
$query = $db->getQuery(true)
->select('name')
->from('#__jfusion')
->where('original_name = ' . $db->quote($name));
$db->setQuery($query);
$copiedPlugins = $db->loadObjectList();
foreach ($copiedPlugins as $plugin) {
//update the copied version with the new files
// $this->copy($name, $plugin->name, true);
}
if ($result['overwrite'] == 1) {
$msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UPDATE') . ': ' . Text::_('SUCCESS');
} else {
$msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('SUCCESS');
}
$result['message'] = $name . ': ' . $msg;
$result['status'] = true;
}
} else {
$msg = Text::_('PLUGIN') . ' ' . $name . ': ' . Text::_('FAILED') . ' ' . Text::_('NEED_JFUSION_VERSION') . ' "' . $version . '" ' . Text::_('OR_HIGHER');
$this->installer->abort($msg);
throw new RuntimeException($name . ': ' . $msg);
}
}
}
return $result;
} | [
"function",
"install",
"(",
"$",
"dir",
"=",
"null",
",",
"&",
"$",
"result",
")",
"{",
"// Get a database connector object",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"false",
";",
"$",
"result",
"[",
"'name'",
"]",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"dir",
"&&",
"!",
"is_dir",
"(",
"Path",
"::",
"clean",
"(",
"$",
"dir",
")",
")",
")",
"{",
"$",
"this",
"->",
"installer",
"->",
"abort",
"(",
"Text",
"::",
"_",
"(",
"'INSTALL_INVALID_PATH'",
")",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'INSTALL_INVALID_PATH'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"installer",
"->",
"setPath",
"(",
"'source'",
",",
"$",
"dir",
")",
";",
"// Get the extension manifest object",
"$",
"manifest",
"=",
"$",
"this",
"->",
"getManifest",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"manifest",
")",
")",
"{",
"$",
"this",
"->",
"installer",
"->",
"abort",
"(",
"Text",
"::",
"_",
"(",
"'INSTALL_NOT_VALID_PLUGIN'",
")",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'INSTALL_NOT_VALID_PLUGIN'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"manifest",
"=",
"$",
"manifest",
";",
"$",
"framework",
"=",
"JFusionFramework",
"::",
"getComposerInfo",
"(",
")",
";",
"$",
"version",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"manifest",
",",
"'version'",
")",
";",
"/**\n\t * ---------------------------------------------------------------------------------------------\n\t * Manifest Document Setup Section\n\t * ---------------------------------------------------------------------------------------------\n\t */",
"// Set the extensions name",
"/**\n\t * Check that the plugin is an actual JFusion plugin\n\t */",
"$",
"name",
"=",
"$",
"this",
"->",
"manifest",
"->",
"name",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"filterInput",
"->",
"clean",
"(",
"$",
"name",
",",
"'string'",
")",
";",
"if",
"(",
"!",
"$",
"framework",
"||",
"!",
"$",
"version",
"||",
"version_compare",
"(",
"$",
"framework",
"->",
"version",
",",
"$",
"version",
")",
">=",
"0",
"||",
"$",
"framework",
"->",
"version",
"==",
"'dev-master'",
")",
"{",
"$",
"result",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"name",
";",
"// installation path",
"$",
"this",
"->",
"installer",
"->",
"setPath",
"(",
"'extension_root'",
",",
"JFusionFramework",
"::",
"getPluginPath",
"(",
"$",
"name",
")",
")",
";",
"// get files to copy",
"/**\n\t\t * ---------------------------------------------------------------------------------------------\n\t\t * Filesystem Processing Section\n\t\t * ---------------------------------------------------------------------------------------------\n\t\t */",
"// If the plugin directory does not exist, lets create it",
"$",
"created",
"=",
"false",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"installer",
"->",
"getPath",
"(",
"'extension_root'",
")",
")",
")",
"{",
"if",
"(",
"!",
"$",
"created",
"=",
"Folder",
"::",
"create",
"(",
"$",
"this",
"->",
"installer",
"->",
"getPath",
"(",
"'extension_root'",
")",
")",
")",
"{",
"$",
"msg",
"=",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'INSTALL'",
")",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'INSTALL_FAILED_DIRECTORY'",
")",
".",
"': \"'",
".",
"$",
"this",
"->",
"installer",
"->",
"getPath",
"(",
"'extension_root'",
")",
".",
"'\"'",
";",
"$",
"this",
"->",
"installer",
"->",
"abort",
"(",
"$",
"msg",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"name",
".",
"': '",
".",
"$",
"msg",
")",
";",
"}",
"}",
"/**\n\t\t * If we created the plugin directory and will want to remove it if we\n\t\t * have to roll back the installation, lets add it to the installation\n\t\t * step stack\n\t\t */",
"if",
"(",
"$",
"created",
")",
"{",
"$",
"this",
"->",
"installer",
"->",
"pushStep",
"(",
"array",
"(",
"'type'",
"=>",
"'folder'",
",",
"'path'",
"=>",
"$",
"this",
"->",
"installer",
"->",
"getPath",
"(",
"'extension_root'",
")",
")",
")",
";",
"}",
"// Copy all necessary files",
"if",
"(",
"$",
"this",
"->",
"installer",
"->",
"parseFiles",
"(",
"$",
"this",
"->",
"manifest",
"->",
"files",
"[",
"0",
"]",
",",
"-",
"1",
")",
"===",
"false",
")",
"{",
"// Install failed, roll back changes",
"$",
"this",
"->",
"installer",
"->",
"abort",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"name",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' '",
".",
"$",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'INSTALL'",
")",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'FAILED'",
")",
")",
";",
"}",
"else",
"{",
"$",
"vendor",
"=",
"$",
"dir",
".",
"'/vendor'",
";",
"if",
"(",
"is_dir",
"(",
"Path",
"::",
"clean",
"(",
"$",
"vendor",
")",
")",
")",
"{",
"Folder",
"::",
"copy",
"(",
"$",
"vendor",
",",
"$",
"this",
"->",
"installer",
"->",
"getPath",
"(",
"'extension_root'",
")",
".",
"'/vendor'",
",",
"''",
",",
"true",
")",
";",
"}",
"$",
"language",
"=",
"$",
"dir",
".",
"'/language'",
";",
"if",
"(",
"is_dir",
"(",
"Path",
"::",
"clean",
"(",
"$",
"language",
")",
")",
")",
"{",
"Folder",
"::",
"copy",
"(",
"$",
"language",
",",
"$",
"this",
"->",
"installer",
"->",
"getPath",
"(",
"'extension_root'",
")",
".",
"'/language'",
",",
"''",
",",
"true",
")",
";",
"}",
"/**\n\t\t\t * ---------------------------------------------------------------------------------------------\n\t\t\t * Database Processing Section\n\t\t\t * ---------------------------------------------------------------------------------------------\n\t\t\t */",
"//let's check to see if a plugin with the same name is already installed",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'id'",
")",
"->",
"from",
"(",
"'#__jfusion'",
")",
"->",
"where",
"(",
"'name = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"name",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"plugin",
"=",
"$",
"db",
"->",
"loadObject",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"plugin",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"installer",
"->",
"isOverwrite",
"(",
")",
")",
"{",
"// Install failed, roll back changes",
"$",
"msg",
"=",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'INSTALL'",
")",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' \"'",
".",
"$",
"name",
".",
"'\" '",
".",
"Text",
"::",
"_",
"(",
"'ALREADY_EXISTS'",
")",
";",
"$",
"this",
"->",
"installer",
"->",
"abort",
"(",
"$",
"msg",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"name",
".",
"': '",
".",
"$",
"msg",
")",
";",
"}",
"else",
"{",
"//set the overwrite tag",
"$",
"result",
"[",
"'overwrite'",
"]",
"=",
"1",
";",
"}",
"}",
"else",
"{",
"//prepare the variables",
"$",
"result",
"[",
"'overwrite'",
"]",
"=",
"0",
";",
"$",
"plugin_entry",
"=",
"new",
"stdClass",
";",
"$",
"plugin_entry",
"->",
"id",
"=",
"null",
";",
"$",
"plugin_entry",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"plugin_entry",
"->",
"dual_login",
"=",
"0",
";",
"//now append the new plugin data",
"try",
"{",
"$",
"db",
"->",
"insertObject",
"(",
"'#__jfusion'",
",",
"$",
"plugin_entry",
",",
"'id'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Install failed, roll back changes",
"$",
"msg",
"=",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'INSTALL'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'ERROR'",
")",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"this",
"->",
"installer",
"->",
"abort",
"(",
"$",
"msg",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"name",
".",
"': '",
".",
"$",
"msg",
")",
";",
"}",
"$",
"this",
"->",
"installer",
"->",
"pushStep",
"(",
"array",
"(",
"'type'",
"=>",
"'plugin'",
",",
"'id'",
"=>",
"$",
"plugin_entry",
"->",
"id",
")",
")",
";",
"}",
"/**\n\t\t\t * ---------------------------------------------------------------------------------------------\n\t\t\t * Finalization and Cleanup Section\n\t\t\t * ---------------------------------------------------------------------------------------------\n\t\t\t */",
"//check to see if this is updating a plugin that has been copied",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'name'",
")",
"->",
"from",
"(",
"'#__jfusion'",
")",
"->",
"where",
"(",
"'original_name = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"name",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"copiedPlugins",
"=",
"$",
"db",
"->",
"loadObjectList",
"(",
")",
";",
"foreach",
"(",
"$",
"copiedPlugins",
"as",
"$",
"plugin",
")",
"{",
"//update the copied version with the new files",
"//\t\t\t\t $this->copy($name, $plugin->name, true);",
"}",
"if",
"(",
"$",
"result",
"[",
"'overwrite'",
"]",
"==",
"1",
")",
"{",
"$",
"msg",
"=",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' '",
".",
"$",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'UPDATE'",
")",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'SUCCESS'",
")",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' '",
".",
"$",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'INSTALL'",
")",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'SUCCESS'",
")",
";",
"}",
"$",
"result",
"[",
"'message'",
"]",
"=",
"$",
"name",
".",
"': '",
".",
"$",
"msg",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"$",
"msg",
"=",
"Text",
"::",
"_",
"(",
"'PLUGIN'",
")",
".",
"' '",
".",
"$",
"name",
".",
"': '",
".",
"Text",
"::",
"_",
"(",
"'FAILED'",
")",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'NEED_JFUSION_VERSION'",
")",
".",
"' \"'",
".",
"$",
"version",
".",
"'\" '",
".",
"Text",
"::",
"_",
"(",
"'OR_HIGHER'",
")",
";",
"$",
"this",
"->",
"installer",
"->",
"abort",
"(",
"$",
"msg",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"name",
".",
"': '",
".",
"$",
"msg",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | handles JFusion plugin installation
@param mixed $dir install path
@param array &$result
@throws \RuntimeException
@return array | [
"handles",
"JFusion",
"plugin",
"installation"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Plugin.php#L66-L224 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.