id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
239,600
|
synapsestudios/synapse-base
|
src/Synapse/SocialLogin/SocialLoginController.php
|
SocialLoginController.auth
|
public function auth(Request $request, $action)
{
$provider = strtolower($request->attributes->get('provider'));
if (! $this->providerExists($provider)) {
return $this->createNotFoundResponse();
}
$service = $this->getServiceByProvider($provider);
$redirectUri = $service->getAuthorizationUri(['state' => $action]);
$response = new Response();
$response->setStatusCode(301);
$response->headers->set('Location', (string) $redirectUri);
return $response;
}
|
php
|
public function auth(Request $request, $action)
{
$provider = strtolower($request->attributes->get('provider'));
if (! $this->providerExists($provider)) {
return $this->createNotFoundResponse();
}
$service = $this->getServiceByProvider($provider);
$redirectUri = $service->getAuthorizationUri(['state' => $action]);
$response = new Response();
$response->setStatusCode(301);
$response->headers->set('Location', (string) $redirectUri);
return $response;
}
|
[
"public",
"function",
"auth",
"(",
"Request",
"$",
"request",
",",
"$",
"action",
")",
"{",
"$",
"provider",
"=",
"strtolower",
"(",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'provider'",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"providerExists",
"(",
"$",
"provider",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createNotFoundResponse",
"(",
")",
";",
"}",
"$",
"service",
"=",
"$",
"this",
"->",
"getServiceByProvider",
"(",
"$",
"provider",
")",
";",
"$",
"redirectUri",
"=",
"$",
"service",
"->",
"getAuthorizationUri",
"(",
"[",
"'state'",
"=>",
"$",
"action",
"]",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"response",
"->",
"setStatusCode",
"(",
"301",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Location'",
",",
"(",
"string",
")",
"$",
"redirectUri",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Authenticate via a separate OAuth provider
@param Request $request
@param int $action Constant representing either Login or Link account
@return Response
|
[
"Authenticate",
"via",
"a",
"separate",
"OAuth",
"provider"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/SocialLogin/SocialLoginController.php#L162-L178
|
239,601
|
synapsestudios/synapse-base
|
src/Synapse/SocialLogin/SocialLoginController.php
|
SocialLoginController.callback
|
public function callback(Request $request)
{
// Check to see if this provider exists and has a callback implemented
$provider = strtolower($request->attributes->get('provider'));
if (! $this->providerExists($provider)) {
return $this->createNotFoundResponse();
}
if (! method_exists($this, $provider)) {
throw new LogicException(sprintf(
'Callback for provider \'%s\' not implemented',
$provider
));
}
// Use provider service and access token from provider to create a LoginRequest for our app
$code = $request->query->get('code');
$providerService = $this->getServiceByProvider($provider);
$providerToken = $providerService->requestAccessToken($code);
$socialLoginRequest = $this->$provider($providerService, $providerToken);
// Handle login or link-account request and redirect to the redirect-url
$state = (int) $request->query->get('state');
try {
if ($state === self::ACTION_LOGIN_WITH_ACCOUNT) {
$token = $this->service->handleLoginRequest($socialLoginRequest);
} elseif ($state === self::ACTION_LINK_ACCOUNT) {
$token = $this->service->handleLinkRequest(
$socialLoginRequest,
$this->session->get('user')
);
} else {
return new Response(
'State parameter not set',
422
);
}
$redirect = $this->config['redirect-url'];
$redirect .= '?'.http_build_query($token);
} catch (NoLinkedAccountException $e) {
$redirect = $this->config['redirect-url'];
$redirect .= '?login_failure=1&error=no_linked_account';
} catch (LinkedAccountExistsException $e) {
$redirect = $this->config['redirect-url'];
$redirect .= '?login_failure=1&error=account_already_linked';
} catch (OutOfBoundsException $e) {
$redirect = $this->config['redirect-url'];
$redirect .= '?login_failure=1';
if ($e->getCode() === SocialLoginService::EXCEPTION_ACCOUNT_NOT_FOUND) {
$redirect .= '&error=account_not_found';
}
}
$response = new Response();
$response->setStatusCode(301);
$response->headers->set('Location', $redirect);
return $response;
}
|
php
|
public function callback(Request $request)
{
// Check to see if this provider exists and has a callback implemented
$provider = strtolower($request->attributes->get('provider'));
if (! $this->providerExists($provider)) {
return $this->createNotFoundResponse();
}
if (! method_exists($this, $provider)) {
throw new LogicException(sprintf(
'Callback for provider \'%s\' not implemented',
$provider
));
}
// Use provider service and access token from provider to create a LoginRequest for our app
$code = $request->query->get('code');
$providerService = $this->getServiceByProvider($provider);
$providerToken = $providerService->requestAccessToken($code);
$socialLoginRequest = $this->$provider($providerService, $providerToken);
// Handle login or link-account request and redirect to the redirect-url
$state = (int) $request->query->get('state');
try {
if ($state === self::ACTION_LOGIN_WITH_ACCOUNT) {
$token = $this->service->handleLoginRequest($socialLoginRequest);
} elseif ($state === self::ACTION_LINK_ACCOUNT) {
$token = $this->service->handleLinkRequest(
$socialLoginRequest,
$this->session->get('user')
);
} else {
return new Response(
'State parameter not set',
422
);
}
$redirect = $this->config['redirect-url'];
$redirect .= '?'.http_build_query($token);
} catch (NoLinkedAccountException $e) {
$redirect = $this->config['redirect-url'];
$redirect .= '?login_failure=1&error=no_linked_account';
} catch (LinkedAccountExistsException $e) {
$redirect = $this->config['redirect-url'];
$redirect .= '?login_failure=1&error=account_already_linked';
} catch (OutOfBoundsException $e) {
$redirect = $this->config['redirect-url'];
$redirect .= '?login_failure=1';
if ($e->getCode() === SocialLoginService::EXCEPTION_ACCOUNT_NOT_FOUND) {
$redirect .= '&error=account_not_found';
}
}
$response = new Response();
$response->setStatusCode(301);
$response->headers->set('Location', $redirect);
return $response;
}
|
[
"public",
"function",
"callback",
"(",
"Request",
"$",
"request",
")",
"{",
"// Check to see if this provider exists and has a callback implemented",
"$",
"provider",
"=",
"strtolower",
"(",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'provider'",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"providerExists",
"(",
"$",
"provider",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createNotFoundResponse",
"(",
")",
";",
"}",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"provider",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Callback for provider \\'%s\\' not implemented'",
",",
"$",
"provider",
")",
")",
";",
"}",
"// Use provider service and access token from provider to create a LoginRequest for our app",
"$",
"code",
"=",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'code'",
")",
";",
"$",
"providerService",
"=",
"$",
"this",
"->",
"getServiceByProvider",
"(",
"$",
"provider",
")",
";",
"$",
"providerToken",
"=",
"$",
"providerService",
"->",
"requestAccessToken",
"(",
"$",
"code",
")",
";",
"$",
"socialLoginRequest",
"=",
"$",
"this",
"->",
"$",
"provider",
"(",
"$",
"providerService",
",",
"$",
"providerToken",
")",
";",
"// Handle login or link-account request and redirect to the redirect-url",
"$",
"state",
"=",
"(",
"int",
")",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'state'",
")",
";",
"try",
"{",
"if",
"(",
"$",
"state",
"===",
"self",
"::",
"ACTION_LOGIN_WITH_ACCOUNT",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"service",
"->",
"handleLoginRequest",
"(",
"$",
"socialLoginRequest",
")",
";",
"}",
"elseif",
"(",
"$",
"state",
"===",
"self",
"::",
"ACTION_LINK_ACCOUNT",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"service",
"->",
"handleLinkRequest",
"(",
"$",
"socialLoginRequest",
",",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'user'",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Response",
"(",
"'State parameter not set'",
",",
"422",
")",
";",
"}",
"$",
"redirect",
"=",
"$",
"this",
"->",
"config",
"[",
"'redirect-url'",
"]",
";",
"$",
"redirect",
".=",
"'?'",
".",
"http_build_query",
"(",
"$",
"token",
")",
";",
"}",
"catch",
"(",
"NoLinkedAccountException",
"$",
"e",
")",
"{",
"$",
"redirect",
"=",
"$",
"this",
"->",
"config",
"[",
"'redirect-url'",
"]",
";",
"$",
"redirect",
".=",
"'?login_failure=1&error=no_linked_account'",
";",
"}",
"catch",
"(",
"LinkedAccountExistsException",
"$",
"e",
")",
"{",
"$",
"redirect",
"=",
"$",
"this",
"->",
"config",
"[",
"'redirect-url'",
"]",
";",
"$",
"redirect",
".=",
"'?login_failure=1&error=account_already_linked'",
";",
"}",
"catch",
"(",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"$",
"redirect",
"=",
"$",
"this",
"->",
"config",
"[",
"'redirect-url'",
"]",
";",
"$",
"redirect",
".=",
"'?login_failure=1'",
";",
"if",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
"===",
"SocialLoginService",
"::",
"EXCEPTION_ACCOUNT_NOT_FOUND",
")",
"{",
"$",
"redirect",
".=",
"'&error=account_not_found'",
";",
"}",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"response",
"->",
"setStatusCode",
"(",
"301",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Location'",
",",
"$",
"redirect",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Callback for OAuth authentication requests
@param Request $request
@return Response
|
[
"Callback",
"for",
"OAuth",
"authentication",
"requests"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/SocialLogin/SocialLoginController.php#L186-L248
|
239,602
|
synapsestudios/synapse-base
|
src/Synapse/SocialLogin/SocialLoginController.php
|
SocialLoginController.providerExists
|
protected function providerExists($provider)
{
return (
array_key_exists($provider, $this->serviceMap) ||
array_key_exists($provider, $this->config)
);
}
|
php
|
protected function providerExists($provider)
{
return (
array_key_exists($provider, $this->serviceMap) ||
array_key_exists($provider, $this->config)
);
}
|
[
"protected",
"function",
"providerExists",
"(",
"$",
"provider",
")",
"{",
"return",
"(",
"array_key_exists",
"(",
"$",
"provider",
",",
"$",
"this",
"->",
"serviceMap",
")",
"||",
"array_key_exists",
"(",
"$",
"provider",
",",
"$",
"this",
"->",
"config",
")",
")",
";",
"}"
] |
Determine whether the provider exists in the service map as well as the social login config
@param string $provider
@return bool
|
[
"Determine",
"whether",
"the",
"provider",
"exists",
"in",
"the",
"service",
"map",
"as",
"well",
"as",
"the",
"social",
"login",
"config"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/SocialLogin/SocialLoginController.php#L256-L262
|
239,603
|
synapsestudios/synapse-base
|
src/Synapse/SocialLogin/SocialLoginController.php
|
SocialLoginController.github
|
protected function github(Oauth2Service\GitHub $github, TokenInterface $token)
{
$emails = json_decode($github->request('user/emails'), true);
$user = json_decode($github->request('user'), true);
$loginRequest = new LoginRequest(
'github',
$user['id'],
$token->getAccessToken(),
$token->getEndOfLife() > 0 ? $token->getEndOfLife() : 0,
$token->getRefreshToken(),
$emails
);
return $loginRequest;
}
|
php
|
protected function github(Oauth2Service\GitHub $github, TokenInterface $token)
{
$emails = json_decode($github->request('user/emails'), true);
$user = json_decode($github->request('user'), true);
$loginRequest = new LoginRequest(
'github',
$user['id'],
$token->getAccessToken(),
$token->getEndOfLife() > 0 ? $token->getEndOfLife() : 0,
$token->getRefreshToken(),
$emails
);
return $loginRequest;
}
|
[
"protected",
"function",
"github",
"(",
"Oauth2Service",
"\\",
"GitHub",
"$",
"github",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"$",
"emails",
"=",
"json_decode",
"(",
"$",
"github",
"->",
"request",
"(",
"'user/emails'",
")",
",",
"true",
")",
";",
"$",
"user",
"=",
"json_decode",
"(",
"$",
"github",
"->",
"request",
"(",
"'user'",
")",
",",
"true",
")",
";",
"$",
"loginRequest",
"=",
"new",
"LoginRequest",
"(",
"'github'",
",",
"$",
"user",
"[",
"'id'",
"]",
",",
"$",
"token",
"->",
"getAccessToken",
"(",
")",
",",
"$",
"token",
"->",
"getEndOfLife",
"(",
")",
">",
"0",
"?",
"$",
"token",
"->",
"getEndOfLife",
"(",
")",
":",
"0",
",",
"$",
"token",
"->",
"getRefreshToken",
"(",
")",
",",
"$",
"emails",
")",
";",
"return",
"$",
"loginRequest",
";",
"}"
] |
Request access token from GitHub and return a LoginRequest object for logging into our app
@param Oauth2Service\GitHub $github
@param TokenInterface $token
@return LoginRequest
|
[
"Request",
"access",
"token",
"from",
"GitHub",
"and",
"return",
"a",
"LoginRequest",
"object",
"for",
"logging",
"into",
"our",
"app"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/SocialLogin/SocialLoginController.php#L271-L286
|
239,604
|
synapsestudios/synapse-base
|
src/Synapse/SocialLogin/SocialLoginController.php
|
SocialLoginController.google
|
protected function google(Oauth2Service\Google $google, TokenInterface $token)
{
$user = json_decode($google->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
$loginRequest = new LoginRequest(
'google',
$user['id'],
$token->getAccessToken(),
$token->getEndOfLife() > 0 ? $token->getEndOfLife() : 0,
$token->getRefreshToken(),
[$user['email']]
);
return $loginRequest;
}
|
php
|
protected function google(Oauth2Service\Google $google, TokenInterface $token)
{
$user = json_decode($google->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
$loginRequest = new LoginRequest(
'google',
$user['id'],
$token->getAccessToken(),
$token->getEndOfLife() > 0 ? $token->getEndOfLife() : 0,
$token->getRefreshToken(),
[$user['email']]
);
return $loginRequest;
}
|
[
"protected",
"function",
"google",
"(",
"Oauth2Service",
"\\",
"Google",
"$",
"google",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"$",
"user",
"=",
"json_decode",
"(",
"$",
"google",
"->",
"request",
"(",
"'https://www.googleapis.com/oauth2/v1/userinfo'",
")",
",",
"true",
")",
";",
"$",
"loginRequest",
"=",
"new",
"LoginRequest",
"(",
"'google'",
",",
"$",
"user",
"[",
"'id'",
"]",
",",
"$",
"token",
"->",
"getAccessToken",
"(",
")",
",",
"$",
"token",
"->",
"getEndOfLife",
"(",
")",
">",
"0",
"?",
"$",
"token",
"->",
"getEndOfLife",
"(",
")",
":",
"0",
",",
"$",
"token",
"->",
"getRefreshToken",
"(",
")",
",",
"[",
"$",
"user",
"[",
"'email'",
"]",
"]",
")",
";",
"return",
"$",
"loginRequest",
";",
"}"
] |
Request access token from Google and return a LoginRequest object for logging into our app
@param Oauth2Service\Google $google
@param TokenInterface $token
@return LoginRequest
|
[
"Request",
"access",
"token",
"from",
"Google",
"and",
"return",
"a",
"LoginRequest",
"object",
"for",
"logging",
"into",
"our",
"app"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/SocialLogin/SocialLoginController.php#L295-L309
|
239,605
|
synapsestudios/synapse-base
|
src/Synapse/SocialLogin/SocialLoginController.php
|
SocialLoginController.facebook
|
protected function facebook(Oauth2Service\Facebook $facebook, TokenInterface $token)
{
$user = json_decode($facebook->request('/me'), true);
$loginRequest = new LoginRequest(
'facebook',
$user['id'],
$token->getAccessToken(),
$token->getEndOfLife() > 0 ? $token->getEndOfLife() : 0,
$token->getRefreshToken(),
[$user['email']]
);
return $loginRequest;
}
|
php
|
protected function facebook(Oauth2Service\Facebook $facebook, TokenInterface $token)
{
$user = json_decode($facebook->request('/me'), true);
$loginRequest = new LoginRequest(
'facebook',
$user['id'],
$token->getAccessToken(),
$token->getEndOfLife() > 0 ? $token->getEndOfLife() : 0,
$token->getRefreshToken(),
[$user['email']]
);
return $loginRequest;
}
|
[
"protected",
"function",
"facebook",
"(",
"Oauth2Service",
"\\",
"Facebook",
"$",
"facebook",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"$",
"user",
"=",
"json_decode",
"(",
"$",
"facebook",
"->",
"request",
"(",
"'/me'",
")",
",",
"true",
")",
";",
"$",
"loginRequest",
"=",
"new",
"LoginRequest",
"(",
"'facebook'",
",",
"$",
"user",
"[",
"'id'",
"]",
",",
"$",
"token",
"->",
"getAccessToken",
"(",
")",
",",
"$",
"token",
"->",
"getEndOfLife",
"(",
")",
">",
"0",
"?",
"$",
"token",
"->",
"getEndOfLife",
"(",
")",
":",
"0",
",",
"$",
"token",
"->",
"getRefreshToken",
"(",
")",
",",
"[",
"$",
"user",
"[",
"'email'",
"]",
"]",
")",
";",
"return",
"$",
"loginRequest",
";",
"}"
] |
Request access token from Facebook and return a LoginRequest object for logging into our app
@param Oauth2Service\Facebook $facebook
@param TokenInterface $token
@return LoginRequest
|
[
"Request",
"access",
"token",
"from",
"Facebook",
"and",
"return",
"a",
"LoginRequest",
"object",
"for",
"logging",
"into",
"our",
"app"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/SocialLogin/SocialLoginController.php#L318-L332
|
239,606
|
synapsestudios/synapse-base
|
src/Synapse/SocialLogin/SocialLoginController.php
|
SocialLoginController.getServiceByProvider
|
public function getServiceByProvider($provider)
{
$redirect = $this->url($this->config[$provider]['callback_route'], array(
'provider' => $provider,
));
$serviceName = $this->serviceMap[$provider];
$storage = new SessionStorage(false);
$credentials = new ConsumerCredentials(
$this->config[$provider]['key'],
$this->config[$provider]['secret'],
$redirect
);
$service = $this->serviceFactory->createService(
$serviceName,
$credentials,
$storage,
$this->config[$provider]['scope']
);
return $service;
}
|
php
|
public function getServiceByProvider($provider)
{
$redirect = $this->url($this->config[$provider]['callback_route'], array(
'provider' => $provider,
));
$serviceName = $this->serviceMap[$provider];
$storage = new SessionStorage(false);
$credentials = new ConsumerCredentials(
$this->config[$provider]['key'],
$this->config[$provider]['secret'],
$redirect
);
$service = $this->serviceFactory->createService(
$serviceName,
$credentials,
$storage,
$this->config[$provider]['scope']
);
return $service;
}
|
[
"public",
"function",
"getServiceByProvider",
"(",
"$",
"provider",
")",
"{",
"$",
"redirect",
"=",
"$",
"this",
"->",
"url",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"provider",
"]",
"[",
"'callback_route'",
"]",
",",
"array",
"(",
"'provider'",
"=>",
"$",
"provider",
",",
")",
")",
";",
"$",
"serviceName",
"=",
"$",
"this",
"->",
"serviceMap",
"[",
"$",
"provider",
"]",
";",
"$",
"storage",
"=",
"new",
"SessionStorage",
"(",
"false",
")",
";",
"$",
"credentials",
"=",
"new",
"ConsumerCredentials",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"provider",
"]",
"[",
"'key'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"$",
"provider",
"]",
"[",
"'secret'",
"]",
",",
"$",
"redirect",
")",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"serviceFactory",
"->",
"createService",
"(",
"$",
"serviceName",
",",
"$",
"credentials",
",",
"$",
"storage",
",",
"$",
"this",
"->",
"config",
"[",
"$",
"provider",
"]",
"[",
"'scope'",
"]",
")",
";",
"return",
"$",
"service",
";",
"}"
] |
Get a provider service given a provider name
@param string $provider
@return OAuth\Common\Service\ServiceInterface
|
[
"Get",
"a",
"provider",
"service",
"given",
"a",
"provider",
"name"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/SocialLogin/SocialLoginController.php#L340-L362
|
239,607
|
gibboncms/gibbon
|
src/Support/Yaml.php
|
Yaml.dumpToSimpleYaml
|
protected function dumpToSimpleYaml($array)
{
$parts = [];
foreach ($array as $key => $value) {
$parts[] = "$key: $value";
}
$yaml = implode("\n", $parts);
return $yaml;
}
|
php
|
protected function dumpToSimpleYaml($array)
{
$parts = [];
foreach ($array as $key => $value) {
$parts[] = "$key: $value";
}
$yaml = implode("\n", $parts);
return $yaml;
}
|
[
"protected",
"function",
"dumpToSimpleYaml",
"(",
"$",
"array",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"\"$key: $value\"",
";",
"}",
"$",
"yaml",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"parts",
")",
";",
"return",
"$",
"yaml",
";",
"}"
] |
Transform an associative array to yaml.
Not using symfony's yaml dumper for full control over the format.
@param array $array
@return string
|
[
"Transform",
"an",
"associative",
"array",
"to",
"yaml",
".",
"Not",
"using",
"symfony",
"s",
"yaml",
"dumper",
"for",
"full",
"control",
"over",
"the",
"format",
"."
] |
2905e90b2902149b3358b385264e98b97cf4fc00
|
https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Support/Yaml.php#L21-L32
|
239,608
|
gibboncms/gibbon
|
src/Support/Yaml.php
|
Yaml.parseYaml
|
public static function parseYaml($yaml)
{
if (self::$yamlParser == null) {
self::$yamlParser = new YamlParser;
}
return self::$yamlParser->parse($yaml);
}
|
php
|
public static function parseYaml($yaml)
{
if (self::$yamlParser == null) {
self::$yamlParser = new YamlParser;
}
return self::$yamlParser->parse($yaml);
}
|
[
"public",
"static",
"function",
"parseYaml",
"(",
"$",
"yaml",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"yamlParser",
"==",
"null",
")",
"{",
"self",
"::",
"$",
"yamlParser",
"=",
"new",
"YamlParser",
";",
"}",
"return",
"self",
"::",
"$",
"yamlParser",
"->",
"parse",
"(",
"$",
"yaml",
")",
";",
"}"
] |
Parse yaml to an array
@param string $yaml
@return array
|
[
"Parse",
"yaml",
"to",
"an",
"array"
] |
2905e90b2902149b3358b385264e98b97cf4fc00
|
https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Support/Yaml.php#L40-L47
|
239,609
|
loopsframework/base
|
src/Loops/Form/Element/File.php
|
File.deleteAction
|
public function deleteAction($parameter) {
try {
if(!$this->request->isPost()) {
return $this->jsonResult(400, 'Please access via POST method.', 'error_access_post');
}
if(!$this->getFile()) {
return $this->jsonResult(400, 'No file was uploaded.', 'error_no_file');
}
$this->initFromSession();
$this->file = NULL;
$this->filename = NULL;
$this->filesize = NULL;
$this->saveToSession();
if(!$this->deleteFile()) {
return $this->jsonResult(400, 'Could not delete file.', 'error_delete_failed');
}
return $this->jsonResult();
}
catch(Exception $e) {
return $this->jsonResult(500, $e->getMessage());
}
}
|
php
|
public function deleteAction($parameter) {
try {
if(!$this->request->isPost()) {
return $this->jsonResult(400, 'Please access via POST method.', 'error_access_post');
}
if(!$this->getFile()) {
return $this->jsonResult(400, 'No file was uploaded.', 'error_no_file');
}
$this->initFromSession();
$this->file = NULL;
$this->filename = NULL;
$this->filesize = NULL;
$this->saveToSession();
if(!$this->deleteFile()) {
return $this->jsonResult(400, 'Could not delete file.', 'error_delete_failed');
}
return $this->jsonResult();
}
catch(Exception $e) {
return $this->jsonResult(500, $e->getMessage());
}
}
|
[
"public",
"function",
"deleteAction",
"(",
"$",
"parameter",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"400",
",",
"'Please access via POST method.'",
",",
"'error_access_post'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getFile",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"400",
",",
"'No file was uploaded.'",
",",
"'error_no_file'",
")",
";",
"}",
"$",
"this",
"->",
"initFromSession",
"(",
")",
";",
"$",
"this",
"->",
"file",
"=",
"NULL",
";",
"$",
"this",
"->",
"filename",
"=",
"NULL",
";",
"$",
"this",
"->",
"filesize",
"=",
"NULL",
";",
"$",
"this",
"->",
"saveToSession",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"deleteFile",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"400",
",",
"'Could not delete file.'",
",",
"'error_delete_failed'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"500",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Deletes a previously uploaded file. Must be accessed with the POST method.
An json response will be generated and send back to the client.
{ 'success': TRUE|FALSE, [ 'error': errorstring ] }
|
[
"Deletes",
"a",
"previously",
"uploaded",
"file",
".",
"Must",
"be",
"accessed",
"with",
"the",
"POST",
"method",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Form/Element/File.php#L118-L147
|
239,610
|
loopsframework/base
|
src/Loops/Form/Element/File.php
|
File.downloadAction
|
public function downloadAction($parameter) {
if(!$this->getFile()) {
return 404;
}
if(count($parameter) > 1) {
return 404;
}
if($parameter && $parameter[0] != $this->filename) {
return 404;
}
return Misc::servefile($this->file, $parameter ? FALSE : $this->filename);
}
|
php
|
public function downloadAction($parameter) {
if(!$this->getFile()) {
return 404;
}
if(count($parameter) > 1) {
return 404;
}
if($parameter && $parameter[0] != $this->filename) {
return 404;
}
return Misc::servefile($this->file, $parameter ? FALSE : $this->filename);
}
|
[
"public",
"function",
"downloadAction",
"(",
"$",
"parameter",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getFile",
"(",
")",
")",
"{",
"return",
"404",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"parameter",
")",
">",
"1",
")",
"{",
"return",
"404",
";",
"}",
"if",
"(",
"$",
"parameter",
"&&",
"$",
"parameter",
"[",
"0",
"]",
"!=",
"$",
"this",
"->",
"filename",
")",
"{",
"return",
"404",
";",
"}",
"return",
"Misc",
"::",
"servefile",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"parameter",
"?",
"FALSE",
":",
"$",
"this",
"->",
"filename",
")",
";",
"}"
] |
Sends a previously uploaded file if it exists.
The first parameter can be set to the uploaded filename to force correct behaviour from the
browser regarding the filename. Otherwise the filename will be defined in the header and
becomes a little bit more unstable since cross-browser checks have to be made.
|
[
"Sends",
"a",
"previously",
"uploaded",
"file",
"if",
"it",
"exists",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Form/Element/File.php#L156-L170
|
239,611
|
loopsframework/base
|
src/Loops/Form/Element/File.php
|
File.uploadAction
|
public function uploadAction($parameter) {
try {
if(!$files = $this->request->files()) {
return $this->jsonResult(400, 'Failed to upload file.', 'error_upload_failed');
}
foreach($files as $file) {
if($error = $file->getError()) {
return $this->jsonResult(400, "Failed to upload file '%s'.", "error_upload_failed_detail", [$file->getError()]);
}
}
$this->initFromSession();
$this->deleteFile();
$dir = $this->getUploadDir();
if(!Misc::recursiveMkdir($dir, 0700)) {
return $this->jsonResult(500, "Failed to create upload directory at '%s'.", "error_createdir_failed", [$dir]);
}
foreach($files as $file) {
$target = "$dir/".$file->getName();
if(!$file->moveTo($target)) {
return $this->jsonResult(500, 'Failed to move file.', 'error_move_failed');
}
}
$this->file = $target;
$this->filename = $file->getName();
$this->filesize = $file->getSize();
$this->saveToSession();
$this->cleanFiles();
return $this->jsonResult();
}
catch(Exception $e) {
return $this->jsonResult(500, $e->getMessage());
}
}
|
php
|
public function uploadAction($parameter) {
try {
if(!$files = $this->request->files()) {
return $this->jsonResult(400, 'Failed to upload file.', 'error_upload_failed');
}
foreach($files as $file) {
if($error = $file->getError()) {
return $this->jsonResult(400, "Failed to upload file '%s'.", "error_upload_failed_detail", [$file->getError()]);
}
}
$this->initFromSession();
$this->deleteFile();
$dir = $this->getUploadDir();
if(!Misc::recursiveMkdir($dir, 0700)) {
return $this->jsonResult(500, "Failed to create upload directory at '%s'.", "error_createdir_failed", [$dir]);
}
foreach($files as $file) {
$target = "$dir/".$file->getName();
if(!$file->moveTo($target)) {
return $this->jsonResult(500, 'Failed to move file.', 'error_move_failed');
}
}
$this->file = $target;
$this->filename = $file->getName();
$this->filesize = $file->getSize();
$this->saveToSession();
$this->cleanFiles();
return $this->jsonResult();
}
catch(Exception $e) {
return $this->jsonResult(500, $e->getMessage());
}
}
|
[
"public",
"function",
"uploadAction",
"(",
"$",
"parameter",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"files",
"=",
"$",
"this",
"->",
"request",
"->",
"files",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"400",
",",
"'Failed to upload file.'",
",",
"'error_upload_failed'",
")",
";",
"}",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"error",
"=",
"$",
"file",
"->",
"getError",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"400",
",",
"\"Failed to upload file '%s'.\"",
",",
"\"error_upload_failed_detail\"",
",",
"[",
"$",
"file",
"->",
"getError",
"(",
")",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"initFromSession",
"(",
")",
";",
"$",
"this",
"->",
"deleteFile",
"(",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"getUploadDir",
"(",
")",
";",
"if",
"(",
"!",
"Misc",
"::",
"recursiveMkdir",
"(",
"$",
"dir",
",",
"0700",
")",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"500",
",",
"\"Failed to create upload directory at '%s'.\"",
",",
"\"error_createdir_failed\"",
",",
"[",
"$",
"dir",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"target",
"=",
"\"$dir/\"",
".",
"$",
"file",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"$",
"file",
"->",
"moveTo",
"(",
"$",
"target",
")",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"500",
",",
"'Failed to move file.'",
",",
"'error_move_failed'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"file",
"=",
"$",
"target",
";",
"$",
"this",
"->",
"filename",
"=",
"$",
"file",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"filesize",
"=",
"$",
"file",
"->",
"getSize",
"(",
")",
";",
"$",
"this",
"->",
"saveToSession",
"(",
")",
";",
"$",
"this",
"->",
"cleanFiles",
"(",
")",
";",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"jsonResult",
"(",
"500",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Stores a received file. The request must be encoded as formdata.
The first file in the formdata will be used, every other file is ignored.
An json response will be generated and send back to the client.
{ 'success': TRUE|FALSE, [ 'error': errorstring ] }
|
[
"Stores",
"a",
"received",
"file",
".",
"The",
"request",
"must",
"be",
"encoded",
"as",
"formdata",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Form/Element/File.php#L180-L225
|
239,612
|
bookability/bookability-php
|
src/Bookability/Availability.php
|
Bookability_Availability.find
|
public function find($token, $_params = array())
{
return $this->transform($this->master->get('availability/' . $token, $_params));
}
|
php
|
public function find($token, $_params = array())
{
return $this->transform($this->master->get('availability/' . $token, $_params));
}
|
[
"public",
"function",
"find",
"(",
"$",
"token",
",",
"$",
"_params",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"transform",
"(",
"$",
"this",
"->",
"master",
"->",
"get",
"(",
"'availability/'",
".",
"$",
"token",
",",
"$",
"_params",
")",
")",
";",
"}"
] |
Retrieve a list of availability for an event date range
@return array
|
[
"Retrieve",
"a",
"list",
"of",
"availability",
"for",
"an",
"event",
"date",
"range"
] |
be455327f2a965877d2b2a59edfe9ed71aed58aa
|
https://github.com/bookability/bookability-php/blob/be455327f2a965877d2b2a59edfe9ed71aed58aa/src/Bookability/Availability.php#L15-L18
|
239,613
|
bookability/bookability-php
|
src/Bookability/Availability.php
|
Bookability_Availability.month
|
public function month($token, $_params = array())
{
return $this->transform($this->master->get('availability/' . $token . '/month', $_params), true);
}
|
php
|
public function month($token, $_params = array())
{
return $this->transform($this->master->get('availability/' . $token . '/month', $_params), true);
}
|
[
"public",
"function",
"month",
"(",
"$",
"token",
",",
"$",
"_params",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"transform",
"(",
"$",
"this",
"->",
"master",
"->",
"get",
"(",
"'availability/'",
".",
"$",
"token",
".",
"'/month'",
",",
"$",
"_params",
")",
",",
"true",
")",
";",
"}"
] |
Retrieve a list of availability for an event month
@return array
|
[
"Retrieve",
"a",
"list",
"of",
"availability",
"for",
"an",
"event",
"month"
] |
be455327f2a965877d2b2a59edfe9ed71aed58aa
|
https://github.com/bookability/bookability-php/blob/be455327f2a965877d2b2a59edfe9ed71aed58aa/src/Bookability/Availability.php#L25-L28
|
239,614
|
bookability/bookability-php
|
src/Bookability/Availability.php
|
Bookability_Availability.date
|
public function date($token, $_params = array())
{
return $this->transform($this->master->get('availability/' . $token . '/date', $_params), true);
}
|
php
|
public function date($token, $_params = array())
{
return $this->transform($this->master->get('availability/' . $token . '/date', $_params), true);
}
|
[
"public",
"function",
"date",
"(",
"$",
"token",
",",
"$",
"_params",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"transform",
"(",
"$",
"this",
"->",
"master",
"->",
"get",
"(",
"'availability/'",
".",
"$",
"token",
".",
"'/date'",
",",
"$",
"_params",
")",
",",
"true",
")",
";",
"}"
] |
Retrieve a list of availability for a single event date
@return array
|
[
"Retrieve",
"a",
"list",
"of",
"availability",
"for",
"a",
"single",
"event",
"date"
] |
be455327f2a965877d2b2a59edfe9ed71aed58aa
|
https://github.com/bookability/bookability-php/blob/be455327f2a965877d2b2a59edfe9ed71aed58aa/src/Bookability/Availability.php#L35-L38
|
239,615
|
subugoe/typo3-pazpar2
|
Classes/Domain/Model/Query.php
|
Query.fullQueryString
|
protected function fullQueryString()
{
$queryParts = [];
// Main search can be default search or full text search.
if ($this->queryString) {
if (!$this->querySwitchFulltext) {
$queryParts[] = $this->queryString;
} else {
$queryParts[] = $this->createSearchString('fulltext', $this->queryString);
}
}
// Title search can be proper title or journal title depending on the switch.
if ($this->queryStringTitle) {
if (!$this->querySwitchJournalOnly) {
$queryParts[] = $this->createSearchString('title', $this->queryStringTitle);
} else {
$queryParts[] = $this->createSearchString('journal', $this->queryStringTitle);
}
}
// Person search is a phrase search.
if ($this->queryStringPerson) {
$myQueryStringPerson = preg_replace('/^[\s"]*/', '', $this->queryStringPerson);
$myQueryStringPerson = preg_replace('/[\s"]*$/', '', $myQueryStringPerson);
$queryParts[] = $this->createSearchString('person', '"' . $myQueryStringPerson . '"');
}
if ($this->queryStringKeyword) {
$queryParts[] = $this->createSearchString('subject', $this->queryStringKeyword);
}
if ($this->queryStringDate) {
$queryParts[] = $this->createSearchString('date', $this->queryStringDate);
}
$query = implode(' and ', $queryParts);
$query = str_replace('*', '?', $query);
return $query;
}
|
php
|
protected function fullQueryString()
{
$queryParts = [];
// Main search can be default search or full text search.
if ($this->queryString) {
if (!$this->querySwitchFulltext) {
$queryParts[] = $this->queryString;
} else {
$queryParts[] = $this->createSearchString('fulltext', $this->queryString);
}
}
// Title search can be proper title or journal title depending on the switch.
if ($this->queryStringTitle) {
if (!$this->querySwitchJournalOnly) {
$queryParts[] = $this->createSearchString('title', $this->queryStringTitle);
} else {
$queryParts[] = $this->createSearchString('journal', $this->queryStringTitle);
}
}
// Person search is a phrase search.
if ($this->queryStringPerson) {
$myQueryStringPerson = preg_replace('/^[\s"]*/', '', $this->queryStringPerson);
$myQueryStringPerson = preg_replace('/[\s"]*$/', '', $myQueryStringPerson);
$queryParts[] = $this->createSearchString('person', '"' . $myQueryStringPerson . '"');
}
if ($this->queryStringKeyword) {
$queryParts[] = $this->createSearchString('subject', $this->queryStringKeyword);
}
if ($this->queryStringDate) {
$queryParts[] = $this->createSearchString('date', $this->queryStringDate);
}
$query = implode(' and ', $queryParts);
$query = str_replace('*', '?', $query);
return $query;
}
|
[
"protected",
"function",
"fullQueryString",
"(",
")",
"{",
"$",
"queryParts",
"=",
"[",
"]",
";",
"// Main search can be default search or full text search.",
"if",
"(",
"$",
"this",
"->",
"queryString",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"querySwitchFulltext",
")",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"$",
"this",
"->",
"queryString",
";",
"}",
"else",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"$",
"this",
"->",
"createSearchString",
"(",
"'fulltext'",
",",
"$",
"this",
"->",
"queryString",
")",
";",
"}",
"}",
"// Title search can be proper title or journal title depending on the switch.",
"if",
"(",
"$",
"this",
"->",
"queryStringTitle",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"querySwitchJournalOnly",
")",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"$",
"this",
"->",
"createSearchString",
"(",
"'title'",
",",
"$",
"this",
"->",
"queryStringTitle",
")",
";",
"}",
"else",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"$",
"this",
"->",
"createSearchString",
"(",
"'journal'",
",",
"$",
"this",
"->",
"queryStringTitle",
")",
";",
"}",
"}",
"// Person search is a phrase search.",
"if",
"(",
"$",
"this",
"->",
"queryStringPerson",
")",
"{",
"$",
"myQueryStringPerson",
"=",
"preg_replace",
"(",
"'/^[\\s\"]*/'",
",",
"''",
",",
"$",
"this",
"->",
"queryStringPerson",
")",
";",
"$",
"myQueryStringPerson",
"=",
"preg_replace",
"(",
"'/[\\s\"]*$/'",
",",
"''",
",",
"$",
"myQueryStringPerson",
")",
";",
"$",
"queryParts",
"[",
"]",
"=",
"$",
"this",
"->",
"createSearchString",
"(",
"'person'",
",",
"'\"'",
".",
"$",
"myQueryStringPerson",
".",
"'\"'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"queryStringKeyword",
")",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"$",
"this",
"->",
"createSearchString",
"(",
"'subject'",
",",
"$",
"this",
"->",
"queryStringKeyword",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"queryStringDate",
")",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"$",
"this",
"->",
"createSearchString",
"(",
"'date'",
",",
"$",
"this",
"->",
"queryStringDate",
")",
";",
"}",
"$",
"query",
"=",
"implode",
"(",
"' and '",
",",
"$",
"queryParts",
")",
";",
"$",
"query",
"=",
"str_replace",
"(",
"'*'",
",",
"'?'",
",",
"$",
"query",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Returns the full query string to send to pazpar2.
@return string
|
[
"Returns",
"the",
"full",
"query",
"string",
"to",
"send",
"to",
"pazpar2",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/Query.php#L304-L340
|
239,616
|
subugoe/typo3-pazpar2
|
Classes/Domain/Model/Query.php
|
Query.getPazpar2BaseURL
|
public function getPazpar2BaseURL()
{
$URL = 'http://' . GeneralUtility::getIndpEnv('HTTP_HOST') . $this->getPazpar2Path();
if ($this->pazpar2BaseURL) {
$URL = $this->pazpar2BaseURL;
}
return $URL;
}
|
php
|
public function getPazpar2BaseURL()
{
$URL = 'http://' . GeneralUtility::getIndpEnv('HTTP_HOST') . $this->getPazpar2Path();
if ($this->pazpar2BaseURL) {
$URL = $this->pazpar2BaseURL;
}
return $URL;
}
|
[
"public",
"function",
"getPazpar2BaseURL",
"(",
")",
"{",
"$",
"URL",
"=",
"'http://'",
".",
"GeneralUtility",
"::",
"getIndpEnv",
"(",
"'HTTP_HOST'",
")",
".",
"$",
"this",
"->",
"getPazpar2Path",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pazpar2BaseURL",
")",
"{",
"$",
"URL",
"=",
"$",
"this",
"->",
"pazpar2BaseURL",
";",
"}",
"return",
"$",
"URL",
";",
"}"
] |
Return URL of pazpar2 service.
If it is not set, return default URL on localhost.
@return string
|
[
"Return",
"URL",
"of",
"pazpar2",
"service",
".",
"If",
"it",
"is",
"not",
"set",
"return",
"default",
"URL",
"on",
"localhost",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/Query.php#L426-L433
|
239,617
|
subugoe/typo3-pazpar2
|
Classes/Domain/Model/Query.php
|
Query.queryIsDone
|
protected function queryIsDone()
{
$result = false;
$statReplyString = $this->fetchURL($this->pazpar2StatURL());
$statReply = GeneralUtility::xml2array($statReplyString);
if ($statReply) {
// The progress variable is a string representing a number between
// 0.00 and 1.00.
// Casting it to int gives 0 as long as the value is < 1.
$progress = (int)$statReply['progress'];
$result = ($progress === 1);
if ($result === true) {
// We are done: note that and get the record count.
$this->setDidRun(true);
$this->setTotalResultCount($statReply['hits']);
}
} else {
GeneralUtility::devLog('could not parse pazpar2 stat reply', 'pazpar2', 3);
}
return $result;
}
|
php
|
protected function queryIsDone()
{
$result = false;
$statReplyString = $this->fetchURL($this->pazpar2StatURL());
$statReply = GeneralUtility::xml2array($statReplyString);
if ($statReply) {
// The progress variable is a string representing a number between
// 0.00 and 1.00.
// Casting it to int gives 0 as long as the value is < 1.
$progress = (int)$statReply['progress'];
$result = ($progress === 1);
if ($result === true) {
// We are done: note that and get the record count.
$this->setDidRun(true);
$this->setTotalResultCount($statReply['hits']);
}
} else {
GeneralUtility::devLog('could not parse pazpar2 stat reply', 'pazpar2', 3);
}
return $result;
}
|
[
"protected",
"function",
"queryIsDone",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"statReplyString",
"=",
"$",
"this",
"->",
"fetchURL",
"(",
"$",
"this",
"->",
"pazpar2StatURL",
"(",
")",
")",
";",
"$",
"statReply",
"=",
"GeneralUtility",
"::",
"xml2array",
"(",
"$",
"statReplyString",
")",
";",
"if",
"(",
"$",
"statReply",
")",
"{",
"// The progress variable is a string representing a number between",
"// 0.00 and 1.00.",
"// Casting it to int gives 0 as long as the value is < 1.",
"$",
"progress",
"=",
"(",
"int",
")",
"$",
"statReply",
"[",
"'progress'",
"]",
";",
"$",
"result",
"=",
"(",
"$",
"progress",
"===",
"1",
")",
";",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"// We are done: note that and get the record count.",
"$",
"this",
"->",
"setDidRun",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setTotalResultCount",
"(",
"$",
"statReply",
"[",
"'hits'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"GeneralUtility",
"::",
"devLog",
"(",
"'could not parse pazpar2 stat reply'",
",",
"'pazpar2'",
",",
"3",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Checks whether the query is done.
Requires a session to be established.
@param int $count return by reference the current number of results
@return bool True when query has finished, False otherwise
|
[
"Checks",
"whether",
"the",
"query",
"is",
"done",
".",
"Requires",
"a",
"session",
"to",
"be",
"established",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/Query.php#L470-L493
|
239,618
|
subugoe/typo3-pazpar2
|
Classes/Domain/Model/Query.php
|
Query.fetchResults
|
protected function fetchResults()
{
$maxResults = 1000; // limit results
if (count($this->conf['exportFormats']) > 0) {
// limit results even more if we are creating export data
$maxResults = $maxResults / (count($this->conf['exportFormats']) + 1);
}
$recordsToFetch = 350;
$firstRecord = 0;
// get records in chunks of $recordsToFetch to avoid running out of memory
// in t3lib_div::xml2tree. We seem to typically need ~100KB per record (?).
while ($firstRecord < $maxResults) {
$recordsToFetchNow = min([$recordsToFetch, $maxResults - $firstRecord]);
$showReplyString = $this->fetchURL($this->pazpar2ShowURL($firstRecord, $recordsToFetchNow));
$firstRecord += $recordsToFetchNow;
// need xml2tree here as xml2array fails when dealing with arrays of tags with the same name
$showReplyTree = GeneralUtility::xml2tree($showReplyString);
$showReply = $showReplyTree['show'][0]['ch'];
if ($showReply) {
$status = $showReply['status'][0]['values'][0];
if ($status == 'OK') {
$this->queryIsRunning = false;
$hits = $showReply['hit'];
if ($hits) {
foreach ($hits as $hit) {
$myHit = $hit['ch'];
$key = $myHit['recid'][0]['values'][0];
// Make sure the 'medium' field exists by setting it to 'other' if necessary.
if (!array_key_exists('md-medium', $myHit)) {
$myHit['md-medium'] = [0 => ['values' => [0 => 'other']]];
}
// If there is no title information but series information, use the
// first series field for the title.
if (!(array_key_exists('md-title', $myHit) || array_key_exists('md-multivolume-title', $myHit))
&& array_key_exists('md-series-title', $myHit)
) {
$myHit['md-multivolume-title'] = [$myHit['md-series-title'][0]];
}
// Sort the location array to have the newest item first
usort($myHit['location'], [$this, 'yearSort']);
$this->results[$key] = $myHit;
}
}
} else {
GeneralUtility::devLog('pazpar2 show reply status is not "OK" but "' . $status . '"', 'pazpar2', 3);
}
} else {
GeneralUtility::devLog('could not parse pazpar2 show reply', 'pazpar2', 3);
}
}
}
|
php
|
protected function fetchResults()
{
$maxResults = 1000; // limit results
if (count($this->conf['exportFormats']) > 0) {
// limit results even more if we are creating export data
$maxResults = $maxResults / (count($this->conf['exportFormats']) + 1);
}
$recordsToFetch = 350;
$firstRecord = 0;
// get records in chunks of $recordsToFetch to avoid running out of memory
// in t3lib_div::xml2tree. We seem to typically need ~100KB per record (?).
while ($firstRecord < $maxResults) {
$recordsToFetchNow = min([$recordsToFetch, $maxResults - $firstRecord]);
$showReplyString = $this->fetchURL($this->pazpar2ShowURL($firstRecord, $recordsToFetchNow));
$firstRecord += $recordsToFetchNow;
// need xml2tree here as xml2array fails when dealing with arrays of tags with the same name
$showReplyTree = GeneralUtility::xml2tree($showReplyString);
$showReply = $showReplyTree['show'][0]['ch'];
if ($showReply) {
$status = $showReply['status'][0]['values'][0];
if ($status == 'OK') {
$this->queryIsRunning = false;
$hits = $showReply['hit'];
if ($hits) {
foreach ($hits as $hit) {
$myHit = $hit['ch'];
$key = $myHit['recid'][0]['values'][0];
// Make sure the 'medium' field exists by setting it to 'other' if necessary.
if (!array_key_exists('md-medium', $myHit)) {
$myHit['md-medium'] = [0 => ['values' => [0 => 'other']]];
}
// If there is no title information but series information, use the
// first series field for the title.
if (!(array_key_exists('md-title', $myHit) || array_key_exists('md-multivolume-title', $myHit))
&& array_key_exists('md-series-title', $myHit)
) {
$myHit['md-multivolume-title'] = [$myHit['md-series-title'][0]];
}
// Sort the location array to have the newest item first
usort($myHit['location'], [$this, 'yearSort']);
$this->results[$key] = $myHit;
}
}
} else {
GeneralUtility::devLog('pazpar2 show reply status is not "OK" but "' . $status . '"', 'pazpar2', 3);
}
} else {
GeneralUtility::devLog('could not parse pazpar2 show reply', 'pazpar2', 3);
}
}
}
|
[
"protected",
"function",
"fetchResults",
"(",
")",
"{",
"$",
"maxResults",
"=",
"1000",
";",
"// limit results",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"conf",
"[",
"'exportFormats'",
"]",
")",
">",
"0",
")",
"{",
"// limit results even more if we are creating export data",
"$",
"maxResults",
"=",
"$",
"maxResults",
"/",
"(",
"count",
"(",
"$",
"this",
"->",
"conf",
"[",
"'exportFormats'",
"]",
")",
"+",
"1",
")",
";",
"}",
"$",
"recordsToFetch",
"=",
"350",
";",
"$",
"firstRecord",
"=",
"0",
";",
"// get records in chunks of $recordsToFetch to avoid running out of memory",
"// in t3lib_div::xml2tree. We seem to typically need ~100KB per record (?).",
"while",
"(",
"$",
"firstRecord",
"<",
"$",
"maxResults",
")",
"{",
"$",
"recordsToFetchNow",
"=",
"min",
"(",
"[",
"$",
"recordsToFetch",
",",
"$",
"maxResults",
"-",
"$",
"firstRecord",
"]",
")",
";",
"$",
"showReplyString",
"=",
"$",
"this",
"->",
"fetchURL",
"(",
"$",
"this",
"->",
"pazpar2ShowURL",
"(",
"$",
"firstRecord",
",",
"$",
"recordsToFetchNow",
")",
")",
";",
"$",
"firstRecord",
"+=",
"$",
"recordsToFetchNow",
";",
"// need xml2tree here as xml2array fails when dealing with arrays of tags with the same name",
"$",
"showReplyTree",
"=",
"GeneralUtility",
"::",
"xml2tree",
"(",
"$",
"showReplyString",
")",
";",
"$",
"showReply",
"=",
"$",
"showReplyTree",
"[",
"'show'",
"]",
"[",
"0",
"]",
"[",
"'ch'",
"]",
";",
"if",
"(",
"$",
"showReply",
")",
"{",
"$",
"status",
"=",
"$",
"showReply",
"[",
"'status'",
"]",
"[",
"0",
"]",
"[",
"'values'",
"]",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"status",
"==",
"'OK'",
")",
"{",
"$",
"this",
"->",
"queryIsRunning",
"=",
"false",
";",
"$",
"hits",
"=",
"$",
"showReply",
"[",
"'hit'",
"]",
";",
"if",
"(",
"$",
"hits",
")",
"{",
"foreach",
"(",
"$",
"hits",
"as",
"$",
"hit",
")",
"{",
"$",
"myHit",
"=",
"$",
"hit",
"[",
"'ch'",
"]",
";",
"$",
"key",
"=",
"$",
"myHit",
"[",
"'recid'",
"]",
"[",
"0",
"]",
"[",
"'values'",
"]",
"[",
"0",
"]",
";",
"// Make sure the 'medium' field exists by setting it to 'other' if necessary.",
"if",
"(",
"!",
"array_key_exists",
"(",
"'md-medium'",
",",
"$",
"myHit",
")",
")",
"{",
"$",
"myHit",
"[",
"'md-medium'",
"]",
"=",
"[",
"0",
"=>",
"[",
"'values'",
"=>",
"[",
"0",
"=>",
"'other'",
"]",
"]",
"]",
";",
"}",
"// If there is no title information but series information, use the",
"// first series field for the title.",
"if",
"(",
"!",
"(",
"array_key_exists",
"(",
"'md-title'",
",",
"$",
"myHit",
")",
"||",
"array_key_exists",
"(",
"'md-multivolume-title'",
",",
"$",
"myHit",
")",
")",
"&&",
"array_key_exists",
"(",
"'md-series-title'",
",",
"$",
"myHit",
")",
")",
"{",
"$",
"myHit",
"[",
"'md-multivolume-title'",
"]",
"=",
"[",
"$",
"myHit",
"[",
"'md-series-title'",
"]",
"[",
"0",
"]",
"]",
";",
"}",
"// Sort the location array to have the newest item first",
"usort",
"(",
"$",
"myHit",
"[",
"'location'",
"]",
",",
"[",
"$",
"this",
",",
"'yearSort'",
"]",
")",
";",
"$",
"this",
"->",
"results",
"[",
"$",
"key",
"]",
"=",
"$",
"myHit",
";",
"}",
"}",
"}",
"else",
"{",
"GeneralUtility",
"::",
"devLog",
"(",
"'pazpar2 show reply status is not \"OK\" but \"'",
".",
"$",
"status",
".",
"'\"'",
",",
"'pazpar2'",
",",
"3",
")",
";",
"}",
"}",
"else",
"{",
"GeneralUtility",
"::",
"devLog",
"(",
"'could not parse pazpar2 show reply'",
",",
"'pazpar2'",
",",
"3",
")",
";",
"}",
"}",
"}"
] |
Fetches results from pazpar2.
Requires an established session.
Stores the results in $results and the total result count in $totalResultCount.
|
[
"Fetches",
"results",
"from",
"pazpar2",
".",
"Requires",
"an",
"established",
"session",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/Query.php#L511-L569
|
239,619
|
subugoe/typo3-pazpar2
|
Classes/Domain/Model/Query.php
|
Query.pazpar2ShowURL
|
protected function pazpar2ShowURL($start = 0, $num = 500)
{
$URL = $this->getPazpar2BaseURL() . '?command=show';
$URL .= '&query=' . urlencode($this->fullQueryString());
$URL .= '&start=' . $start . '&num=' . $num;
$URL .= '&sort=' . urlencode($this->sortOrderString());
$URL .= '&block=1'; // unclear how this is advantagous but the JS client adds it
return $URL;
}
|
php
|
protected function pazpar2ShowURL($start = 0, $num = 500)
{
$URL = $this->getPazpar2BaseURL() . '?command=show';
$URL .= '&query=' . urlencode($this->fullQueryString());
$URL .= '&start=' . $start . '&num=' . $num;
$URL .= '&sort=' . urlencode($this->sortOrderString());
$URL .= '&block=1'; // unclear how this is advantagous but the JS client adds it
return $URL;
}
|
[
"protected",
"function",
"pazpar2ShowURL",
"(",
"$",
"start",
"=",
"0",
",",
"$",
"num",
"=",
"500",
")",
"{",
"$",
"URL",
"=",
"$",
"this",
"->",
"getPazpar2BaseURL",
"(",
")",
".",
"'?command=show'",
";",
"$",
"URL",
".=",
"'&query='",
".",
"urlencode",
"(",
"$",
"this",
"->",
"fullQueryString",
"(",
")",
")",
";",
"$",
"URL",
".=",
"'&start='",
".",
"$",
"start",
".",
"'&num='",
".",
"$",
"num",
";",
"$",
"URL",
".=",
"'&sort='",
".",
"urlencode",
"(",
"$",
"this",
"->",
"sortOrderString",
"(",
")",
")",
";",
"$",
"URL",
".=",
"'&block=1'",
";",
"// unclear how this is advantagous but the JS client adds it",
"return",
"$",
"URL",
";",
"}"
] |
Returns URL for downloading pazpar2 results.
The parameters can be used to give the the start record
as well as the number of records required.
TYPO3 typically starts running into out of memory errors when fetching
around 1000 records in one go with a 128MB memory limit for PHP.
@param int $start index of first record to retrieve (optional, default: 0)
@param int $num number of records to retrieve (optional, default: 500)
@return string
|
[
"Returns",
"URL",
"for",
"downloading",
"pazpar2",
"results",
".",
"The",
"parameters",
"can",
"be",
"used",
"to",
"give",
"the",
"the",
"start",
"record",
"as",
"well",
"as",
"the",
"number",
"of",
"records",
"required",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/Query.php#L583-L591
|
239,620
|
subugoe/typo3-pazpar2
|
Classes/Domain/Model/Query.php
|
Query.sortOrderString
|
protected function sortOrderString()
{
$sortOrderComponents = [];
foreach ($this->getSortOrder() as $sortCriterion) {
$sortOrderComponents[] = $sortCriterion['fieldName'] . ':'
. (($sortCriterion['direction'] === 'descending') ? '0' : '1');
}
$sortOrderString = implode(',', $sortOrderComponents);
return $sortOrderString;
}
|
php
|
protected function sortOrderString()
{
$sortOrderComponents = [];
foreach ($this->getSortOrder() as $sortCriterion) {
$sortOrderComponents[] = $sortCriterion['fieldName'] . ':'
. (($sortCriterion['direction'] === 'descending') ? '0' : '1');
}
$sortOrderString = implode(',', $sortOrderComponents);
return $sortOrderString;
}
|
[
"protected",
"function",
"sortOrderString",
"(",
")",
"{",
"$",
"sortOrderComponents",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getSortOrder",
"(",
")",
"as",
"$",
"sortCriterion",
")",
"{",
"$",
"sortOrderComponents",
"[",
"]",
"=",
"$",
"sortCriterion",
"[",
"'fieldName'",
"]",
".",
"':'",
".",
"(",
"(",
"$",
"sortCriterion",
"[",
"'direction'",
"]",
"===",
"'descending'",
")",
"?",
"'0'",
":",
"'1'",
")",
";",
"}",
"$",
"sortOrderString",
"=",
"implode",
"(",
"','",
",",
"$",
"sortOrderComponents",
")",
";",
"return",
"$",
"sortOrderString",
";",
"}"
] |
Returns a string encoding the sort order formatted for use by pazpar2.
@return string
|
[
"Returns",
"a",
"string",
"encoding",
"the",
"sort",
"order",
"formatted",
"for",
"use",
"by",
"pazpar2",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/Query.php#L598-L608
|
239,621
|
subugoe/typo3-pazpar2
|
Classes/Domain/Model/Query.php
|
Query.yearSort
|
protected function yearSort($a, $b)
{
$aDates = $this->extractNewestDates($a);
$bDates = $this->extractNewestDates($b);
if (count($aDates) > 0 && count($bDates) > 0) {
return $bDates[0] - $aDates[0];
} elseif (count($aDates) > 0 && count($bDates) === 0) {
return -1;
} elseif (count($aDates) === 0 && count($bDates) > 0) {
return 1;
} else {
return 0;
}
}
|
php
|
protected function yearSort($a, $b)
{
$aDates = $this->extractNewestDates($a);
$bDates = $this->extractNewestDates($b);
if (count($aDates) > 0 && count($bDates) > 0) {
return $bDates[0] - $aDates[0];
} elseif (count($aDates) > 0 && count($bDates) === 0) {
return -1;
} elseif (count($aDates) === 0 && count($bDates) > 0) {
return 1;
} else {
return 0;
}
}
|
[
"protected",
"function",
"yearSort",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"aDates",
"=",
"$",
"this",
"->",
"extractNewestDates",
"(",
"$",
"a",
")",
";",
"$",
"bDates",
"=",
"$",
"this",
"->",
"extractNewestDates",
"(",
"$",
"b",
")",
";",
"if",
"(",
"count",
"(",
"$",
"aDates",
")",
">",
"0",
"&&",
"count",
"(",
"$",
"bDates",
")",
">",
"0",
")",
"{",
"return",
"$",
"bDates",
"[",
"0",
"]",
"-",
"$",
"aDates",
"[",
"0",
"]",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"aDates",
")",
">",
"0",
"&&",
"count",
"(",
"$",
"bDates",
")",
"===",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"aDates",
")",
"===",
"0",
"&&",
"count",
"(",
"$",
"bDates",
")",
">",
"0",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] |
Auxiliary sort function for sorting records and locations based
on their 'date' field with the newest item being first and undefined
dates last.
@param array $a location or full pazpar2 record
@param array $b location or full pazpar2 record
@return int
|
[
"Auxiliary",
"sort",
"function",
"for",
"sorting",
"records",
"and",
"locations",
"based",
"on",
"their",
"date",
"field",
"with",
"the",
"newest",
"item",
"being",
"first",
"and",
"undefined",
"dates",
"last",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/Query.php#L669-L683
|
239,622
|
IVAgafonov/DataProvider
|
src/System/DataProvider.php
|
DataProvider.getObjects
|
public function getObjects($query, $object)
{
$this->statement = $this->db->query($query);
if ($this->statement) {
$this->statement->setFetchMode(\PDO::FETCH_CLASS, $object);
$objects = $this->statement->fetchAll();
if ($objects) {
return $objects;
}
}
return false;
}
|
php
|
public function getObjects($query, $object)
{
$this->statement = $this->db->query($query);
if ($this->statement) {
$this->statement->setFetchMode(\PDO::FETCH_CLASS, $object);
$objects = $this->statement->fetchAll();
if ($objects) {
return $objects;
}
}
return false;
}
|
[
"public",
"function",
"getObjects",
"(",
"$",
"query",
",",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"statement",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"this",
"->",
"statement",
")",
"{",
"$",
"this",
"->",
"statement",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"object",
")",
";",
"$",
"objects",
"=",
"$",
"this",
"->",
"statement",
"->",
"fetchAll",
"(",
")",
";",
"if",
"(",
"$",
"objects",
")",
"{",
"return",
"$",
"objects",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get objects by sql query
@param string $query Sql query
@param string $object Object name
@return array|bool
|
[
"Get",
"objects",
"by",
"sql",
"query"
] |
9d61b7adfb8ff794f37298daabf0e511d22bf049
|
https://github.com/IVAgafonov/DataProvider/blob/9d61b7adfb8ff794f37298daabf0e511d22bf049/src/System/DataProvider.php#L54-L65
|
239,623
|
IVAgafonov/DataProvider
|
src/System/DataProvider.php
|
DataProvider.getObject
|
public function getObject($query, $object)
{
$this->statement = $this->db->query($query);
if ($this->statement) {
$this->statement->setFetchMode(\PDO::FETCH_CLASS, $object);
return $this->statement->fetch();
}
return false;
}
|
php
|
public function getObject($query, $object)
{
$this->statement = $this->db->query($query);
if ($this->statement) {
$this->statement->setFetchMode(\PDO::FETCH_CLASS, $object);
return $this->statement->fetch();
}
return false;
}
|
[
"public",
"function",
"getObject",
"(",
"$",
"query",
",",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"statement",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"this",
"->",
"statement",
")",
"{",
"$",
"this",
"->",
"statement",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"object",
")",
";",
"return",
"$",
"this",
"->",
"statement",
"->",
"fetch",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Get object by sql query
@param string $query Sql query
@param string $object Object name
@return array|bool
|
[
"Get",
"object",
"by",
"sql",
"query"
] |
9d61b7adfb8ff794f37298daabf0e511d22bf049
|
https://github.com/IVAgafonov/DataProvider/blob/9d61b7adfb8ff794f37298daabf0e511d22bf049/src/System/DataProvider.php#L75-L83
|
239,624
|
IVAgafonov/DataProvider
|
src/System/DataProvider.php
|
DataProvider.getArrays
|
public function getArrays($query)
{
$this->statement = $this->db->query($query);
if ($this->statement) {
$result = $this->statement->fetchAll(\PDO::FETCH_ASSOC);
if ($result) {
return $result;
}
}
return false;
}
|
php
|
public function getArrays($query)
{
$this->statement = $this->db->query($query);
if ($this->statement) {
$result = $this->statement->fetchAll(\PDO::FETCH_ASSOC);
if ($result) {
return $result;
}
}
return false;
}
|
[
"public",
"function",
"getArrays",
"(",
"$",
"query",
")",
"{",
"$",
"this",
"->",
"statement",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"this",
"->",
"statement",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"statement",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get arrays by sql query
@param string $query Sql query
@return array|bool
|
[
"Get",
"arrays",
"by",
"sql",
"query"
] |
9d61b7adfb8ff794f37298daabf0e511d22bf049
|
https://github.com/IVAgafonov/DataProvider/blob/9d61b7adfb8ff794f37298daabf0e511d22bf049/src/System/DataProvider.php#L92-L102
|
239,625
|
oschildt/SmartFactory
|
src/SmartFactory/DatabaseWorkers/ShardManager.php
|
ShardManager.registerShard
|
public function registerShard($shard_name, $parameters)
{
if (empty($shard_name)) {
throw new \Exception("The shard name is not specified!");
}
if (!empty($this->shard_table[$shard_name])) {
throw new \Exception("The shard '$shard_name' has been already registered!");
}
$this->shard_table[$shard_name]["parameters"] = $parameters;
return true;
}
|
php
|
public function registerShard($shard_name, $parameters)
{
if (empty($shard_name)) {
throw new \Exception("The shard name is not specified!");
}
if (!empty($this->shard_table[$shard_name])) {
throw new \Exception("The shard '$shard_name' has been already registered!");
}
$this->shard_table[$shard_name]["parameters"] = $parameters;
return true;
}
|
[
"public",
"function",
"registerShard",
"(",
"$",
"shard_name",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"shard_name",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The shard name is not specified!\"",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"shard_table",
"[",
"$",
"shard_name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The shard '$shard_name' has been already registered!\"",
")",
";",
"}",
"$",
"this",
"->",
"shard_table",
"[",
"$",
"shard_name",
"]",
"[",
"\"parameters\"",
"]",
"=",
"$",
"parameters",
";",
"return",
"true",
";",
"}"
] |
Registers a new shard.
@param string $shard_name
Unique shard name.
@param array $parameters
The connection parameters to the shard as an associative array in the form key => value:
- $parameters["db_type"] - type of the database (MySQL or MSSQL)
- $parameters["db_server"] - server address
- $parameters["db_name"] - database name
- $parameters["db_user"] - user name
- $parameters["db_password"] - user password
- $parameters["autoconnect"] - should true if the connection should be established automatically
upon creation.
- $parameters["read_only"] - this paramter sets the connection to the read only mode.
@return boolean
It should return true if the registering was successful, otherwise false.
@throws \Exception
It might throw an exception in the case of any errors:
- if the shard name is not specified.
- if the shard name has been already registered.
@author Oleg Schildt
|
[
"Registers",
"a",
"new",
"shard",
"."
] |
efd289961a720d5f3103a3c696e2beee16e9644d
|
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/ShardManager.php#L71-L84
|
239,626
|
oschildt/SmartFactory
|
src/SmartFactory/DatabaseWorkers/ShardManager.php
|
ShardManager.dbshard
|
public function dbshard($shard_name)
{
if (empty($shard_name) || empty($this->shard_table[$shard_name])) {
throw new \Exception("The shard '$shard_name' was not found!");
return null;
}
if (empty($this->shard_table[$shard_name]["dbworker"])) {
$this->shard_table[$shard_name]["dbworker"] = dbworker($this->shard_table[$shard_name]["parameters"], true);
}
return $this->shard_table[$shard_name]["dbworker"];
}
|
php
|
public function dbshard($shard_name)
{
if (empty($shard_name) || empty($this->shard_table[$shard_name])) {
throw new \Exception("The shard '$shard_name' was not found!");
return null;
}
if (empty($this->shard_table[$shard_name]["dbworker"])) {
$this->shard_table[$shard_name]["dbworker"] = dbworker($this->shard_table[$shard_name]["parameters"], true);
}
return $this->shard_table[$shard_name]["dbworker"];
}
|
[
"public",
"function",
"dbshard",
"(",
"$",
"shard_name",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"shard_name",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"shard_table",
"[",
"$",
"shard_name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The shard '$shard_name' was not found!\"",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"shard_table",
"[",
"$",
"shard_name",
"]",
"[",
"\"dbworker\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"shard_table",
"[",
"$",
"shard_name",
"]",
"[",
"\"dbworker\"",
"]",
"=",
"dbworker",
"(",
"$",
"this",
"->",
"shard_table",
"[",
"$",
"shard_name",
"]",
"[",
"\"parameters\"",
"]",
",",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"shard_table",
"[",
"$",
"shard_name",
"]",
"[",
"\"dbworker\"",
"]",
";",
"}"
] |
The method dbshard provides the DBWorker object for working with the shard.
If the parameters are omitted, the system takes the parameters from the configuration
settings and reuses the single instance of the DBWorker for all requests.
If the user passes the parameters explicitly, a new instance of the DBWorker is created upon each new request.
Currently supported: MySQL und MS SQL.
@param string $shard_name
The name of the shard.
@return \SmartFactory\DatabaseWorkers\DBWorker|null
returns DBWorker object or null if the object could not be created.
@throws \Exception
It might throw an exception in the case of any errors:
- if the interface or class does not exist.
- if the shard was not found.
- if the check of the classes and interfaces fails.
- if the php extension is not installed.
- db_missing_type_error - if the database type is not specified.
- db_conn_data_error - if the connection parameters are incomplete.
- db_server_conn_error - if the database server cannot be connected.
- db_not_exists_error - if database does not exists od inaccesible to the user.
@author Oleg Schildt
|
[
"The",
"method",
"dbshard",
"provides",
"the",
"DBWorker",
"object",
"for",
"working",
"with",
"the",
"shard",
"."
] |
efd289961a720d5f3103a3c696e2beee16e9644d
|
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/ShardManager.php#L115-L127
|
239,627
|
phlexible/phlexible
|
src/Phlexible/Component/Volume/VolumeManager.php
|
VolumeManager.findByFileId
|
public function findByFileId($fileId)
{
foreach ($this->volumes as $volume) {
try {
$file = $volume->findFile($fileId);
if ($file) {
return $volume;
}
} catch (\Exception $e) {
}
}
return null;
}
|
php
|
public function findByFileId($fileId)
{
foreach ($this->volumes as $volume) {
try {
$file = $volume->findFile($fileId);
if ($file) {
return $volume;
}
} catch (\Exception $e) {
}
}
return null;
}
|
[
"public",
"function",
"findByFileId",
"(",
"$",
"fileId",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"volumes",
"as",
"$",
"volume",
")",
"{",
"try",
"{",
"$",
"file",
"=",
"$",
"volume",
"->",
"findFile",
"(",
"$",
"fileId",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"return",
"$",
"volume",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"return",
"null",
";",
"}"
] |
Return volume by file ID.
@param string $fileId
@return Volume
|
[
"Return",
"volume",
"by",
"file",
"ID",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/Volume/VolumeManager.php#L90-L103
|
239,628
|
phlexible/phlexible
|
src/Phlexible/Component/Volume/VolumeManager.php
|
VolumeManager.findByFolderId
|
public function findByFolderId($folderId)
{
foreach ($this->volumes as $volume) {
if ($volume->findFolder($folderId)) {
return $volume;
}
}
return null;
}
|
php
|
public function findByFolderId($folderId)
{
foreach ($this->volumes as $volume) {
if ($volume->findFolder($folderId)) {
return $volume;
}
}
return null;
}
|
[
"public",
"function",
"findByFolderId",
"(",
"$",
"folderId",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"volumes",
"as",
"$",
"volume",
")",
"{",
"if",
"(",
"$",
"volume",
"->",
"findFolder",
"(",
"$",
"folderId",
")",
")",
"{",
"return",
"$",
"volume",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Return volume by folder ID.
@param string $folderId
@return Volume
|
[
"Return",
"volume",
"by",
"folder",
"ID",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/Volume/VolumeManager.php#L130-L139
|
239,629
|
nubs/sensible
|
src/Strategy/EnvironmentVariableStrategy.php
|
EnvironmentVariableStrategy.get
|
public function get()
{
$result = $this->_environment ? $this->_environment->getenv($this->_name) : getenv($this->_name);
return $result !== false ? $result : null;
}
|
php
|
public function get()
{
$result = $this->_environment ? $this->_environment->getenv($this->_name) : getenv($this->_name);
return $result !== false ? $result : null;
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_environment",
"?",
"$",
"this",
"->",
"_environment",
"->",
"getenv",
"(",
"$",
"this",
"->",
"_name",
")",
":",
"getenv",
"(",
"$",
"this",
"->",
"_name",
")",
";",
"return",
"$",
"result",
"!==",
"false",
"?",
"$",
"result",
":",
"null",
";",
"}"
] |
Returns the command as found in the environment variable.
@return string|null The command, or null if the environment variable
wasn't set.
|
[
"Returns",
"the",
"command",
"as",
"found",
"in",
"the",
"environment",
"variable",
"."
] |
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
|
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Strategy/EnvironmentVariableStrategy.php#L38-L43
|
239,630
|
ciims/cii
|
components/CiiPHPMessageSource.php
|
CiiPHPMessageSource.getMessageFile
|
protected function getMessageFile($category,$language)
{
if(!isset($this->_files[$category][$language]))
{
if(($pos=strpos($category,'.'))!==false && strpos($category,'ciims') === false)
{
$extensionClass=substr($category,0,$pos);
$extensionCategory=substr($category,$pos+1);
// First check if there's an extension registered for this class.
if(isset($this->extensionPaths[$extensionClass]))
$this->_files[$category][$language]=Yii::getPathOfAlias($this->extensionPaths[$extensionClass]).DS.$language.DS.$extensionCategory.'.php';
else
{
if (strpos($extensionClass, 'themes') !== false)
{
$baseClass = explode('.', $extensionCategory);
$theme = $baseClass[0];
unset($baseClass[0]);
$baseClass = implode('.', $baseClass);
$this->_files[$category][$language] = Yii::getPathOfAlias("base.themes.$theme.messages").DS.$language.DS.$baseClass.'.php';
}
else
{
// No extension registered, need to find it.
if (isset(Yii::app()->controller->module->id))
$extensionClass .= 'Module';
$class=new ReflectionClass($extensionClass);
$this->_files[$category][$language]=dirname($class->getFileName()).DS.'messages'.DS.$language.DS.$extensionCategory.'.php';
}
}
}
else
{
if (strpos($category,'ciims.') !== false)
{
$this->basePath = Yii::getPathOfAlias('application.messages.');
$this->_files[$category][$language]=$this->basePath.DS.$language.DS.str_replace('.', '/', str_replace('ciims.', '', $category)).'.php';
}
else
$this->_files[$category][$language]=$this->basePath.DS.$language.DS.$category.'.php';
}
}
return $this->_files[$category][$language];
}
|
php
|
protected function getMessageFile($category,$language)
{
if(!isset($this->_files[$category][$language]))
{
if(($pos=strpos($category,'.'))!==false && strpos($category,'ciims') === false)
{
$extensionClass=substr($category,0,$pos);
$extensionCategory=substr($category,$pos+1);
// First check if there's an extension registered for this class.
if(isset($this->extensionPaths[$extensionClass]))
$this->_files[$category][$language]=Yii::getPathOfAlias($this->extensionPaths[$extensionClass]).DS.$language.DS.$extensionCategory.'.php';
else
{
if (strpos($extensionClass, 'themes') !== false)
{
$baseClass = explode('.', $extensionCategory);
$theme = $baseClass[0];
unset($baseClass[0]);
$baseClass = implode('.', $baseClass);
$this->_files[$category][$language] = Yii::getPathOfAlias("base.themes.$theme.messages").DS.$language.DS.$baseClass.'.php';
}
else
{
// No extension registered, need to find it.
if (isset(Yii::app()->controller->module->id))
$extensionClass .= 'Module';
$class=new ReflectionClass($extensionClass);
$this->_files[$category][$language]=dirname($class->getFileName()).DS.'messages'.DS.$language.DS.$extensionCategory.'.php';
}
}
}
else
{
if (strpos($category,'ciims.') !== false)
{
$this->basePath = Yii::getPathOfAlias('application.messages.');
$this->_files[$category][$language]=$this->basePath.DS.$language.DS.str_replace('.', '/', str_replace('ciims.', '', $category)).'.php';
}
else
$this->_files[$category][$language]=$this->basePath.DS.$language.DS.$category.'.php';
}
}
return $this->_files[$category][$language];
}
|
[
"protected",
"function",
"getMessageFile",
"(",
"$",
"category",
",",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_files",
"[",
"$",
"category",
"]",
"[",
"$",
"language",
"]",
")",
")",
"{",
"if",
"(",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"category",
",",
"'.'",
")",
")",
"!==",
"false",
"&&",
"strpos",
"(",
"$",
"category",
",",
"'ciims'",
")",
"===",
"false",
")",
"{",
"$",
"extensionClass",
"=",
"substr",
"(",
"$",
"category",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"extensionCategory",
"=",
"substr",
"(",
"$",
"category",
",",
"$",
"pos",
"+",
"1",
")",
";",
"// First check if there's an extension registered for this class.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"extensionPaths",
"[",
"$",
"extensionClass",
"]",
")",
")",
"$",
"this",
"->",
"_files",
"[",
"$",
"category",
"]",
"[",
"$",
"language",
"]",
"=",
"Yii",
"::",
"getPathOfAlias",
"(",
"$",
"this",
"->",
"extensionPaths",
"[",
"$",
"extensionClass",
"]",
")",
".",
"DS",
".",
"$",
"language",
".",
"DS",
".",
"$",
"extensionCategory",
".",
"'.php'",
";",
"else",
"{",
"if",
"(",
"strpos",
"(",
"$",
"extensionClass",
",",
"'themes'",
")",
"!==",
"false",
")",
"{",
"$",
"baseClass",
"=",
"explode",
"(",
"'.'",
",",
"$",
"extensionCategory",
")",
";",
"$",
"theme",
"=",
"$",
"baseClass",
"[",
"0",
"]",
";",
"unset",
"(",
"$",
"baseClass",
"[",
"0",
"]",
")",
";",
"$",
"baseClass",
"=",
"implode",
"(",
"'.'",
",",
"$",
"baseClass",
")",
";",
"$",
"this",
"->",
"_files",
"[",
"$",
"category",
"]",
"[",
"$",
"language",
"]",
"=",
"Yii",
"::",
"getPathOfAlias",
"(",
"\"base.themes.$theme.messages\"",
")",
".",
"DS",
".",
"$",
"language",
".",
"DS",
".",
"$",
"baseClass",
".",
"'.php'",
";",
"}",
"else",
"{",
"// No extension registered, need to find it.",
"if",
"(",
"isset",
"(",
"Yii",
"::",
"app",
"(",
")",
"->",
"controller",
"->",
"module",
"->",
"id",
")",
")",
"$",
"extensionClass",
".=",
"'Module'",
";",
"$",
"class",
"=",
"new",
"ReflectionClass",
"(",
"$",
"extensionClass",
")",
";",
"$",
"this",
"->",
"_files",
"[",
"$",
"category",
"]",
"[",
"$",
"language",
"]",
"=",
"dirname",
"(",
"$",
"class",
"->",
"getFileName",
"(",
")",
")",
".",
"DS",
".",
"'messages'",
".",
"DS",
".",
"$",
"language",
".",
"DS",
".",
"$",
"extensionCategory",
".",
"'.php'",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"strpos",
"(",
"$",
"category",
",",
"'ciims.'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"basePath",
"=",
"Yii",
"::",
"getPathOfAlias",
"(",
"'application.messages.'",
")",
";",
"$",
"this",
"->",
"_files",
"[",
"$",
"category",
"]",
"[",
"$",
"language",
"]",
"=",
"$",
"this",
"->",
"basePath",
".",
"DS",
".",
"$",
"language",
".",
"DS",
".",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"str_replace",
"(",
"'ciims.'",
",",
"''",
",",
"$",
"category",
")",
")",
".",
"'.php'",
";",
"}",
"else",
"$",
"this",
"->",
"_files",
"[",
"$",
"category",
"]",
"[",
"$",
"language",
"]",
"=",
"$",
"this",
"->",
"basePath",
".",
"DS",
".",
"$",
"language",
".",
"DS",
".",
"$",
"category",
".",
"'.php'",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_files",
"[",
"$",
"category",
"]",
"[",
"$",
"language",
"]",
";",
"}"
] |
Direct overload of getMessageFile
This method is overloaded to allow modules, themes, and CiiMS Core to have their own unique message sources
instead of having everything grouped together in protected/messages
Modules and Themes now should have their own /messages folder to store translations
@param string $category The category we want to work with
@param string $language The language we want the string translated to
@return string File path to the message translation source
|
[
"Direct",
"overload",
"of",
"getMessageFile"
] |
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
|
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/components/CiiPHPMessageSource.php#L45-L91
|
239,631
|
ncuesta/pinocchio
|
src/Pinocchio/Parser/Php.php
|
Php.parse
|
public function parse(\Pinocchio\Pinocchio $pinocchio, \Pinocchio\Highlighter\HighlighterInterface $highlighter = null) {
if (null === $highlighter) {
$highlighter = new Pygments();
}
$code = '';
// $docBlocks is initialized with an empty element for the '<?php' start of the code
$docBlocks = array('');
$previousToken = null;
$commentRegexSet = $this->getCommentRegexSet();
foreach ($this->tokenize($pinocchio->getSource()) as $token) {
if (is_array($token)) {
if ($this->isComment(token_name($token[0]))) {
$last = '';
$token[1] = str_replace("\t", self::TAB_AS_SPACES, $token[1]);
if (token_name($previousToken[0]) === self::TOKEN_NAME_COMMENT && token_name($token[0]) === self::TOKEN_NAME_COMMENT) {
$last = array_pop($docBlocks);
} else {
$code .= self::CODEBLOCK_DELIMITER;
}
$docBlocks[] = $last . preg_replace($commentRegexSet, '$1', $token[1]);
} else {
$code .= $token[1];
}
} else {
$code .= $token;
}
$previousToken = $token;
}
$codeBlocks = explode(
self::HIGHLIGHTED_CODEBLOCK_DELIMITER,
$highlighter->highlight('php', $code)
);
foreach ($codeBlocks as $codeBlock) {
$pinocchio->addCodeBlock(
sprintf(
self::HIGHLIGHT_BLOCK_HTML_PATTERN,
str_replace("\t", ' ', $codeBlock)
)
);
}
$pinocchio->setDocBlocks($this->parseDocblocks($docBlocks));
return $pinocchio;
}
|
php
|
public function parse(\Pinocchio\Pinocchio $pinocchio, \Pinocchio\Highlighter\HighlighterInterface $highlighter = null) {
if (null === $highlighter) {
$highlighter = new Pygments();
}
$code = '';
// $docBlocks is initialized with an empty element for the '<?php' start of the code
$docBlocks = array('');
$previousToken = null;
$commentRegexSet = $this->getCommentRegexSet();
foreach ($this->tokenize($pinocchio->getSource()) as $token) {
if (is_array($token)) {
if ($this->isComment(token_name($token[0]))) {
$last = '';
$token[1] = str_replace("\t", self::TAB_AS_SPACES, $token[1]);
if (token_name($previousToken[0]) === self::TOKEN_NAME_COMMENT && token_name($token[0]) === self::TOKEN_NAME_COMMENT) {
$last = array_pop($docBlocks);
} else {
$code .= self::CODEBLOCK_DELIMITER;
}
$docBlocks[] = $last . preg_replace($commentRegexSet, '$1', $token[1]);
} else {
$code .= $token[1];
}
} else {
$code .= $token;
}
$previousToken = $token;
}
$codeBlocks = explode(
self::HIGHLIGHTED_CODEBLOCK_DELIMITER,
$highlighter->highlight('php', $code)
);
foreach ($codeBlocks as $codeBlock) {
$pinocchio->addCodeBlock(
sprintf(
self::HIGHLIGHT_BLOCK_HTML_PATTERN,
str_replace("\t", ' ', $codeBlock)
)
);
}
$pinocchio->setDocBlocks($this->parseDocblocks($docBlocks));
return $pinocchio;
}
|
[
"public",
"function",
"parse",
"(",
"\\",
"Pinocchio",
"\\",
"Pinocchio",
"$",
"pinocchio",
",",
"\\",
"Pinocchio",
"\\",
"Highlighter",
"\\",
"HighlighterInterface",
"$",
"highlighter",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"highlighter",
")",
"{",
"$",
"highlighter",
"=",
"new",
"Pygments",
"(",
")",
";",
"}",
"$",
"code",
"=",
"''",
";",
"// $docBlocks is initialized with an empty element for the '<?php' start of the code",
"$",
"docBlocks",
"=",
"array",
"(",
"''",
")",
";",
"$",
"previousToken",
"=",
"null",
";",
"$",
"commentRegexSet",
"=",
"$",
"this",
"->",
"getCommentRegexSet",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"tokenize",
"(",
"$",
"pinocchio",
"->",
"getSource",
"(",
")",
")",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"token",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isComment",
"(",
"token_name",
"(",
"$",
"token",
"[",
"0",
"]",
")",
")",
")",
"{",
"$",
"last",
"=",
"''",
";",
"$",
"token",
"[",
"1",
"]",
"=",
"str_replace",
"(",
"\"\\t\"",
",",
"self",
"::",
"TAB_AS_SPACES",
",",
"$",
"token",
"[",
"1",
"]",
")",
";",
"if",
"(",
"token_name",
"(",
"$",
"previousToken",
"[",
"0",
"]",
")",
"===",
"self",
"::",
"TOKEN_NAME_COMMENT",
"&&",
"token_name",
"(",
"$",
"token",
"[",
"0",
"]",
")",
"===",
"self",
"::",
"TOKEN_NAME_COMMENT",
")",
"{",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"docBlocks",
")",
";",
"}",
"else",
"{",
"$",
"code",
".=",
"self",
"::",
"CODEBLOCK_DELIMITER",
";",
"}",
"$",
"docBlocks",
"[",
"]",
"=",
"$",
"last",
".",
"preg_replace",
"(",
"$",
"commentRegexSet",
",",
"'$1'",
",",
"$",
"token",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"code",
".=",
"$",
"token",
"[",
"1",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"code",
".=",
"$",
"token",
";",
"}",
"$",
"previousToken",
"=",
"$",
"token",
";",
"}",
"$",
"codeBlocks",
"=",
"explode",
"(",
"self",
"::",
"HIGHLIGHTED_CODEBLOCK_DELIMITER",
",",
"$",
"highlighter",
"->",
"highlight",
"(",
"'php'",
",",
"$",
"code",
")",
")",
";",
"foreach",
"(",
"$",
"codeBlocks",
"as",
"$",
"codeBlock",
")",
"{",
"$",
"pinocchio",
"->",
"addCodeBlock",
"(",
"sprintf",
"(",
"self",
"::",
"HIGHLIGHT_BLOCK_HTML_PATTERN",
",",
"str_replace",
"(",
"\"\\t\"",
",",
"' '",
",",
"$",
"codeBlock",
")",
")",
")",
";",
"}",
"$",
"pinocchio",
"->",
"setDocBlocks",
"(",
"$",
"this",
"->",
"parseDocblocks",
"(",
"$",
"docBlocks",
")",
")",
";",
"return",
"$",
"pinocchio",
";",
"}"
] |
Parse a Pinocchio instance.
@param \Pinocchio\Pinocchio $pinocchio The Pinocchio instance to parse.
@param \Pinocchio\Highlighter\HighlighterInterface $highlighter The highlighter to use (optional)
@return \Pinocchio\Pinocchio
|
[
"Parse",
"a",
"Pinocchio",
"instance",
"."
] |
01b119a003362fd3a50e843341c62c95374d87cf
|
https://github.com/ncuesta/pinocchio/blob/01b119a003362fd3a50e843341c62c95374d87cf/src/Pinocchio/Parser/Php.php#L54-L106
|
239,632
|
ncuesta/pinocchio
|
src/Pinocchio/Parser/Php.php
|
Php.getCommentRegexSet
|
public function getCommentRegexSet()
{
return array(
self::REGEX_COMMENT_SINGLE_LINE,
self::REGEX_COMMENT_MULTILINE_START,
self::REGEX_COMMENT_MULTILINE_CONT,
self::REGEX_COMMENT_MULTILINE_END,
self::REGEX_COMMENT_MULTILINE_ONE_LINER,
);
}
|
php
|
public function getCommentRegexSet()
{
return array(
self::REGEX_COMMENT_SINGLE_LINE,
self::REGEX_COMMENT_MULTILINE_START,
self::REGEX_COMMENT_MULTILINE_CONT,
self::REGEX_COMMENT_MULTILINE_END,
self::REGEX_COMMENT_MULTILINE_ONE_LINER,
);
}
|
[
"public",
"function",
"getCommentRegexSet",
"(",
")",
"{",
"return",
"array",
"(",
"self",
"::",
"REGEX_COMMENT_SINGLE_LINE",
",",
"self",
"::",
"REGEX_COMMENT_MULTILINE_START",
",",
"self",
"::",
"REGEX_COMMENT_MULTILINE_CONT",
",",
"self",
"::",
"REGEX_COMMENT_MULTILINE_END",
",",
"self",
"::",
"REGEX_COMMENT_MULTILINE_ONE_LINER",
",",
")",
";",
"}"
] |
Get the set of regular expressions that represent the different
comment blocks that might be found in the PHP code.
@return array
|
[
"Get",
"the",
"set",
"of",
"regular",
"expressions",
"that",
"represent",
"the",
"different",
"comment",
"blocks",
"that",
"might",
"be",
"found",
"in",
"the",
"PHP",
"code",
"."
] |
01b119a003362fd3a50e843341c62c95374d87cf
|
https://github.com/ncuesta/pinocchio/blob/01b119a003362fd3a50e843341c62c95374d87cf/src/Pinocchio/Parser/Php.php#L114-L123
|
239,633
|
ncuesta/pinocchio
|
src/Pinocchio/Parser/Php.php
|
Php.parseDocblocks
|
protected function parseDocblocks($rawDocBlocks)
{
$parsedDocBlocks = array();
$docBlockParser = new MarkdownParser();
foreach ($rawDocBlocks as $docBlock) {
$docBlock = preg_replace(self::REGEX_DOCBLOCK_TYPE, '$1$2 `$4` ', $docBlock);
$docBlock = preg_replace(self::REGEX_DOCBLOCK_VAR, '$1`$2`', $docBlock);
$docBlock = preg_replace(self::REGEX_DOCBLOCK_ARG, "\n<em class=\"docparam\">$1</em>", $docBlock);
$parsedDocBlocks[] = $docBlockParser->transformMarkdown($docBlock);
}
return $parsedDocBlocks;
}
|
php
|
protected function parseDocblocks($rawDocBlocks)
{
$parsedDocBlocks = array();
$docBlockParser = new MarkdownParser();
foreach ($rawDocBlocks as $docBlock) {
$docBlock = preg_replace(self::REGEX_DOCBLOCK_TYPE, '$1$2 `$4` ', $docBlock);
$docBlock = preg_replace(self::REGEX_DOCBLOCK_VAR, '$1`$2`', $docBlock);
$docBlock = preg_replace(self::REGEX_DOCBLOCK_ARG, "\n<em class=\"docparam\">$1</em>", $docBlock);
$parsedDocBlocks[] = $docBlockParser->transformMarkdown($docBlock);
}
return $parsedDocBlocks;
}
|
[
"protected",
"function",
"parseDocblocks",
"(",
"$",
"rawDocBlocks",
")",
"{",
"$",
"parsedDocBlocks",
"=",
"array",
"(",
")",
";",
"$",
"docBlockParser",
"=",
"new",
"MarkdownParser",
"(",
")",
";",
"foreach",
"(",
"$",
"rawDocBlocks",
"as",
"$",
"docBlock",
")",
"{",
"$",
"docBlock",
"=",
"preg_replace",
"(",
"self",
"::",
"REGEX_DOCBLOCK_TYPE",
",",
"'$1$2 `$4` '",
",",
"$",
"docBlock",
")",
";",
"$",
"docBlock",
"=",
"preg_replace",
"(",
"self",
"::",
"REGEX_DOCBLOCK_VAR",
",",
"'$1`$2`'",
",",
"$",
"docBlock",
")",
";",
"$",
"docBlock",
"=",
"preg_replace",
"(",
"self",
"::",
"REGEX_DOCBLOCK_ARG",
",",
"\"\\n<em class=\\\"docparam\\\">$1</em>\"",
",",
"$",
"docBlock",
")",
";",
"$",
"parsedDocBlocks",
"[",
"]",
"=",
"$",
"docBlockParser",
"->",
"transformMarkdown",
"(",
"$",
"docBlock",
")",
";",
"}",
"return",
"$",
"parsedDocBlocks",
";",
"}"
] |
Parse the given documentation blocks with a Markdown parser and return
the resulting formatted blocks as HTML snippets.
@param array $rawDocBlocks The raw documentation blocks to parse.
@return array
|
[
"Parse",
"the",
"given",
"documentation",
"blocks",
"with",
"a",
"Markdown",
"parser",
"and",
"return",
"the",
"resulting",
"formatted",
"blocks",
"as",
"HTML",
"snippets",
"."
] |
01b119a003362fd3a50e843341c62c95374d87cf
|
https://github.com/ncuesta/pinocchio/blob/01b119a003362fd3a50e843341c62c95374d87cf/src/Pinocchio/Parser/Php.php#L133-L147
|
239,634
|
wearenolte/wp-widgets
|
src/Collection/LeanRecent.php
|
LeanRecent.update
|
public function update( $new_instance, $old_instance ) {
$post_types = get_post_types();
$selected = isset( $_REQUEST[ $this->get_field_id( 'post_type' ) ] )
? sanitize_text_field( wp_unslash( $_REQUEST[ $this->get_field_id( 'post_type' ) ] ) )
: false;
if ( in_array( $selected, $post_types, true ) ) {
$new_instance['post_type'] = $selected;
}
$number = isset( $_REQUEST[ $this->get_field_id( 'number' ) ] )
? absint( $_REQUEST[ $this->get_field_id( 'number' ) ] )
: false;
$new_instance['number'] = $number;
return $new_instance;
}
|
php
|
public function update( $new_instance, $old_instance ) {
$post_types = get_post_types();
$selected = isset( $_REQUEST[ $this->get_field_id( 'post_type' ) ] )
? sanitize_text_field( wp_unslash( $_REQUEST[ $this->get_field_id( 'post_type' ) ] ) )
: false;
if ( in_array( $selected, $post_types, true ) ) {
$new_instance['post_type'] = $selected;
}
$number = isset( $_REQUEST[ $this->get_field_id( 'number' ) ] )
? absint( $_REQUEST[ $this->get_field_id( 'number' ) ] )
: false;
$new_instance['number'] = $number;
return $new_instance;
}
|
[
"public",
"function",
"update",
"(",
"$",
"new_instance",
",",
"$",
"old_instance",
")",
"{",
"$",
"post_types",
"=",
"get_post_types",
"(",
")",
";",
"$",
"selected",
"=",
"isset",
"(",
"$",
"_REQUEST",
"[",
"$",
"this",
"->",
"get_field_id",
"(",
"'post_type'",
")",
"]",
")",
"?",
"sanitize_text_field",
"(",
"wp_unslash",
"(",
"$",
"_REQUEST",
"[",
"$",
"this",
"->",
"get_field_id",
"(",
"'post_type'",
")",
"]",
")",
")",
":",
"false",
";",
"if",
"(",
"in_array",
"(",
"$",
"selected",
",",
"$",
"post_types",
",",
"true",
")",
")",
"{",
"$",
"new_instance",
"[",
"'post_type'",
"]",
"=",
"$",
"selected",
";",
"}",
"$",
"number",
"=",
"isset",
"(",
"$",
"_REQUEST",
"[",
"$",
"this",
"->",
"get_field_id",
"(",
"'number'",
")",
"]",
")",
"?",
"absint",
"(",
"$",
"_REQUEST",
"[",
"$",
"this",
"->",
"get_field_id",
"(",
"'number'",
")",
"]",
")",
":",
"false",
";",
"$",
"new_instance",
"[",
"'number'",
"]",
"=",
"$",
"number",
";",
"return",
"$",
"new_instance",
";",
"}"
] |
Save the post type
@param array $new_instance
@param array $old_instance
@return array
|
[
"Save",
"the",
"post",
"type"
] |
7b008dc3182f8b9da44657bd2fe714e7e48cf002
|
https://github.com/wearenolte/wp-widgets/blob/7b008dc3182f8b9da44657bd2fe714e7e48cf002/src/Collection/LeanRecent.php#L80-L99
|
239,635
|
Puzzlout/FrameworkMvcLegacy
|
src/Helpers/UserHelper.php
|
UserHelper.GetAndStoreUsersInSession
|
public static function GetAndStoreUsersInSession($caller) {
$users = array();
if (!$caller->app()->user()->getAttribute(\Puzzlout\Framework\Enums\SessionKeys::AllUsers)) {
$manager = $caller->managers()->getDalInstance($caller->module());
$users = $manager->selectAllUsers();
$caller->app()->user->setAttribute(
\Puzzlout\Framework\Enums\SessionKeys::AllUsers, $users
);
} else {
$users = $caller->app()->user->getAttribute(\Puzzlout\Framework\Enums\SessionKeys::AllUsers);
}
return $users;
}
|
php
|
public static function GetAndStoreUsersInSession($caller) {
$users = array();
if (!$caller->app()->user()->getAttribute(\Puzzlout\Framework\Enums\SessionKeys::AllUsers)) {
$manager = $caller->managers()->getDalInstance($caller->module());
$users = $manager->selectAllUsers();
$caller->app()->user->setAttribute(
\Puzzlout\Framework\Enums\SessionKeys::AllUsers, $users
);
} else {
$users = $caller->app()->user->getAttribute(\Puzzlout\Framework\Enums\SessionKeys::AllUsers);
}
return $users;
}
|
[
"public",
"static",
"function",
"GetAndStoreUsersInSession",
"(",
"$",
"caller",
")",
"{",
"$",
"users",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"caller",
"->",
"app",
"(",
")",
"->",
"user",
"(",
")",
"->",
"getAttribute",
"(",
"\\",
"Puzzlout",
"\\",
"Framework",
"\\",
"Enums",
"\\",
"SessionKeys",
"::",
"AllUsers",
")",
")",
"{",
"$",
"manager",
"=",
"$",
"caller",
"->",
"managers",
"(",
")",
"->",
"getDalInstance",
"(",
"$",
"caller",
"->",
"module",
"(",
")",
")",
";",
"$",
"users",
"=",
"$",
"manager",
"->",
"selectAllUsers",
"(",
")",
";",
"$",
"caller",
"->",
"app",
"(",
")",
"->",
"user",
"->",
"setAttribute",
"(",
"\\",
"Puzzlout",
"\\",
"Framework",
"\\",
"Enums",
"\\",
"SessionKeys",
"::",
"AllUsers",
",",
"$",
"users",
")",
";",
"}",
"else",
"{",
"$",
"users",
"=",
"$",
"caller",
"->",
"app",
"(",
")",
"->",
"user",
"->",
"getAttribute",
"(",
"\\",
"Puzzlout",
"\\",
"Framework",
"\\",
"Enums",
"\\",
"SessionKeys",
"::",
"AllUsers",
")",
";",
"}",
"return",
"$",
"users",
";",
"}"
] |
Checks if the users are not stored in Session.
Stores the users
Set the data into the session for later use.
@param /Library/Request $rq
@return array $lists : the lists of objects if any
|
[
"Checks",
"if",
"the",
"users",
"are",
"not",
"stored",
"in",
"Session",
".",
"Stores",
"the",
"users",
"Set",
"the",
"data",
"into",
"the",
"session",
"for",
"later",
"use",
"."
] |
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
|
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/UserHelper.php#L70-L83
|
239,636
|
Puzzlout/FrameworkMvcLegacy
|
src/Helpers/UserHelper.php
|
UserHelper.AddNewUserToSession
|
public static function AddNewUserToSession($caller, $user) {
$users = self::GetAndStoreUsersInSession($caller);
$users[] = $user;
$caller->app()->user->setAttribute(
\Puzzlout\Framework\Enums\SessionKeys::AllUsers, $users
);
}
|
php
|
public static function AddNewUserToSession($caller, $user) {
$users = self::GetAndStoreUsersInSession($caller);
$users[] = $user;
$caller->app()->user->setAttribute(
\Puzzlout\Framework\Enums\SessionKeys::AllUsers, $users
);
}
|
[
"public",
"static",
"function",
"AddNewUserToSession",
"(",
"$",
"caller",
",",
"$",
"user",
")",
"{",
"$",
"users",
"=",
"self",
"::",
"GetAndStoreUsersInSession",
"(",
"$",
"caller",
")",
";",
"$",
"users",
"[",
"]",
"=",
"$",
"user",
";",
"$",
"caller",
"->",
"app",
"(",
")",
"->",
"user",
"->",
"setAttribute",
"(",
"\\",
"Puzzlout",
"\\",
"Framework",
"\\",
"Enums",
"\\",
"SessionKeys",
"::",
"AllUsers",
",",
"$",
"users",
")",
";",
"}"
] |
Add new user in session
|
[
"Add",
"new",
"user",
"in",
"session"
] |
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
|
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/UserHelper.php#L88-L94
|
239,637
|
Puzzlout/FrameworkMvcLegacy
|
src/Helpers/UserHelper.php
|
UserHelper.CategorizeUsersList
|
public static function CategorizeUsersList($users) {
$list = array();
if (is_array($users) && count($users) > 0) {
foreach ($users as $user) {
$userType = $user->user_type();
$list[$userType][] = $user;
}
}
return $list;
}
|
php
|
public static function CategorizeUsersList($users) {
$list = array();
if (is_array($users) && count($users) > 0) {
foreach ($users as $user) {
$userType = $user->user_type();
$list[$userType][] = $user;
}
}
return $list;
}
|
[
"public",
"static",
"function",
"CategorizeUsersList",
"(",
"$",
"users",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"users",
")",
"&&",
"count",
"(",
"$",
"users",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"userType",
"=",
"$",
"user",
"->",
"user_type",
"(",
")",
";",
"$",
"list",
"[",
"$",
"userType",
"]",
"[",
"]",
"=",
"$",
"user",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] |
Categorize user list by type
|
[
"Categorize",
"user",
"list",
"by",
"type"
] |
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
|
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/UserHelper.php#L99-L108
|
239,638
|
mszewcz/php-light-framework
|
src/Visitor/Ip.php
|
Ip.getProxyString
|
private static function getProxyString(): ?string
{
$proxyString = null;
if (\getenv('HTTP_CLIENT_IP')) {
$proxyString = \getenv('HTTP_CLIENT_IP');
} elseif (\getenv('HTTP_X_FORWARDED_FOR')) {
$proxyString = \getenv('HTTP_X_FORWARDED_FOR');
} elseif (\getenv('HTTP_X_FORWARDED')) {
$proxyString = \getenv('HTTP_X_FORWARDED');
} elseif (\getenv('HTTP_X_COMING_FROM')) {
$proxyString = \getenv('HTTP_X_COMING_FROM');
} elseif (\getenv('HTTP_FORWARDED_FOR')) {
$proxyString = \getenv('HTTP_FORWARDED_FOR');
} elseif (\getenv('HTTP_FORWARDED')) {
$proxyString = \getenv('HTTP_FORWARDED');
} elseif (\getenv('HTTP_COMING_FROM')) {
$proxyString = \getenv('HTTP_COMING_FROM');
}
return $proxyString;
}
|
php
|
private static function getProxyString(): ?string
{
$proxyString = null;
if (\getenv('HTTP_CLIENT_IP')) {
$proxyString = \getenv('HTTP_CLIENT_IP');
} elseif (\getenv('HTTP_X_FORWARDED_FOR')) {
$proxyString = \getenv('HTTP_X_FORWARDED_FOR');
} elseif (\getenv('HTTP_X_FORWARDED')) {
$proxyString = \getenv('HTTP_X_FORWARDED');
} elseif (\getenv('HTTP_X_COMING_FROM')) {
$proxyString = \getenv('HTTP_X_COMING_FROM');
} elseif (\getenv('HTTP_FORWARDED_FOR')) {
$proxyString = \getenv('HTTP_FORWARDED_FOR');
} elseif (\getenv('HTTP_FORWARDED')) {
$proxyString = \getenv('HTTP_FORWARDED');
} elseif (\getenv('HTTP_COMING_FROM')) {
$proxyString = \getenv('HTTP_COMING_FROM');
}
return $proxyString;
}
|
[
"private",
"static",
"function",
"getProxyString",
"(",
")",
":",
"?",
"string",
"{",
"$",
"proxyString",
"=",
"null",
";",
"if",
"(",
"\\",
"getenv",
"(",
"'HTTP_CLIENT_IP'",
")",
")",
"{",
"$",
"proxyString",
"=",
"\\",
"getenv",
"(",
"'HTTP_CLIENT_IP'",
")",
";",
"}",
"elseif",
"(",
"\\",
"getenv",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
")",
"{",
"$",
"proxyString",
"=",
"\\",
"getenv",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
";",
"}",
"elseif",
"(",
"\\",
"getenv",
"(",
"'HTTP_X_FORWARDED'",
")",
")",
"{",
"$",
"proxyString",
"=",
"\\",
"getenv",
"(",
"'HTTP_X_FORWARDED'",
")",
";",
"}",
"elseif",
"(",
"\\",
"getenv",
"(",
"'HTTP_X_COMING_FROM'",
")",
")",
"{",
"$",
"proxyString",
"=",
"\\",
"getenv",
"(",
"'HTTP_X_COMING_FROM'",
")",
";",
"}",
"elseif",
"(",
"\\",
"getenv",
"(",
"'HTTP_FORWARDED_FOR'",
")",
")",
"{",
"$",
"proxyString",
"=",
"\\",
"getenv",
"(",
"'HTTP_FORWARDED_FOR'",
")",
";",
"}",
"elseif",
"(",
"\\",
"getenv",
"(",
"'HTTP_FORWARDED'",
")",
")",
"{",
"$",
"proxyString",
"=",
"\\",
"getenv",
"(",
"'HTTP_FORWARDED'",
")",
";",
"}",
"elseif",
"(",
"\\",
"getenv",
"(",
"'HTTP_COMING_FROM'",
")",
")",
"{",
"$",
"proxyString",
"=",
"\\",
"getenv",
"(",
"'HTTP_COMING_FROM'",
")",
";",
"}",
"return",
"$",
"proxyString",
";",
"}"
] |
Check and returns proxy string
@return null|string
|
[
"Check",
"and",
"returns",
"proxy",
"string"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Visitor/Ip.php#L39-L58
|
239,639
|
mszewcz/php-light-framework
|
src/Visitor/Ip.php
|
Ip.getFirstIP
|
private static function getFirstIP($proxyString = ''): ?string
{
\preg_match('/^(([0-9]{1,3}\.){3}[0-9]{1,3})/', $proxyString, $matches);
return (\is_array($matches) && isset($matches[1])) ? $matches[1] : null;
}
|
php
|
private static function getFirstIP($proxyString = ''): ?string
{
\preg_match('/^(([0-9]{1,3}\.){3}[0-9]{1,3})/', $proxyString, $matches);
return (\is_array($matches) && isset($matches[1])) ? $matches[1] : null;
}
|
[
"private",
"static",
"function",
"getFirstIP",
"(",
"$",
"proxyString",
"=",
"''",
")",
":",
"?",
"string",
"{",
"\\",
"preg_match",
"(",
"'/^(([0-9]{1,3}\\.){3}[0-9]{1,3})/'",
",",
"$",
"proxyString",
",",
"$",
"matches",
")",
";",
"return",
"(",
"\\",
"is_array",
"(",
"$",
"matches",
")",
"&&",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"?",
"$",
"matches",
"[",
"1",
"]",
":",
"null",
";",
"}"
] |
Checks for first IP in proxy string and returns it
@param string $proxyString
@return null|string
|
[
"Checks",
"for",
"first",
"IP",
"in",
"proxy",
"string",
"and",
"returns",
"it"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Visitor/Ip.php#L77-L81
|
239,640
|
mszewcz/php-light-framework
|
src/Visitor/Ip.php
|
Ip.getFullIpHost
|
private static function getFullIpHost($clientIpHost = null, $proxyIpHost = null): ?string
{
$fullIpHost = [];
if ($clientIpHost !== null) {
$fullIpHost[] = \sprintf('client: %s', $clientIpHost);
}
if ($proxyIpHost !== null) {
$fullIpHost[] = \sprintf('proxy: %s', $proxyIpHost);
}
return (\count($fullIpHost) > 0) ? \implode(', ', $fullIpHost) : null;
}
|
php
|
private static function getFullIpHost($clientIpHost = null, $proxyIpHost = null): ?string
{
$fullIpHost = [];
if ($clientIpHost !== null) {
$fullIpHost[] = \sprintf('client: %s', $clientIpHost);
}
if ($proxyIpHost !== null) {
$fullIpHost[] = \sprintf('proxy: %s', $proxyIpHost);
}
return (\count($fullIpHost) > 0) ? \implode(', ', $fullIpHost) : null;
}
|
[
"private",
"static",
"function",
"getFullIpHost",
"(",
"$",
"clientIpHost",
"=",
"null",
",",
"$",
"proxyIpHost",
"=",
"null",
")",
":",
"?",
"string",
"{",
"$",
"fullIpHost",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"clientIpHost",
"!==",
"null",
")",
"{",
"$",
"fullIpHost",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'client: %s'",
",",
"$",
"clientIpHost",
")",
";",
"}",
"if",
"(",
"$",
"proxyIpHost",
"!==",
"null",
")",
"{",
"$",
"fullIpHost",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'proxy: %s'",
",",
"$",
"proxyIpHost",
")",
";",
"}",
"return",
"(",
"\\",
"count",
"(",
"$",
"fullIpHost",
")",
">",
"0",
")",
"?",
"\\",
"implode",
"(",
"', '",
",",
"$",
"fullIpHost",
")",
":",
"null",
";",
"}"
] |
Returns full ip host string
@param null $clientIpHost
@param null $proxyIpHost
@return null|string
|
[
"Returns",
"full",
"ip",
"host",
"string"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Visitor/Ip.php#L90-L101
|
239,641
|
mszewcz/php-light-framework
|
src/Visitor/Ip.php
|
Ip.check
|
public static function check(): array
{
$remoteAddr = \getenv('REMOTE_ADDR') ?: null;
$httpVia = \getenv('HTTP_VIA') ?: null;
$proxyString = static::getProxyString();
$ipData = static::$ipData;
if ($remoteAddr !== null) {
if ($proxyString !== null) {
$clientIP = static::getFirstIP($proxyString);
$proxyIP = $remoteAddr;
$proxyHost = static::getHost($proxyIP);
if ($clientIP !== null) {
$clientHost = static::getHost($clientIP);
$ipData['CLIENT_IP'] = $clientIP;
$ipData['CLIENT_HOST'] = $clientHost;
$ipData['CLIENT_IP_HOST'] = \sprintf('%s (%s)', $clientIP, $clientHost);
}
$ipData['PROXY_IP'] = $proxyIP;
$ipData['PROXY_HOST'] = $proxyHost;
$ipData['PROXY_IP_HOST'] = \sprintf('%s (%s)', $proxyIP, $proxyHost);
$ipData['PROXY_STRING'] = $proxyString;
} elseif ($httpVia !== null) {
$proxyHost = static::getHost($remoteAddr);
$ipData['PROXY_IP'] = $remoteAddr;
$ipData['PROXY_HOST'] = $proxyHost;
$ipData['PROXY_IP_HOST'] = \sprintf('%s (%s)', $remoteAddr, $proxyHost);
$ipData['HTTP_VIA'] = $httpVia;
} else {
$clientHost = static::getHost($remoteAddr);
$ipData['CLIENT_IP'] = $remoteAddr;
$ipData['CLIENT_HOST'] = $clientHost;
$ipData['CLIENT_IP_HOST'] = \sprintf('%s (%s)', $remoteAddr, $clientHost);
}
$ipData['FULL_IP_HOST'] = static::getFullIpHost($ipData['CLIENT_IP_HOST'], $ipData['PROXY_IP_HOST']);
}
return $ipData;
}
|
php
|
public static function check(): array
{
$remoteAddr = \getenv('REMOTE_ADDR') ?: null;
$httpVia = \getenv('HTTP_VIA') ?: null;
$proxyString = static::getProxyString();
$ipData = static::$ipData;
if ($remoteAddr !== null) {
if ($proxyString !== null) {
$clientIP = static::getFirstIP($proxyString);
$proxyIP = $remoteAddr;
$proxyHost = static::getHost($proxyIP);
if ($clientIP !== null) {
$clientHost = static::getHost($clientIP);
$ipData['CLIENT_IP'] = $clientIP;
$ipData['CLIENT_HOST'] = $clientHost;
$ipData['CLIENT_IP_HOST'] = \sprintf('%s (%s)', $clientIP, $clientHost);
}
$ipData['PROXY_IP'] = $proxyIP;
$ipData['PROXY_HOST'] = $proxyHost;
$ipData['PROXY_IP_HOST'] = \sprintf('%s (%s)', $proxyIP, $proxyHost);
$ipData['PROXY_STRING'] = $proxyString;
} elseif ($httpVia !== null) {
$proxyHost = static::getHost($remoteAddr);
$ipData['PROXY_IP'] = $remoteAddr;
$ipData['PROXY_HOST'] = $proxyHost;
$ipData['PROXY_IP_HOST'] = \sprintf('%s (%s)', $remoteAddr, $proxyHost);
$ipData['HTTP_VIA'] = $httpVia;
} else {
$clientHost = static::getHost($remoteAddr);
$ipData['CLIENT_IP'] = $remoteAddr;
$ipData['CLIENT_HOST'] = $clientHost;
$ipData['CLIENT_IP_HOST'] = \sprintf('%s (%s)', $remoteAddr, $clientHost);
}
$ipData['FULL_IP_HOST'] = static::getFullIpHost($ipData['CLIENT_IP_HOST'], $ipData['PROXY_IP_HOST']);
}
return $ipData;
}
|
[
"public",
"static",
"function",
"check",
"(",
")",
":",
"array",
"{",
"$",
"remoteAddr",
"=",
"\\",
"getenv",
"(",
"'REMOTE_ADDR'",
")",
"?",
":",
"null",
";",
"$",
"httpVia",
"=",
"\\",
"getenv",
"(",
"'HTTP_VIA'",
")",
"?",
":",
"null",
";",
"$",
"proxyString",
"=",
"static",
"::",
"getProxyString",
"(",
")",
";",
"$",
"ipData",
"=",
"static",
"::",
"$",
"ipData",
";",
"if",
"(",
"$",
"remoteAddr",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"proxyString",
"!==",
"null",
")",
"{",
"$",
"clientIP",
"=",
"static",
"::",
"getFirstIP",
"(",
"$",
"proxyString",
")",
";",
"$",
"proxyIP",
"=",
"$",
"remoteAddr",
";",
"$",
"proxyHost",
"=",
"static",
"::",
"getHost",
"(",
"$",
"proxyIP",
")",
";",
"if",
"(",
"$",
"clientIP",
"!==",
"null",
")",
"{",
"$",
"clientHost",
"=",
"static",
"::",
"getHost",
"(",
"$",
"clientIP",
")",
";",
"$",
"ipData",
"[",
"'CLIENT_IP'",
"]",
"=",
"$",
"clientIP",
";",
"$",
"ipData",
"[",
"'CLIENT_HOST'",
"]",
"=",
"$",
"clientHost",
";",
"$",
"ipData",
"[",
"'CLIENT_IP_HOST'",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"clientIP",
",",
"$",
"clientHost",
")",
";",
"}",
"$",
"ipData",
"[",
"'PROXY_IP'",
"]",
"=",
"$",
"proxyIP",
";",
"$",
"ipData",
"[",
"'PROXY_HOST'",
"]",
"=",
"$",
"proxyHost",
";",
"$",
"ipData",
"[",
"'PROXY_IP_HOST'",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"proxyIP",
",",
"$",
"proxyHost",
")",
";",
"$",
"ipData",
"[",
"'PROXY_STRING'",
"]",
"=",
"$",
"proxyString",
";",
"}",
"elseif",
"(",
"$",
"httpVia",
"!==",
"null",
")",
"{",
"$",
"proxyHost",
"=",
"static",
"::",
"getHost",
"(",
"$",
"remoteAddr",
")",
";",
"$",
"ipData",
"[",
"'PROXY_IP'",
"]",
"=",
"$",
"remoteAddr",
";",
"$",
"ipData",
"[",
"'PROXY_HOST'",
"]",
"=",
"$",
"proxyHost",
";",
"$",
"ipData",
"[",
"'PROXY_IP_HOST'",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"remoteAddr",
",",
"$",
"proxyHost",
")",
";",
"$",
"ipData",
"[",
"'HTTP_VIA'",
"]",
"=",
"$",
"httpVia",
";",
"}",
"else",
"{",
"$",
"clientHost",
"=",
"static",
"::",
"getHost",
"(",
"$",
"remoteAddr",
")",
";",
"$",
"ipData",
"[",
"'CLIENT_IP'",
"]",
"=",
"$",
"remoteAddr",
";",
"$",
"ipData",
"[",
"'CLIENT_HOST'",
"]",
"=",
"$",
"clientHost",
";",
"$",
"ipData",
"[",
"'CLIENT_IP_HOST'",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"remoteAddr",
",",
"$",
"clientHost",
")",
";",
"}",
"$",
"ipData",
"[",
"'FULL_IP_HOST'",
"]",
"=",
"static",
"::",
"getFullIpHost",
"(",
"$",
"ipData",
"[",
"'CLIENT_IP_HOST'",
"]",
",",
"$",
"ipData",
"[",
"'PROXY_IP_HOST'",
"]",
")",
";",
"}",
"return",
"$",
"ipData",
";",
"}"
] |
Checks for visitor IP address, proxy address and returns them
@return array
|
[
"Checks",
"for",
"visitor",
"IP",
"address",
"proxy",
"address",
"and",
"returns",
"them"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Visitor/Ip.php#L108-L150
|
239,642
|
jagilpe/entity-list-bundle
|
Twig/JagilpeEntityListExtension.php
|
JagilpeEntityListExtension.getAttributesString
|
public function getAttributesString(array $attributes = array())
{
$attributesString = '';
foreach ($attributes as $name => $values) {
$value = is_array($values) ? implode(' ', $values) : $values;
$attributesString .= ' '.$name.'="'.$value.'"';
}
return $attributesString;
}
|
php
|
public function getAttributesString(array $attributes = array())
{
$attributesString = '';
foreach ($attributes as $name => $values) {
$value = is_array($values) ? implode(' ', $values) : $values;
$attributesString .= ' '.$name.'="'.$value.'"';
}
return $attributesString;
}
|
[
"public",
"function",
"getAttributesString",
"(",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attributesString",
"=",
"''",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"$",
"value",
"=",
"is_array",
"(",
"$",
"values",
")",
"?",
"implode",
"(",
"' '",
",",
"$",
"values",
")",
":",
"$",
"values",
";",
"$",
"attributesString",
".=",
"' '",
".",
"$",
"name",
".",
"'=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"}",
"return",
"$",
"attributesString",
";",
"}"
] |
Returns an string for the given attributes ready to be places in an html element
@param array $attributes
@return string
|
[
"Returns",
"an",
"string",
"for",
"the",
"given",
"attributes",
"ready",
"to",
"be",
"places",
"in",
"an",
"html",
"element"
] |
54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc
|
https://github.com/jagilpe/entity-list-bundle/blob/54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc/Twig/JagilpeEntityListExtension.php#L67-L77
|
239,643
|
Sowapps/orpheus-sqladapter
|
src/SQLAdapter/SQLAdapterMySQL.php
|
SQLAdapterMySQL.update
|
public function update(array $options=array()) {
$options += self::$updateDefaults;
if( empty($options['table']) ) {
throw new Exception('Empty table option');
}
if( empty($options['what']) ) {
throw new Exception('No field');
}
$OPTIONS = '';
$OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : '';
$OPTIONS .= (!empty($options['ignore'])) ? ' IGNORE' : '';
// if( is_array($options['what']) ) {
// $string = '';
// foreach( $options['what'] as $key => $value ) {
// $string .= ($string ? ', ' : '').static::escapeIdentifier($key).'='.static::formatValue($value);
// }
// $options['what'] = $string;
// }
$WHAT = $this->formatFieldList($options['what']);
$WC = ( !empty($options['where']) ) ? 'WHERE '.$options['where'] : '';
$ORDERBY = ( !empty($options['orderby']) ) ? 'ORDER BY '.$options['orderby'] : '';
$LIMIT = ( $options['number'] > 0 ) ? 'LIMIT '.
( ($options['offset'] > 0) ? $options['offset'].', ' : '' ).$options['number'] : '';
$TABLE = static::escapeIdentifier($options['table']);
$QUERY = "UPDATE {$OPTIONS} {$TABLE} SET {$WHAT} {$WC} {$ORDERBY} {$LIMIT}";
if( $options['output'] == static::SQLQUERY ) {
return $QUERY;
}
return $this->query($QUERY, PDOEXEC);
}
|
php
|
public function update(array $options=array()) {
$options += self::$updateDefaults;
if( empty($options['table']) ) {
throw new Exception('Empty table option');
}
if( empty($options['what']) ) {
throw new Exception('No field');
}
$OPTIONS = '';
$OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : '';
$OPTIONS .= (!empty($options['ignore'])) ? ' IGNORE' : '';
// if( is_array($options['what']) ) {
// $string = '';
// foreach( $options['what'] as $key => $value ) {
// $string .= ($string ? ', ' : '').static::escapeIdentifier($key).'='.static::formatValue($value);
// }
// $options['what'] = $string;
// }
$WHAT = $this->formatFieldList($options['what']);
$WC = ( !empty($options['where']) ) ? 'WHERE '.$options['where'] : '';
$ORDERBY = ( !empty($options['orderby']) ) ? 'ORDER BY '.$options['orderby'] : '';
$LIMIT = ( $options['number'] > 0 ) ? 'LIMIT '.
( ($options['offset'] > 0) ? $options['offset'].', ' : '' ).$options['number'] : '';
$TABLE = static::escapeIdentifier($options['table']);
$QUERY = "UPDATE {$OPTIONS} {$TABLE} SET {$WHAT} {$WC} {$ORDERBY} {$LIMIT}";
if( $options['output'] == static::SQLQUERY ) {
return $QUERY;
}
return $this->query($QUERY, PDOEXEC);
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"+=",
"self",
"::",
"$",
"updateDefaults",
";",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'table'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Empty table option'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'what'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No field'",
")",
";",
"}",
"$",
"OPTIONS",
"=",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'lowpriority'",
"]",
")",
")",
"?",
"' LOW_PRIORITY'",
":",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'ignore'",
"]",
")",
")",
"?",
"' IGNORE'",
":",
"''",
";",
"// \t\tif( is_array($options['what']) ) {",
"// \t\t\t$string\t= '';",
"// \t\t\tforeach( $options['what'] as $key => $value ) {",
"// \t\t\t\t$string .= ($string ? ', ' : '').static::escapeIdentifier($key).'='.static::formatValue($value);",
"// \t\t\t}",
"// \t\t\t$options['what'] = $string;",
"// \t\t}",
"$",
"WHAT",
"=",
"$",
"this",
"->",
"formatFieldList",
"(",
"$",
"options",
"[",
"'what'",
"]",
")",
";",
"$",
"WC",
"=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'where'",
"]",
")",
")",
"?",
"'WHERE '",
".",
"$",
"options",
"[",
"'where'",
"]",
":",
"''",
";",
"$",
"ORDERBY",
"=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'orderby'",
"]",
")",
")",
"?",
"'ORDER BY '",
".",
"$",
"options",
"[",
"'orderby'",
"]",
":",
"''",
";",
"$",
"LIMIT",
"=",
"(",
"$",
"options",
"[",
"'number'",
"]",
">",
"0",
")",
"?",
"'LIMIT '",
".",
"(",
"(",
"$",
"options",
"[",
"'offset'",
"]",
">",
"0",
")",
"?",
"$",
"options",
"[",
"'offset'",
"]",
".",
"', '",
":",
"''",
")",
".",
"$",
"options",
"[",
"'number'",
"]",
":",
"''",
";",
"$",
"TABLE",
"=",
"static",
"::",
"escapeIdentifier",
"(",
"$",
"options",
"[",
"'table'",
"]",
")",
";",
"$",
"QUERY",
"=",
"\"UPDATE {$OPTIONS} {$TABLE} SET {$WHAT} {$WC} {$ORDERBY} {$LIMIT}\"",
";",
"if",
"(",
"$",
"options",
"[",
"'output'",
"]",
"==",
"static",
"::",
"SQLQUERY",
")",
"{",
"return",
"$",
"QUERY",
";",
"}",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"QUERY",
",",
"PDOEXEC",
")",
";",
"}"
] |
Update something in database
@param array $options The options used to build the query.
@return int The number of affected rows.
@see http://dev.mysql.com/doc/refman/5.0/en/update.html
Using pdo_query(), It parses the query from an array to a UPDATE query.
|
[
"Update",
"something",
"in",
"database"
] |
d7730e70f84d7d877a688ff4408cefea34117a1c
|
https://github.com/Sowapps/orpheus-sqladapter/blob/d7730e70f84d7d877a688ff4408cefea34117a1c/src/SQLAdapter/SQLAdapterMySQL.php#L156-L188
|
239,644
|
Sowapps/orpheus-sqladapter
|
src/SQLAdapter/SQLAdapterMySQL.php
|
SQLAdapterMySQL.insert
|
public function insert(array $options=array()) {
$options += self::$insertDefaults;
if( empty($options['table']) ) {
throw new Exception('Empty table option');
}
if( empty($options['what']) ) {
throw new Exception('No field');
}
$OPTIONS = '';
$OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : (!empty($options['delayed'])) ? ' DELAYED' : '';
$OPTIONS .= (!empty($options['ignore'])) ? ' IGNORE' : '';
$OPTIONS .= (!empty($options['into'])) ? ' INTO' : '';
$COLS = $WHAT = '';
//Is an array
if( is_array($options['what']) ) {
//Is an indexed array of fields Arrays
if( !empty($options['what'][0]) ) {
// Quoted as escapeIdentifier()
$COLS = '(`'.implode('`, `', array_keys($options['what'][0])).'`)';
foreach($options['what'] as $row) {
$WHAT .= (!empty($WHAT) ? ', ' : '').'('.implode(', ', $row).')';
}
$WHAT = 'VALUES '.$WHAT;
//Is associative fields Arrays
} else {
// $WHAT = 'SET '.parseFields($options['what'], '`');
$WHAT = 'SET '.$this->formatFieldList($options['what']);
}
//Is a string
} else {
$WHAT = $options['what'];
}
$TABLE = static::escapeIdentifier($options['table']);
$QUERY = "INSERT {$OPTIONS} {$TABLE} {$COLS} {$WHAT}";
if( $options['output'] == static::SQLQUERY ) {
return $QUERY;
}
return $this->query($QUERY, PDOEXEC);
}
|
php
|
public function insert(array $options=array()) {
$options += self::$insertDefaults;
if( empty($options['table']) ) {
throw new Exception('Empty table option');
}
if( empty($options['what']) ) {
throw new Exception('No field');
}
$OPTIONS = '';
$OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : (!empty($options['delayed'])) ? ' DELAYED' : '';
$OPTIONS .= (!empty($options['ignore'])) ? ' IGNORE' : '';
$OPTIONS .= (!empty($options['into'])) ? ' INTO' : '';
$COLS = $WHAT = '';
//Is an array
if( is_array($options['what']) ) {
//Is an indexed array of fields Arrays
if( !empty($options['what'][0]) ) {
// Quoted as escapeIdentifier()
$COLS = '(`'.implode('`, `', array_keys($options['what'][0])).'`)';
foreach($options['what'] as $row) {
$WHAT .= (!empty($WHAT) ? ', ' : '').'('.implode(', ', $row).')';
}
$WHAT = 'VALUES '.$WHAT;
//Is associative fields Arrays
} else {
// $WHAT = 'SET '.parseFields($options['what'], '`');
$WHAT = 'SET '.$this->formatFieldList($options['what']);
}
//Is a string
} else {
$WHAT = $options['what'];
}
$TABLE = static::escapeIdentifier($options['table']);
$QUERY = "INSERT {$OPTIONS} {$TABLE} {$COLS} {$WHAT}";
if( $options['output'] == static::SQLQUERY ) {
return $QUERY;
}
return $this->query($QUERY, PDOEXEC);
}
|
[
"public",
"function",
"insert",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"+=",
"self",
"::",
"$",
"insertDefaults",
";",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'table'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Empty table option'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'what'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No field'",
")",
";",
"}",
"$",
"OPTIONS",
"=",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'lowpriority'",
"]",
")",
")",
"?",
"' LOW_PRIORITY'",
":",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'delayed'",
"]",
")",
")",
"?",
"' DELAYED'",
":",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'ignore'",
"]",
")",
")",
"?",
"' IGNORE'",
":",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'into'",
"]",
")",
")",
"?",
"' INTO'",
":",
"''",
";",
"$",
"COLS",
"=",
"$",
"WHAT",
"=",
"''",
";",
"//Is an array",
"if",
"(",
"is_array",
"(",
"$",
"options",
"[",
"'what'",
"]",
")",
")",
"{",
"//Is an indexed array of fields Arrays",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'what'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"// Quoted as escapeIdentifier()",
"$",
"COLS",
"=",
"'(`'",
".",
"implode",
"(",
"'`, `'",
",",
"array_keys",
"(",
"$",
"options",
"[",
"'what'",
"]",
"[",
"0",
"]",
")",
")",
".",
"'`)'",
";",
"foreach",
"(",
"$",
"options",
"[",
"'what'",
"]",
"as",
"$",
"row",
")",
"{",
"$",
"WHAT",
".=",
"(",
"!",
"empty",
"(",
"$",
"WHAT",
")",
"?",
"', '",
":",
"''",
")",
".",
"'('",
".",
"implode",
"(",
"', '",
",",
"$",
"row",
")",
".",
"')'",
";",
"}",
"$",
"WHAT",
"=",
"'VALUES '",
".",
"$",
"WHAT",
";",
"//Is associative fields Arrays",
"}",
"else",
"{",
"// \t\t\t\t$WHAT\t= 'SET '.parseFields($options['what'], '`');",
"$",
"WHAT",
"=",
"'SET '",
".",
"$",
"this",
"->",
"formatFieldList",
"(",
"$",
"options",
"[",
"'what'",
"]",
")",
";",
"}",
"//Is a string",
"}",
"else",
"{",
"$",
"WHAT",
"=",
"$",
"options",
"[",
"'what'",
"]",
";",
"}",
"$",
"TABLE",
"=",
"static",
"::",
"escapeIdentifier",
"(",
"$",
"options",
"[",
"'table'",
"]",
")",
";",
"$",
"QUERY",
"=",
"\"INSERT {$OPTIONS} {$TABLE} {$COLS} {$WHAT}\"",
";",
"if",
"(",
"$",
"options",
"[",
"'output'",
"]",
"==",
"static",
"::",
"SQLQUERY",
")",
"{",
"return",
"$",
"QUERY",
";",
"}",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"QUERY",
",",
"PDOEXEC",
")",
";",
"}"
] |
Insert something in database
@param array $options The options used to build the query.
@return int The number of inserted rows.
It parses the query from an array to a INSERT query.
Accept only the String syntax for what option.
|
[
"Insert",
"something",
"in",
"database"
] |
d7730e70f84d7d877a688ff4408cefea34117a1c
|
https://github.com/Sowapps/orpheus-sqladapter/blob/d7730e70f84d7d877a688ff4408cefea34117a1c/src/SQLAdapter/SQLAdapterMySQL.php#L199-L240
|
239,645
|
Sowapps/orpheus-sqladapter
|
src/SQLAdapter/SQLAdapterMySQL.php
|
SQLAdapterMySQL.delete
|
public function delete(array $options=array()) {
$options += self::$deleteDefaults;
if( empty($options['table']) ) {
throw new Exception('Empty table option');
}
$OPTIONS = '';
$OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : '';
$OPTIONS .= (!empty($options['quick'])) ? ' QUICK' : '';
$OPTIONS .= (!empty($options['ignore'])) ? ' IGNORE' : '';
$WC = ( !empty($options['where']) ) ? 'WHERE '.$options['where'] : '';
$ORDERBY = ( !empty($options['orderby']) ) ? 'ORDER BY '.$options['orderby'] : '';
$LIMIT = ( $options['number'] > 0 ) ? 'LIMIT '.
( ($options['offset'] > 0) ? $options['offset'].', ' : '' ).$options['number'] : '';
$TABLE = static::escapeIdentifier($options['table']);
$QUERY = "DELETE {$OPTIONS} FROM {$TABLE} {$WC} {$ORDERBY} {$LIMIT}";
if( $options['output'] == static::SQLQUERY ) {
return $QUERY;
}
return $this->query($QUERY, PDOEXEC);
}
|
php
|
public function delete(array $options=array()) {
$options += self::$deleteDefaults;
if( empty($options['table']) ) {
throw new Exception('Empty table option');
}
$OPTIONS = '';
$OPTIONS .= (!empty($options['lowpriority'])) ? ' LOW_PRIORITY' : '';
$OPTIONS .= (!empty($options['quick'])) ? ' QUICK' : '';
$OPTIONS .= (!empty($options['ignore'])) ? ' IGNORE' : '';
$WC = ( !empty($options['where']) ) ? 'WHERE '.$options['where'] : '';
$ORDERBY = ( !empty($options['orderby']) ) ? 'ORDER BY '.$options['orderby'] : '';
$LIMIT = ( $options['number'] > 0 ) ? 'LIMIT '.
( ($options['offset'] > 0) ? $options['offset'].', ' : '' ).$options['number'] : '';
$TABLE = static::escapeIdentifier($options['table']);
$QUERY = "DELETE {$OPTIONS} FROM {$TABLE} {$WC} {$ORDERBY} {$LIMIT}";
if( $options['output'] == static::SQLQUERY ) {
return $QUERY;
}
return $this->query($QUERY, PDOEXEC);
}
|
[
"public",
"function",
"delete",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"+=",
"self",
"::",
"$",
"deleteDefaults",
";",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'table'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Empty table option'",
")",
";",
"}",
"$",
"OPTIONS",
"=",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'lowpriority'",
"]",
")",
")",
"?",
"' LOW_PRIORITY'",
":",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'quick'",
"]",
")",
")",
"?",
"' QUICK'",
":",
"''",
";",
"$",
"OPTIONS",
".=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'ignore'",
"]",
")",
")",
"?",
"' IGNORE'",
":",
"''",
";",
"$",
"WC",
"=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'where'",
"]",
")",
")",
"?",
"'WHERE '",
".",
"$",
"options",
"[",
"'where'",
"]",
":",
"''",
";",
"$",
"ORDERBY",
"=",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'orderby'",
"]",
")",
")",
"?",
"'ORDER BY '",
".",
"$",
"options",
"[",
"'orderby'",
"]",
":",
"''",
";",
"$",
"LIMIT",
"=",
"(",
"$",
"options",
"[",
"'number'",
"]",
">",
"0",
")",
"?",
"'LIMIT '",
".",
"(",
"(",
"$",
"options",
"[",
"'offset'",
"]",
">",
"0",
")",
"?",
"$",
"options",
"[",
"'offset'",
"]",
".",
"', '",
":",
"''",
")",
".",
"$",
"options",
"[",
"'number'",
"]",
":",
"''",
";",
"$",
"TABLE",
"=",
"static",
"::",
"escapeIdentifier",
"(",
"$",
"options",
"[",
"'table'",
"]",
")",
";",
"$",
"QUERY",
"=",
"\"DELETE {$OPTIONS} FROM {$TABLE} {$WC} {$ORDERBY} {$LIMIT}\"",
";",
"if",
"(",
"$",
"options",
"[",
"'output'",
"]",
"==",
"static",
"::",
"SQLQUERY",
")",
"{",
"return",
"$",
"QUERY",
";",
"}",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"QUERY",
",",
"PDOEXEC",
")",
";",
"}"
] |
Delete something in database
@param array $options The options used to build the query.
@return int The number of deleted rows.
It parses the query from an array to a DELETE query.
|
[
"Delete",
"something",
"in",
"database"
] |
d7730e70f84d7d877a688ff4408cefea34117a1c
|
https://github.com/Sowapps/orpheus-sqladapter/blob/d7730e70f84d7d877a688ff4408cefea34117a1c/src/SQLAdapter/SQLAdapterMySQL.php#L250-L270
|
239,646
|
unyx/console
|
terminals/Posix.php
|
Posix.getDimensionsFromTput
|
protected function getDimensionsFromTput() : ?array
{
if (empty($output = $this->execute('tput cols && tput lines'))) {
return null;
}
// tput will have returned the values on separate lines, so let's just explode.
$output = explode("\n", $output);
return [
'width' => (int) $output[0],
'height'=> (int) $output[1]
];
}
|
php
|
protected function getDimensionsFromTput() : ?array
{
if (empty($output = $this->execute('tput cols && tput lines'))) {
return null;
}
// tput will have returned the values on separate lines, so let's just explode.
$output = explode("\n", $output);
return [
'width' => (int) $output[0],
'height'=> (int) $output[1]
];
}
|
[
"protected",
"function",
"getDimensionsFromTput",
"(",
")",
":",
"?",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"output",
"=",
"$",
"this",
"->",
"execute",
"(",
"'tput cols && tput lines'",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"// tput will have returned the values on separate lines, so let's just explode.",
"$",
"output",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"output",
")",
";",
"return",
"[",
"'width'",
"=>",
"(",
"int",
")",
"$",
"output",
"[",
"0",
"]",
",",
"'height'",
"=>",
"(",
"int",
")",
"$",
"output",
"[",
"1",
"]",
"]",
";",
"}"
] |
Executes a combined 'tput' call and parses the results in order to determine the dimensions of the terminal.
@return array Either an array containing two keys - 'width' and 'height' or null if the data couldn't
be parsed to retrieve anything useful.
|
[
"Executes",
"a",
"combined",
"tput",
"call",
"and",
"parses",
"the",
"results",
"in",
"order",
"to",
"determine",
"the",
"dimensions",
"of",
"the",
"terminal",
"."
] |
b4a76e08bbb5428b0349c0ec4259a914f81a2957
|
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/terminals/Posix.php#L63-L76
|
239,647
|
FDT2k/noctis-core
|
src/Service/UserSessionService.php
|
UserSessionService.recover_session
|
function recover_session($token=''){
//$r = Env::getRequest();
$key = Env::getConfig("jwt")->get('key');
$expiration = Env::getConfig("jwt")->get('token_expiration');
$cookie_key= Env::getConfig("jwt")->get('cookie_key');
if(empty($key) || empty($expiration) || empty($cookie_key)){
throw new Exception("critical security failure. Please configure module",00);
}
//retrieve user token // priority order -> cookie-> headers
$result = false;
if(empty($token)){
$token = (isset($_COOKIE[$cookie_key]))? $_COOKIE[$cookie_key] : Env::getRequest()->getToken();
}
// var_dump($_COOKIE);
try{
//var_dump($token);
$decoded = array();
if(!empty($token)){
$decoded = JWT::decode($token, $key, array('HS256'));
if($decoded){
//authenticated
$result = true;
$this->setToken($token);
// var_dump($token);
if(Env::getConfig("jwt")->get('auto_renew')){
$this->create_session((array)$decoded->data);
}
//$key = $this->getEntity()->onePKName();
// $this->load_user($decoded->data->$key);
}
}
}
catch(\Firebase\JWT\ExpiredException $e){
$this->setError("Expired token, please log in again",101);
return false;
}
catch( \Exception $e){
$this->setError("Invalid token ".var_export($e,true),102);
return false;
}finally{
if ($result) {
// $this->logout();
$this->setDefaultDatas((array)$decoded->data);
return true;
}
}
return false;
}
|
php
|
function recover_session($token=''){
//$r = Env::getRequest();
$key = Env::getConfig("jwt")->get('key');
$expiration = Env::getConfig("jwt")->get('token_expiration');
$cookie_key= Env::getConfig("jwt")->get('cookie_key');
if(empty($key) || empty($expiration) || empty($cookie_key)){
throw new Exception("critical security failure. Please configure module",00);
}
//retrieve user token // priority order -> cookie-> headers
$result = false;
if(empty($token)){
$token = (isset($_COOKIE[$cookie_key]))? $_COOKIE[$cookie_key] : Env::getRequest()->getToken();
}
// var_dump($_COOKIE);
try{
//var_dump($token);
$decoded = array();
if(!empty($token)){
$decoded = JWT::decode($token, $key, array('HS256'));
if($decoded){
//authenticated
$result = true;
$this->setToken($token);
// var_dump($token);
if(Env::getConfig("jwt")->get('auto_renew')){
$this->create_session((array)$decoded->data);
}
//$key = $this->getEntity()->onePKName();
// $this->load_user($decoded->data->$key);
}
}
}
catch(\Firebase\JWT\ExpiredException $e){
$this->setError("Expired token, please log in again",101);
return false;
}
catch( \Exception $e){
$this->setError("Invalid token ".var_export($e,true),102);
return false;
}finally{
if ($result) {
// $this->logout();
$this->setDefaultDatas((array)$decoded->data);
return true;
}
}
return false;
}
|
[
"function",
"recover_session",
"(",
"$",
"token",
"=",
"''",
")",
"{",
"//$r = Env::getRequest();",
"$",
"key",
"=",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'key'",
")",
";",
"$",
"expiration",
"=",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'token_expiration'",
")",
";",
"$",
"cookie_key",
"=",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'cookie_key'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
"||",
"empty",
"(",
"$",
"expiration",
")",
"||",
"empty",
"(",
"$",
"cookie_key",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"critical security failure. Please configure module\"",
",",
"00",
")",
";",
"}",
"//retrieve user token // priority order -> cookie-> headers",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"empty",
"(",
"$",
"token",
")",
")",
"{",
"$",
"token",
"=",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"cookie_key",
"]",
")",
")",
"?",
"$",
"_COOKIE",
"[",
"$",
"cookie_key",
"]",
":",
"Env",
"::",
"getRequest",
"(",
")",
"->",
"getToken",
"(",
")",
";",
"}",
"//\tvar_dump($_COOKIE);",
"try",
"{",
"//var_dump($token);",
"$",
"decoded",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"token",
")",
")",
"{",
"$",
"decoded",
"=",
"JWT",
"::",
"decode",
"(",
"$",
"token",
",",
"$",
"key",
",",
"array",
"(",
"'HS256'",
")",
")",
";",
"if",
"(",
"$",
"decoded",
")",
"{",
"//authenticated",
"$",
"result",
"=",
"true",
";",
"$",
"this",
"->",
"setToken",
"(",
"$",
"token",
")",
";",
"//\tvar_dump($token);",
"if",
"(",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'auto_renew'",
")",
")",
"{",
"$",
"this",
"->",
"create_session",
"(",
"(",
"array",
")",
"$",
"decoded",
"->",
"data",
")",
";",
"}",
"//$key = $this->getEntity()->onePKName();",
"//\t$this->load_user($decoded->data->$key);",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Firebase",
"\\",
"JWT",
"\\",
"ExpiredException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"\"Expired token, please log in again\"",
",",
"101",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"\"Invalid token \"",
".",
"var_export",
"(",
"$",
"e",
",",
"true",
")",
",",
"102",
")",
";",
"return",
"false",
";",
"}",
"finally",
"{",
"if",
"(",
"$",
"result",
")",
"{",
"//\t$this->logout();",
"$",
"this",
"->",
"setDefaultDatas",
"(",
"(",
"array",
")",
"$",
"decoded",
"->",
"data",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Recover a jwt user session from a cookie
|
[
"Recover",
"a",
"jwt",
"user",
"session",
"from",
"a",
"cookie"
] |
482763dd92efcf3d96d13939cdb745763416f3b5
|
https://github.com/FDT2k/noctis-core/blob/482763dd92efcf3d96d13939cdb745763416f3b5/src/Service/UserSessionService.php#L17-L76
|
239,648
|
FDT2k/noctis-core
|
src/Service/UserSessionService.php
|
UserSessionService.create_session
|
function create_session($data){
$key = Env::getConfig("jwt")->get('key');
$expiration = Env::getConfig("jwt")->get('token_expiration');
$cookie_key= Env::getConfig("jwt")->get('cookie_key');
$token = array(
"iss" => $_SERVER['HTTP_HOST'],
"iat" => time(),
"nbf" => time(),
"exp" => time()+($expiration),
"data" => $data
);
$jwt = JWT::encode($token, $key);
$this->setToken($jwt);
$_SESSION[$cookie_key]=$jwt;
setcookie($cookie_key,$jwt,time()+$expiration,'/');
//var_dump($cookie_key);
Env::getRequest()->setToken($jwt);
$this->setDefaultDatas($data);
}
|
php
|
function create_session($data){
$key = Env::getConfig("jwt")->get('key');
$expiration = Env::getConfig("jwt")->get('token_expiration');
$cookie_key= Env::getConfig("jwt")->get('cookie_key');
$token = array(
"iss" => $_SERVER['HTTP_HOST'],
"iat" => time(),
"nbf" => time(),
"exp" => time()+($expiration),
"data" => $data
);
$jwt = JWT::encode($token, $key);
$this->setToken($jwt);
$_SESSION[$cookie_key]=$jwt;
setcookie($cookie_key,$jwt,time()+$expiration,'/');
//var_dump($cookie_key);
Env::getRequest()->setToken($jwt);
$this->setDefaultDatas($data);
}
|
[
"function",
"create_session",
"(",
"$",
"data",
")",
"{",
"$",
"key",
"=",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'key'",
")",
";",
"$",
"expiration",
"=",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'token_expiration'",
")",
";",
"$",
"cookie_key",
"=",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'cookie_key'",
")",
";",
"$",
"token",
"=",
"array",
"(",
"\"iss\"",
"=>",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
",",
"\"iat\"",
"=>",
"time",
"(",
")",
",",
"\"nbf\"",
"=>",
"time",
"(",
")",
",",
"\"exp\"",
"=>",
"time",
"(",
")",
"+",
"(",
"$",
"expiration",
")",
",",
"\"data\"",
"=>",
"$",
"data",
")",
";",
"$",
"jwt",
"=",
"JWT",
"::",
"encode",
"(",
"$",
"token",
",",
"$",
"key",
")",
";",
"$",
"this",
"->",
"setToken",
"(",
"$",
"jwt",
")",
";",
"$",
"_SESSION",
"[",
"$",
"cookie_key",
"]",
"=",
"$",
"jwt",
";",
"setcookie",
"(",
"$",
"cookie_key",
",",
"$",
"jwt",
",",
"time",
"(",
")",
"+",
"$",
"expiration",
",",
"'/'",
")",
";",
"//var_dump($cookie_key);",
"Env",
"::",
"getRequest",
"(",
")",
"->",
"setToken",
"(",
"$",
"jwt",
")",
";",
"$",
"this",
"->",
"setDefaultDatas",
"(",
"$",
"data",
")",
";",
"}"
] |
Create a jwt user session
|
[
"Create",
"a",
"jwt",
"user",
"session"
] |
482763dd92efcf3d96d13939cdb745763416f3b5
|
https://github.com/FDT2k/noctis-core/blob/482763dd92efcf3d96d13939cdb745763416f3b5/src/Service/UserSessionService.php#L82-L103
|
239,649
|
FDT2k/noctis-core
|
src/Service/UserSessionService.php
|
UserSessionService.destroy
|
function destroy(){
$cookie_key= Env::getConfig("jwt")->get('cookie_key');
setcookie($cookie_key,'',time()-10000,'/');
unset($_SESSION[$cookie_key]);
session_destroy();
}
|
php
|
function destroy(){
$cookie_key= Env::getConfig("jwt")->get('cookie_key');
setcookie($cookie_key,'',time()-10000,'/');
unset($_SESSION[$cookie_key]);
session_destroy();
}
|
[
"function",
"destroy",
"(",
")",
"{",
"$",
"cookie_key",
"=",
"Env",
"::",
"getConfig",
"(",
"\"jwt\"",
")",
"->",
"get",
"(",
"'cookie_key'",
")",
";",
"setcookie",
"(",
"$",
"cookie_key",
",",
"''",
",",
"time",
"(",
")",
"-",
"10000",
",",
"'/'",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"$",
"cookie_key",
"]",
")",
";",
"session_destroy",
"(",
")",
";",
"}"
] |
Destroy a jwt user session
|
[
"Destroy",
"a",
"jwt",
"user",
"session"
] |
482763dd92efcf3d96d13939cdb745763416f3b5
|
https://github.com/FDT2k/noctis-core/blob/482763dd92efcf3d96d13939cdb745763416f3b5/src/Service/UserSessionService.php#L108-L113
|
239,650
|
flowcode/pachamama
|
src/flowcode/pachamama/domain/MailMessage.php
|
MailMessage.getHtmlMail
|
public static function getHtmlMail($mailView, $params, $to, $from, $subject) {
if (file_exists($mailView)) {
ob_start();
require_once $mailView;
$body = ob_get_contents();
ob_end_clean();
} else {
throw new MailViewException($mailView);
}
$mail = new MailMessage($to, $from, $body, $subject);
$headers = "MIME-Version: 1.0\r\n"
. "Content-Type: text/html; charset=utf-8\r\n"
. "Content-Transfer-Encoding: 8bit\r\n"
. "From: =?UTF-8?B?" . base64_encode($params["from_name"]) . "?= <" . $from . ">\r\n"
. "X-Mailer: PHP/" . phpversion();
$mail->setHeaders($headers);
return $mail;
}
|
php
|
public static function getHtmlMail($mailView, $params, $to, $from, $subject) {
if (file_exists($mailView)) {
ob_start();
require_once $mailView;
$body = ob_get_contents();
ob_end_clean();
} else {
throw new MailViewException($mailView);
}
$mail = new MailMessage($to, $from, $body, $subject);
$headers = "MIME-Version: 1.0\r\n"
. "Content-Type: text/html; charset=utf-8\r\n"
. "Content-Transfer-Encoding: 8bit\r\n"
. "From: =?UTF-8?B?" . base64_encode($params["from_name"]) . "?= <" . $from . ">\r\n"
. "X-Mailer: PHP/" . phpversion();
$mail->setHeaders($headers);
return $mail;
}
|
[
"public",
"static",
"function",
"getHtmlMail",
"(",
"$",
"mailView",
",",
"$",
"params",
",",
"$",
"to",
",",
"$",
"from",
",",
"$",
"subject",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"mailView",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"require_once",
"$",
"mailView",
";",
"$",
"body",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MailViewException",
"(",
"$",
"mailView",
")",
";",
"}",
"$",
"mail",
"=",
"new",
"MailMessage",
"(",
"$",
"to",
",",
"$",
"from",
",",
"$",
"body",
",",
"$",
"subject",
")",
";",
"$",
"headers",
"=",
"\"MIME-Version: 1.0\\r\\n\"",
".",
"\"Content-Type: text/html; charset=utf-8\\r\\n\"",
".",
"\"Content-Transfer-Encoding: 8bit\\r\\n\"",
".",
"\"From: =?UTF-8?B?\"",
".",
"base64_encode",
"(",
"$",
"params",
"[",
"\"from_name\"",
"]",
")",
".",
"\"?= <\"",
".",
"$",
"from",
".",
"\">\\r\\n\"",
".",
"\"X-Mailer: PHP/\"",
".",
"phpversion",
"(",
")",
";",
"$",
"mail",
"->",
"setHeaders",
"(",
"$",
"headers",
")",
";",
"return",
"$",
"mail",
";",
"}"
] |
Get Html Mail with a view.
@param type $mailView
@param type $params
@param type $to
@param type $from
@param type $subject
@return \flowcode\pachamama\domain\Mail
@throws MailViewException
|
[
"Get",
"Html",
"Mail",
"with",
"a",
"view",
"."
] |
c258de6da7af9c5e6453edcce87f5f40faf4f7c6
|
https://github.com/flowcode/pachamama/blob/c258de6da7af9c5e6453edcce87f5f40faf4f7c6/src/flowcode/pachamama/domain/MailMessage.php#L44-L62
|
239,651
|
flowcode/pachamama
|
src/flowcode/pachamama/domain/MailMessage.php
|
MailMessage.getPlainMail
|
public static function getPlainMail($to, $from, $body, $subject) {
$mail = new MailMessage($to, $from, $body, $subject);
return $mail;
}
|
php
|
public static function getPlainMail($to, $from, $body, $subject) {
$mail = new MailMessage($to, $from, $body, $subject);
return $mail;
}
|
[
"public",
"static",
"function",
"getPlainMail",
"(",
"$",
"to",
",",
"$",
"from",
",",
"$",
"body",
",",
"$",
"subject",
")",
"{",
"$",
"mail",
"=",
"new",
"MailMessage",
"(",
"$",
"to",
",",
"$",
"from",
",",
"$",
"body",
",",
"$",
"subject",
")",
";",
"return",
"$",
"mail",
";",
"}"
] |
Gat a standard plain mail.
@param type $to
@param type $from
@param type $body
@param type $subject
@return \flowcode\pachamama\domain\Mail
|
[
"Gat",
"a",
"standard",
"plain",
"mail",
"."
] |
c258de6da7af9c5e6453edcce87f5f40faf4f7c6
|
https://github.com/flowcode/pachamama/blob/c258de6da7af9c5e6453edcce87f5f40faf4f7c6/src/flowcode/pachamama/domain/MailMessage.php#L72-L75
|
239,652
|
bashilbers/domain
|
src/Aggregates/Reconstitution.php
|
Reconstitution.reconstituteFrom
|
public static function reconstituteFrom(CommittedEvents $history)
{
$instance = static::fromIdentity($history->getIdentity());
$instance->whenAll($history);
return $instance;
}
|
php
|
public static function reconstituteFrom(CommittedEvents $history)
{
$instance = static::fromIdentity($history->getIdentity());
$instance->whenAll($history);
return $instance;
}
|
[
"public",
"static",
"function",
"reconstituteFrom",
"(",
"CommittedEvents",
"$",
"history",
")",
"{",
"$",
"instance",
"=",
"static",
"::",
"fromIdentity",
"(",
"$",
"history",
"->",
"getIdentity",
"(",
")",
")",
";",
"$",
"instance",
"->",
"whenAll",
"(",
"$",
"history",
")",
";",
"return",
"$",
"instance",
";",
"}"
] |
Reconstructs given concrete aggregate and applies the history
@param CommittedEvents $history
@return static
|
[
"Reconstructs",
"given",
"concrete",
"aggregate",
"and",
"applies",
"the",
"history"
] |
864736b8c409077706554b6ac4c574832678d316
|
https://github.com/bashilbers/domain/blob/864736b8c409077706554b6ac4c574832678d316/src/Aggregates/Reconstitution.php#L21-L27
|
239,653
|
Dhii/container-helper-base
|
src/ContainerHasCapableTrait.php
|
ContainerHasCapableTrait._containerHas
|
protected function _containerHas($container, $key)
{
$key = $this->_normalizeKey($key);
if ($container instanceof BaseContainerInterface) {
return $container->has($key);
}
if ($container instanceof ArrayAccess) {
// Catching exceptions thrown by `offsetExists()`
try {
return $container->offsetExists($key);
} catch (RootException $e) {
throw $this->_createContainerException($this->__('Could not check for key "%1$s"', [$key]), null, $e, null);
}
}
if (is_array($container)) {
return array_key_exists($key, $container);
}
if ($container instanceof stdClass) {
return property_exists($container, $key);
}
throw $this->_createInvalidArgumentException($this->__('Not a valid container'), null, null, $container);
}
|
php
|
protected function _containerHas($container, $key)
{
$key = $this->_normalizeKey($key);
if ($container instanceof BaseContainerInterface) {
return $container->has($key);
}
if ($container instanceof ArrayAccess) {
// Catching exceptions thrown by `offsetExists()`
try {
return $container->offsetExists($key);
} catch (RootException $e) {
throw $this->_createContainerException($this->__('Could not check for key "%1$s"', [$key]), null, $e, null);
}
}
if (is_array($container)) {
return array_key_exists($key, $container);
}
if ($container instanceof stdClass) {
return property_exists($container, $key);
}
throw $this->_createInvalidArgumentException($this->__('Not a valid container'), null, null, $container);
}
|
[
"protected",
"function",
"_containerHas",
"(",
"$",
"container",
",",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"_normalizeKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"container",
"instanceof",
"BaseContainerInterface",
")",
"{",
"return",
"$",
"container",
"->",
"has",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"$",
"container",
"instanceof",
"ArrayAccess",
")",
"{",
"// Catching exceptions thrown by `offsetExists()`",
"try",
"{",
"return",
"$",
"container",
"->",
"offsetExists",
"(",
"$",
"key",
")",
";",
"}",
"catch",
"(",
"RootException",
"$",
"e",
")",
"{",
"throw",
"$",
"this",
"->",
"_createContainerException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Could not check for key \"%1$s\"'",
",",
"[",
"$",
"key",
"]",
")",
",",
"null",
",",
"$",
"e",
",",
"null",
")",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"container",
")",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"container",
")",
";",
"}",
"if",
"(",
"$",
"container",
"instanceof",
"stdClass",
")",
"{",
"return",
"property_exists",
"(",
"$",
"container",
",",
"$",
"key",
")",
";",
"}",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Not a valid container'",
")",
",",
"null",
",",
"null",
",",
"$",
"container",
")",
";",
"}"
] |
Checks for a key on a container.
@since [*next-version*]
@param array|ArrayAccess|stdClass|BaseContainerInterface $container The container to check.
@param string|int|float|bool|Stringable $key The key to check for.
@throws ContainerExceptionInterface If an error occurred while checking the container.
@throws OutOfRangeException If the container or the key is invalid.
@return bool True if the container has an entry for the given key, false if not.
|
[
"Checks",
"for",
"a",
"key",
"on",
"a",
"container",
"."
] |
ccb2f56971d70cf203baa596cd14fdf91be6bfae
|
https://github.com/Dhii/container-helper-base/blob/ccb2f56971d70cf203baa596cd14fdf91be6bfae/src/ContainerHasCapableTrait.php#L34-L60
|
239,654
|
jannisfink/config
|
src/value/ConfigurationValue.php
|
ConfigurationValue.parse
|
public function parse() {
$value = $this->getRawValue();
$matches = [];
if (is_array($value)) {
return $value;
}
if (preg_match(self::NESTED_CONFIGURATION_REGEX, $value, $matches) === 1) {
return $this->parseNestedValue($value, $matches);
} else {
return $this->parser->parseIntelligent($value);
}
}
|
php
|
public function parse() {
$value = $this->getRawValue();
$matches = [];
if (is_array($value)) {
return $value;
}
if (preg_match(self::NESTED_CONFIGURATION_REGEX, $value, $matches) === 1) {
return $this->parseNestedValue($value, $matches);
} else {
return $this->parser->parseIntelligent($value);
}
}
|
[
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getRawValue",
"(",
")",
";",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"preg_match",
"(",
"self",
"::",
"NESTED_CONFIGURATION_REGEX",
",",
"$",
"value",
",",
"$",
"matches",
")",
"===",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"parseNestedValue",
"(",
"$",
"value",
",",
"$",
"matches",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"parser",
"->",
"parseIntelligent",
"(",
"$",
"value",
")",
";",
"}",
"}"
] |
Parse the configuration value and return the parsed result
@return mixed the parsed value
|
[
"Parse",
"the",
"configuration",
"value",
"and",
"return",
"the",
"parsed",
"result"
] |
54dc18c6125c971c46ded9f9484f6802112aab44
|
https://github.com/jannisfink/config/blob/54dc18c6125c971c46ded9f9484f6802112aab44/src/value/ConfigurationValue.php#L63-L75
|
239,655
|
phperf/pipeline
|
src/Vector/KalmanFilter.php
|
KalmanFilter.value
|
function value($value, $u = 0)
{
if (null === $this->x) {
$this->x = (1 / $this->measurementVector) * $value;
$this->cov = (1 / $this->measurementVector) * $this->measurementNoise * (1 / $this->measurementVector);
} else {
// Compute prediction
$predX = ($this->stateVector * $this->x) + ($this->controlVector * $u);
$predCov = (($this->stateVector * $this->cov) * $this->stateVector) + $this->processNoise;
// Kalman gain
$K = $predCov * $this->measurementVector *
(1 / (($this->measurementVector * $predCov * $this->measurementVector) + $this->measurementNoise));
// Correction
$this->x = $predX + $K * ($value - ($this->measurementVector * $predX));
$this->cov = $predCov - ($K * $this->measurementVector * $predCov);
}
return $this->x;
}
|
php
|
function value($value, $u = 0)
{
if (null === $this->x) {
$this->x = (1 / $this->measurementVector) * $value;
$this->cov = (1 / $this->measurementVector) * $this->measurementNoise * (1 / $this->measurementVector);
} else {
// Compute prediction
$predX = ($this->stateVector * $this->x) + ($this->controlVector * $u);
$predCov = (($this->stateVector * $this->cov) * $this->stateVector) + $this->processNoise;
// Kalman gain
$K = $predCov * $this->measurementVector *
(1 / (($this->measurementVector * $predCov * $this->measurementVector) + $this->measurementNoise));
// Correction
$this->x = $predX + $K * ($value - ($this->measurementVector * $predX));
$this->cov = $predCov - ($K * $this->measurementVector * $predCov);
}
return $this->x;
}
|
[
"function",
"value",
"(",
"$",
"value",
",",
"$",
"u",
"=",
"0",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"x",
")",
"{",
"$",
"this",
"->",
"x",
"=",
"(",
"1",
"/",
"$",
"this",
"->",
"measurementVector",
")",
"*",
"$",
"value",
";",
"$",
"this",
"->",
"cov",
"=",
"(",
"1",
"/",
"$",
"this",
"->",
"measurementVector",
")",
"*",
"$",
"this",
"->",
"measurementNoise",
"*",
"(",
"1",
"/",
"$",
"this",
"->",
"measurementVector",
")",
";",
"}",
"else",
"{",
"// Compute prediction",
"$",
"predX",
"=",
"(",
"$",
"this",
"->",
"stateVector",
"*",
"$",
"this",
"->",
"x",
")",
"+",
"(",
"$",
"this",
"->",
"controlVector",
"*",
"$",
"u",
")",
";",
"$",
"predCov",
"=",
"(",
"(",
"$",
"this",
"->",
"stateVector",
"*",
"$",
"this",
"->",
"cov",
")",
"*",
"$",
"this",
"->",
"stateVector",
")",
"+",
"$",
"this",
"->",
"processNoise",
";",
"// Kalman gain",
"$",
"K",
"=",
"$",
"predCov",
"*",
"$",
"this",
"->",
"measurementVector",
"*",
"(",
"1",
"/",
"(",
"(",
"$",
"this",
"->",
"measurementVector",
"*",
"$",
"predCov",
"*",
"$",
"this",
"->",
"measurementVector",
")",
"+",
"$",
"this",
"->",
"measurementNoise",
")",
")",
";",
"// Correction",
"$",
"this",
"->",
"x",
"=",
"$",
"predX",
"+",
"$",
"K",
"*",
"(",
"$",
"value",
"-",
"(",
"$",
"this",
"->",
"measurementVector",
"*",
"$",
"predX",
")",
")",
";",
"$",
"this",
"->",
"cov",
"=",
"$",
"predCov",
"-",
"(",
"$",
"K",
"*",
"$",
"this",
"->",
"measurementVector",
"*",
"$",
"predCov",
")",
";",
"}",
"return",
"$",
"this",
"->",
"x",
";",
"}"
] |
Filter a new value
@param float $value Measurement
@param float|int $u Control
@return float
|
[
"Filter",
"a",
"new",
"value"
] |
d3c4f36e586a677f42674a3fe7077d1334840c6d
|
https://github.com/phperf/pipeline/blob/d3c4f36e586a677f42674a3fe7077d1334840c6d/src/Vector/KalmanFilter.php#L48-L68
|
239,656
|
synapsestudios/synapse-base
|
src/Synapse/Mapper/FinderTrait.php
|
FinderTrait.findBy
|
public function findBy(array $wheres, array $options = [])
{
$query = $this->getSqlObject()->select();
$this->setColumns($query, $options);
$wheres = $this->addJoins($query, $wheres, $options);
$this->addWheres($query, $wheres, $options);
if (Arr::get($options, 'order')) {
$this->setOrder($query, $options['order']);
}
return $this->executeAndGetResultsAsEntity($query);
}
|
php
|
public function findBy(array $wheres, array $options = [])
{
$query = $this->getSqlObject()->select();
$this->setColumns($query, $options);
$wheres = $this->addJoins($query, $wheres, $options);
$this->addWheres($query, $wheres, $options);
if (Arr::get($options, 'order')) {
$this->setOrder($query, $options['order']);
}
return $this->executeAndGetResultsAsEntity($query);
}
|
[
"public",
"function",
"findBy",
"(",
"array",
"$",
"wheres",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getSqlObject",
"(",
")",
"->",
"select",
"(",
")",
";",
"$",
"this",
"->",
"setColumns",
"(",
"$",
"query",
",",
"$",
"options",
")",
";",
"$",
"wheres",
"=",
"$",
"this",
"->",
"addJoins",
"(",
"$",
"query",
",",
"$",
"wheres",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"addWheres",
"(",
"$",
"query",
",",
"$",
"wheres",
",",
"$",
"options",
")",
";",
"if",
"(",
"Arr",
"::",
"get",
"(",
"$",
"options",
",",
"'order'",
")",
")",
"{",
"$",
"this",
"->",
"setOrder",
"(",
"$",
"query",
",",
"$",
"options",
"[",
"'order'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"executeAndGetResultsAsEntity",
"(",
"$",
"query",
")",
";",
"}"
] |
Find a single entity by specific field values
@param array $wheres An array of where conditions in the format:
['column' => 'value'] or
['column', 'operator', 'value']
@param array $options
@return AbstractEntity|bool
|
[
"Find",
"a",
"single",
"entity",
"by",
"specific",
"field",
"values"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/FinderTrait.php#L51-L66
|
239,657
|
synapsestudios/synapse-base
|
src/Synapse/Mapper/FinderTrait.php
|
FinderTrait.findAllBy
|
public function findAllBy(array $wheres, array $options = [])
{
$query = $this->getSqlObject()->select();
$this->setColumns($query, $options);
$wheres = $this->addJoins($query, $wheres, $options);
$this->addWheres($query, $wheres, $options);
$page = Arr::get($options, 'page');
if ($page && !Arr::get($options, 'order')) {
throw new LogicException('Must provide an ORDER BY if using pagination');
}
if (Arr::get($options, 'order')) {
$this->setOrder($query, $options['order']);
}
if ($page) {
$paginationData = $this->getPaginationData($query, $options);
// Set LIMIT and OFFSET
$query->limit($paginationData->getResultsPerPage());
$query->offset(($page - 1) * $paginationData->getResultsPerPage());
}
$entityIterator = $this->executeAndGetResultsAsEntityIterator($query);
if ($page) {
$entityIterator->setPaginationData($paginationData);
}
return $entityIterator;
}
|
php
|
public function findAllBy(array $wheres, array $options = [])
{
$query = $this->getSqlObject()->select();
$this->setColumns($query, $options);
$wheres = $this->addJoins($query, $wheres, $options);
$this->addWheres($query, $wheres, $options);
$page = Arr::get($options, 'page');
if ($page && !Arr::get($options, 'order')) {
throw new LogicException('Must provide an ORDER BY if using pagination');
}
if (Arr::get($options, 'order')) {
$this->setOrder($query, $options['order']);
}
if ($page) {
$paginationData = $this->getPaginationData($query, $options);
// Set LIMIT and OFFSET
$query->limit($paginationData->getResultsPerPage());
$query->offset(($page - 1) * $paginationData->getResultsPerPage());
}
$entityIterator = $this->executeAndGetResultsAsEntityIterator($query);
if ($page) {
$entityIterator->setPaginationData($paginationData);
}
return $entityIterator;
}
|
[
"public",
"function",
"findAllBy",
"(",
"array",
"$",
"wheres",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getSqlObject",
"(",
")",
"->",
"select",
"(",
")",
";",
"$",
"this",
"->",
"setColumns",
"(",
"$",
"query",
",",
"$",
"options",
")",
";",
"$",
"wheres",
"=",
"$",
"this",
"->",
"addJoins",
"(",
"$",
"query",
",",
"$",
"wheres",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"addWheres",
"(",
"$",
"query",
",",
"$",
"wheres",
",",
"$",
"options",
")",
";",
"$",
"page",
"=",
"Arr",
"::",
"get",
"(",
"$",
"options",
",",
"'page'",
")",
";",
"if",
"(",
"$",
"page",
"&&",
"!",
"Arr",
"::",
"get",
"(",
"$",
"options",
",",
"'order'",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Must provide an ORDER BY if using pagination'",
")",
";",
"}",
"if",
"(",
"Arr",
"::",
"get",
"(",
"$",
"options",
",",
"'order'",
")",
")",
"{",
"$",
"this",
"->",
"setOrder",
"(",
"$",
"query",
",",
"$",
"options",
"[",
"'order'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"page",
")",
"{",
"$",
"paginationData",
"=",
"$",
"this",
"->",
"getPaginationData",
"(",
"$",
"query",
",",
"$",
"options",
")",
";",
"// Set LIMIT and OFFSET",
"$",
"query",
"->",
"limit",
"(",
"$",
"paginationData",
"->",
"getResultsPerPage",
"(",
")",
")",
";",
"$",
"query",
"->",
"offset",
"(",
"(",
"$",
"page",
"-",
"1",
")",
"*",
"$",
"paginationData",
"->",
"getResultsPerPage",
"(",
")",
")",
";",
"}",
"$",
"entityIterator",
"=",
"$",
"this",
"->",
"executeAndGetResultsAsEntityIterator",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"page",
")",
"{",
"$",
"entityIterator",
"->",
"setPaginationData",
"(",
"$",
"paginationData",
")",
";",
"}",
"return",
"$",
"entityIterator",
";",
"}"
] |
Find all entities matching specific field values
@param array $wheres An array of where conditions in the format:
['column' => 'value'] or
['column', 'operator', 'value']
@param array $options Array of options for this request.
May include 'order', 'page', or 'resultsPerPage'.
@return EntityIterator AbstractEntity objects
@throws LogicException If pagination enabled and no 'order' option specified.
|
[
"Find",
"all",
"entities",
"matching",
"specific",
"field",
"values"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/FinderTrait.php#L90-L124
|
239,658
|
synapsestudios/synapse-base
|
src/Synapse/Mapper/FinderTrait.php
|
FinderTrait.setOrder
|
protected function setOrder(Select $query, array $order)
{
// Normalize to [['column', 'direction']] format if only one column
if (! is_array(Arr::get($order, 0))) {
$order = [$order];
}
foreach ($order as $key => $orderValue) {
if (is_array($orderValue)) {
// Column and direction
$query->order(
Arr::get($orderValue, 0).' '.Arr::get($orderValue, 1)
);
}
}
return $query;
}
|
php
|
protected function setOrder(Select $query, array $order)
{
// Normalize to [['column', 'direction']] format if only one column
if (! is_array(Arr::get($order, 0))) {
$order = [$order];
}
foreach ($order as $key => $orderValue) {
if (is_array($orderValue)) {
// Column and direction
$query->order(
Arr::get($orderValue, 0).' '.Arr::get($orderValue, 1)
);
}
}
return $query;
}
|
[
"protected",
"function",
"setOrder",
"(",
"Select",
"$",
"query",
",",
"array",
"$",
"order",
")",
"{",
"// Normalize to [['column', 'direction']] format if only one column",
"if",
"(",
"!",
"is_array",
"(",
"Arr",
"::",
"get",
"(",
"$",
"order",
",",
"0",
")",
")",
")",
"{",
"$",
"order",
"=",
"[",
"$",
"order",
"]",
";",
"}",
"foreach",
"(",
"$",
"order",
"as",
"$",
"key",
"=>",
"$",
"orderValue",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"orderValue",
")",
")",
"{",
"// Column and direction",
"$",
"query",
"->",
"order",
"(",
"Arr",
"::",
"get",
"(",
"$",
"orderValue",
",",
"0",
")",
".",
"' '",
".",
"Arr",
"::",
"get",
"(",
"$",
"orderValue",
",",
"1",
")",
")",
";",
"}",
"}",
"return",
"$",
"query",
";",
"}"
] |
Set the order on the given query
Can specify order as [['column', 'direction'], ['column', 'direction']]
or just ['column', 'direction'] or even [['column', 'direction'], 'column']
@param Select $query
@param array $order
@return Select
|
[
"Set",
"the",
"order",
"on",
"the",
"given",
"query"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/FinderTrait.php#L148-L165
|
239,659
|
synapsestudios/synapse-base
|
src/Synapse/Mapper/FinderTrait.php
|
FinderTrait.getPaginationData
|
protected function getPaginationData(Select $query, array $options)
{
// Get pagination options
$page = (int) Arr::get($options, 'page');
if ($page < 1) {
$page = 1;
}
$resultsPerPage = Arr::get(
$options,
'resultsPerPage',
$this->resultsPerPage
);
// Get total results
$resultCount = $this->getQueryResultCount($query);
$pageCount = ceil($resultCount / $resultsPerPage);
return new PaginationData([
'page' => $page,
'page_count' => $pageCount,
'result_count' => $resultCount,
'results_per_page' => $resultsPerPage
]);
}
|
php
|
protected function getPaginationData(Select $query, array $options)
{
// Get pagination options
$page = (int) Arr::get($options, 'page');
if ($page < 1) {
$page = 1;
}
$resultsPerPage = Arr::get(
$options,
'resultsPerPage',
$this->resultsPerPage
);
// Get total results
$resultCount = $this->getQueryResultCount($query);
$pageCount = ceil($resultCount / $resultsPerPage);
return new PaginationData([
'page' => $page,
'page_count' => $pageCount,
'result_count' => $resultCount,
'results_per_page' => $resultsPerPage
]);
}
|
[
"protected",
"function",
"getPaginationData",
"(",
"Select",
"$",
"query",
",",
"array",
"$",
"options",
")",
"{",
"// Get pagination options",
"$",
"page",
"=",
"(",
"int",
")",
"Arr",
"::",
"get",
"(",
"$",
"options",
",",
"'page'",
")",
";",
"if",
"(",
"$",
"page",
"<",
"1",
")",
"{",
"$",
"page",
"=",
"1",
";",
"}",
"$",
"resultsPerPage",
"=",
"Arr",
"::",
"get",
"(",
"$",
"options",
",",
"'resultsPerPage'",
",",
"$",
"this",
"->",
"resultsPerPage",
")",
";",
"// Get total results",
"$",
"resultCount",
"=",
"$",
"this",
"->",
"getQueryResultCount",
"(",
"$",
"query",
")",
";",
"$",
"pageCount",
"=",
"ceil",
"(",
"$",
"resultCount",
"/",
"$",
"resultsPerPage",
")",
";",
"return",
"new",
"PaginationData",
"(",
"[",
"'page'",
"=>",
"$",
"page",
",",
"'page_count'",
"=>",
"$",
"pageCount",
",",
"'result_count'",
"=>",
"$",
"resultCount",
",",
"'results_per_page'",
"=>",
"$",
"resultsPerPage",
"]",
")",
";",
"}"
] |
Get data object with pagination data like page and page_count
@param Select $query
@param array $options
@return PaginationData
|
[
"Get",
"data",
"object",
"with",
"pagination",
"data",
"like",
"page",
"and",
"page_count"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/FinderTrait.php#L174-L199
|
239,660
|
synapsestudios/synapse-base
|
src/Synapse/Mapper/FinderTrait.php
|
FinderTrait.getQueryResultCount
|
protected function getQueryResultCount(Select $query)
{
$queryString = $this->getSqlObject()->getSqlStringForSqlObject($query, $this->dbAdapter->getPlatform());
$format = 'Select count(*) as `count` from (%s) as `query_count`';
$countQueryString = sprintf($format, $queryString);
$countQuery = $this->dbAdapter->query($countQueryString);
$result = $countQuery->execute()->current();
return (int) Arr::get($result, 'count');
}
|
php
|
protected function getQueryResultCount(Select $query)
{
$queryString = $this->getSqlObject()->getSqlStringForSqlObject($query, $this->dbAdapter->getPlatform());
$format = 'Select count(*) as `count` from (%s) as `query_count`';
$countQueryString = sprintf($format, $queryString);
$countQuery = $this->dbAdapter->query($countQueryString);
$result = $countQuery->execute()->current();
return (int) Arr::get($result, 'count');
}
|
[
"protected",
"function",
"getQueryResultCount",
"(",
"Select",
"$",
"query",
")",
"{",
"$",
"queryString",
"=",
"$",
"this",
"->",
"getSqlObject",
"(",
")",
"->",
"getSqlStringForSqlObject",
"(",
"$",
"query",
",",
"$",
"this",
"->",
"dbAdapter",
"->",
"getPlatform",
"(",
")",
")",
";",
"$",
"format",
"=",
"'Select count(*) as `count` from (%s) as `query_count`'",
";",
"$",
"countQueryString",
"=",
"sprintf",
"(",
"$",
"format",
",",
"$",
"queryString",
")",
";",
"$",
"countQuery",
"=",
"$",
"this",
"->",
"dbAdapter",
"->",
"query",
"(",
"$",
"countQueryString",
")",
";",
"$",
"result",
"=",
"$",
"countQuery",
"->",
"execute",
"(",
")",
"->",
"current",
"(",
")",
";",
"return",
"(",
"int",
")",
"Arr",
"::",
"get",
"(",
"$",
"result",
",",
"'count'",
")",
";",
"}"
] |
Get the count of results from a given query
@param Select $query
@return int
|
[
"Get",
"the",
"count",
"of",
"results",
"from",
"a",
"given",
"query"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/FinderTrait.php#L207-L220
|
239,661
|
synapsestudios/synapse-base
|
src/Synapse/Mapper/FinderTrait.php
|
FinderTrait.addWheres
|
protected function addWheres(PreparableSqlInterface $query, array $wheres, array $options = [])
{
foreach ($wheres as $key => $where) {
if (is_array($where) && count($where) === 3) {
$leftOpRightSyntax = true;
$operator = $where[1];
switch ($operator) {
case '=':
$predicate = new Operator(
$where[0],
Operator::OP_EQ,
$where[2]
);
break;
case '!=':
$predicate = new Operator(
$where[0],
Operator::OP_NE,
$where[2]
);
break;
case '>':
$predicate = new Operator(
$where[0],
Operator::OP_GT,
$where[2]
);
break;
case '<':
$predicate = new Operator(
$where[0],
Operator::OP_LT,
$where[2]
);
break;
case '>=':
$predicate = new Operator(
$where[0],
Operator::OP_GTE,
$where[2]
);
break;
case '<=':
$predicate = new Operator(
$where[0],
Operator::OP_LTE,
$where[2]
);
break;
case 'LIKE':
$predicate = new Like($where[0], $where[2]);
break;
case 'NOT LIKE':
$predicate = new NotLike($where[0], $where[2]);
break;
case 'IN':
$predicate = new In($where[0], $where[2]);
break;
case 'NOT IN':
$predicate = new NotIn($where[0], $where[2]);
break;
case 'IS':
$predicate = new IsNull($where[0]);
break;
case 'IS NOT':
$predicate = new IsNotNull($where[0]);
break;
default:
$leftOpRightSyntax = false;
break;
}
if ($leftOpRightSyntax === false) {
$predicate = [$key => $where];
}
} else {
$predicate = [$key => $where];
}
$query->where($predicate);
}
return $query;
}
|
php
|
protected function addWheres(PreparableSqlInterface $query, array $wheres, array $options = [])
{
foreach ($wheres as $key => $where) {
if (is_array($where) && count($where) === 3) {
$leftOpRightSyntax = true;
$operator = $where[1];
switch ($operator) {
case '=':
$predicate = new Operator(
$where[0],
Operator::OP_EQ,
$where[2]
);
break;
case '!=':
$predicate = new Operator(
$where[0],
Operator::OP_NE,
$where[2]
);
break;
case '>':
$predicate = new Operator(
$where[0],
Operator::OP_GT,
$where[2]
);
break;
case '<':
$predicate = new Operator(
$where[0],
Operator::OP_LT,
$where[2]
);
break;
case '>=':
$predicate = new Operator(
$where[0],
Operator::OP_GTE,
$where[2]
);
break;
case '<=':
$predicate = new Operator(
$where[0],
Operator::OP_LTE,
$where[2]
);
break;
case 'LIKE':
$predicate = new Like($where[0], $where[2]);
break;
case 'NOT LIKE':
$predicate = new NotLike($where[0], $where[2]);
break;
case 'IN':
$predicate = new In($where[0], $where[2]);
break;
case 'NOT IN':
$predicate = new NotIn($where[0], $where[2]);
break;
case 'IS':
$predicate = new IsNull($where[0]);
break;
case 'IS NOT':
$predicate = new IsNotNull($where[0]);
break;
default:
$leftOpRightSyntax = false;
break;
}
if ($leftOpRightSyntax === false) {
$predicate = [$key => $where];
}
} else {
$predicate = [$key => $where];
}
$query->where($predicate);
}
return $query;
}
|
[
"protected",
"function",
"addWheres",
"(",
"PreparableSqlInterface",
"$",
"query",
",",
"array",
"$",
"wheres",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"wheres",
"as",
"$",
"key",
"=>",
"$",
"where",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"where",
")",
"&&",
"count",
"(",
"$",
"where",
")",
"===",
"3",
")",
"{",
"$",
"leftOpRightSyntax",
"=",
"true",
";",
"$",
"operator",
"=",
"$",
"where",
"[",
"1",
"]",
";",
"switch",
"(",
"$",
"operator",
")",
"{",
"case",
"'='",
":",
"$",
"predicate",
"=",
"new",
"Operator",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"Operator",
"::",
"OP_EQ",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'!='",
":",
"$",
"predicate",
"=",
"new",
"Operator",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"Operator",
"::",
"OP_NE",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'>'",
":",
"$",
"predicate",
"=",
"new",
"Operator",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"Operator",
"::",
"OP_GT",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'<'",
":",
"$",
"predicate",
"=",
"new",
"Operator",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"Operator",
"::",
"OP_LT",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'>='",
":",
"$",
"predicate",
"=",
"new",
"Operator",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"Operator",
"::",
"OP_GTE",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'<='",
":",
"$",
"predicate",
"=",
"new",
"Operator",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"Operator",
"::",
"OP_LTE",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'LIKE'",
":",
"$",
"predicate",
"=",
"new",
"Like",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'NOT LIKE'",
":",
"$",
"predicate",
"=",
"new",
"NotLike",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'IN'",
":",
"$",
"predicate",
"=",
"new",
"In",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'NOT IN'",
":",
"$",
"predicate",
"=",
"new",
"NotIn",
"(",
"$",
"where",
"[",
"0",
"]",
",",
"$",
"where",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"'IS'",
":",
"$",
"predicate",
"=",
"new",
"IsNull",
"(",
"$",
"where",
"[",
"0",
"]",
")",
";",
"break",
";",
"case",
"'IS NOT'",
":",
"$",
"predicate",
"=",
"new",
"IsNotNull",
"(",
"$",
"where",
"[",
"0",
"]",
")",
";",
"break",
";",
"default",
":",
"$",
"leftOpRightSyntax",
"=",
"false",
";",
"break",
";",
"}",
"if",
"(",
"$",
"leftOpRightSyntax",
"===",
"false",
")",
"{",
"$",
"predicate",
"=",
"[",
"$",
"key",
"=>",
"$",
"where",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"predicate",
"=",
"[",
"$",
"key",
"=>",
"$",
"where",
"]",
";",
"}",
"$",
"query",
"->",
"where",
"(",
"$",
"predicate",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Add where clauses to query
@param PreparableSqlInterface $query
@param array $wheres An array of where conditions in the format:
['column' => 'value'] or
['column', 'operator', 'value']
@param array $options
@return PreparableSqlInterface
@throws InvalidArgumentException If a WHERE requirement is in an unsupported format.
|
[
"Add",
"where",
"clauses",
"to",
"query"
] |
60c830550491742a077ab063f924e2f0b63825da
|
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/FinderTrait.php#L233-L318
|
239,662
|
Dhii/validation-abstract
|
src/ValidatorAwareTrait.php
|
ValidatorAwareTrait._setValidator
|
protected function _setValidator($validator)
{
if (!is_null($validator) && !($validator instanceof ValidatorInterface)) {
throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator);
}
$this->validator = $validator;
}
|
php
|
protected function _setValidator($validator)
{
if (!is_null($validator) && !($validator instanceof ValidatorInterface)) {
throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator);
}
$this->validator = $validator;
}
|
[
"protected",
"function",
"_setValidator",
"(",
"$",
"validator",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"validator",
")",
"&&",
"!",
"(",
"$",
"validator",
"instanceof",
"ValidatorInterface",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid validator'",
")",
",",
"null",
",",
"null",
",",
"$",
"validator",
")",
";",
"}",
"$",
"this",
"->",
"validator",
"=",
"$",
"validator",
";",
"}"
] |
Assigns a validator to this instance.
@since [*next-version*]
@param ValidatorInterface|null $validator The validator.
|
[
"Assigns",
"a",
"validator",
"to",
"this",
"instance",
"."
] |
dff998ba3476927a0fc6d10bb022425de8f1c844
|
https://github.com/Dhii/validation-abstract/blob/dff998ba3476927a0fc6d10bb022425de8f1c844/src/ValidatorAwareTrait.php#L44-L51
|
239,663
|
extendsframework/extends-router
|
src/Route/Path/PathRoute.php
|
PathRoute.getMatchedParameters
|
protected function getMatchedParameters(array $matches): array
{
$parameters = [];
foreach ($matches as $key => $match) {
if (is_string($key)) {
$parameters[$key] = $match[0];
}
}
return array_replace_recursive($this->getParameters(), $parameters);
}
|
php
|
protected function getMatchedParameters(array $matches): array
{
$parameters = [];
foreach ($matches as $key => $match) {
if (is_string($key)) {
$parameters[$key] = $match[0];
}
}
return array_replace_recursive($this->getParameters(), $parameters);
}
|
[
"protected",
"function",
"getMatchedParameters",
"(",
"array",
"$",
"matches",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"key",
"=>",
"$",
"match",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"parameters",
"[",
"$",
"key",
"]",
"=",
"$",
"match",
"[",
"0",
"]",
";",
"}",
"}",
"return",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"getParameters",
"(",
")",
",",
"$",
"parameters",
")",
";",
"}"
] |
Get the parameters when the route is matched.
The $matches will be filtered for integer keys and merged into the default parameters.
@param array $matches
@return array
|
[
"Get",
"the",
"parameters",
"when",
"the",
"route",
"is",
"matched",
"."
] |
7c142749635c6fb1c58508bf3c8f594529e136d9
|
https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Route/Path/PathRoute.php#L136-L146
|
239,664
|
extendsframework/extends-router
|
src/Route/Path/PathRoute.php
|
PathRoute.getPattern
|
protected function getPattern(): string
{
$path = preg_replace_callback('~:([a-z][a-z0-9\_]+)~i', function ($match) {
return sprintf('(?<%s>%s)', $match[1], '[^\/]*');
}, $this->getPath());
return sprintf('~\G(%s)(/|\z)~', $path);
}
|
php
|
protected function getPattern(): string
{
$path = preg_replace_callback('~:([a-z][a-z0-9\_]+)~i', function ($match) {
return sprintf('(?<%s>%s)', $match[1], '[^\/]*');
}, $this->getPath());
return sprintf('~\G(%s)(/|\z)~', $path);
}
|
[
"protected",
"function",
"getPattern",
"(",
")",
":",
"string",
"{",
"$",
"path",
"=",
"preg_replace_callback",
"(",
"'~:([a-z][a-z0-9\\_]+)~i'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"return",
"sprintf",
"(",
"'(?<%s>%s)'",
",",
"$",
"match",
"[",
"1",
"]",
",",
"'[^\\/]*'",
")",
";",
"}",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"return",
"sprintf",
"(",
"'~\\G(%s)(/|\\z)~'",
",",
"$",
"path",
")",
";",
"}"
] |
Get pattern to match request path.
@return string
|
[
"Get",
"pattern",
"to",
"match",
"request",
"path",
"."
] |
7c142749635c6fb1c58508bf3c8f594529e136d9
|
https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Route/Path/PathRoute.php#L153-L160
|
239,665
|
lasallecrm/lasallecrm-l5-listmanagement-pkg
|
src/FrontendProcessing/SubscribeToList.php
|
SubscribeToList.prepareEmailDataForInsert
|
public function prepareEmailDataForInsert($request) {
$data = [];
$data['email_type_id'] = 1; // Primary
$data['title'] = $request->input('email');
$data['description'] = "";
$data['comments'] = "Created by front-end subscription to an email list";
$data['created_at'] = Carbon::now();
$data['created_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['updated_at'] = Carbon::now();
$data['updated_by'] = $this->userRepository->getFirstAmongEqualsUserID();
return $data;
}
|
php
|
public function prepareEmailDataForInsert($request) {
$data = [];
$data['email_type_id'] = 1; // Primary
$data['title'] = $request->input('email');
$data['description'] = "";
$data['comments'] = "Created by front-end subscription to an email list";
$data['created_at'] = Carbon::now();
$data['created_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['updated_at'] = Carbon::now();
$data['updated_by'] = $this->userRepository->getFirstAmongEqualsUserID();
return $data;
}
|
[
"public",
"function",
"prepareEmailDataForInsert",
"(",
"$",
"request",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'email_type_id'",
"]",
"=",
"1",
";",
"// Primary",
"$",
"data",
"[",
"'title'",
"]",
"=",
"$",
"request",
"->",
"input",
"(",
"'email'",
")",
";",
"$",
"data",
"[",
"'description'",
"]",
"=",
"\"\"",
";",
"$",
"data",
"[",
"'comments'",
"]",
"=",
"\"Created by front-end subscription to an email list\"",
";",
"$",
"data",
"[",
"'created_at'",
"]",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"$",
"data",
"[",
"'created_by'",
"]",
"=",
"$",
"this",
"->",
"userRepository",
"->",
"getFirstAmongEqualsUserID",
"(",
")",
";",
"$",
"data",
"[",
"'updated_at'",
"]",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"$",
"data",
"[",
"'updated_by'",
"]",
"=",
"$",
"this",
"->",
"userRepository",
"->",
"getFirstAmongEqualsUserID",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Prepare the data for creating a new record in the "emails" db table
@param object $request The request object
@return array
|
[
"Prepare",
"the",
"data",
"for",
"creating",
"a",
"new",
"record",
"in",
"the",
"emails",
"db",
"table"
] |
4b5da1af5d25d5fb4be5199f3cf22da313d475f3
|
https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/FrontendProcessing/SubscribeToList.php#L168-L182
|
239,666
|
lasallecrm/lasallecrm-l5-listmanagement-pkg
|
src/FrontendProcessing/SubscribeToList.php
|
SubscribeToList.prepareList_emailDataForInsert
|
public function prepareList_emailDataForInsert($input) {
$data = [];
$data['title'] = $input['listID']." ".$input['emailID'];
$data['list_id'] = $input['listID'];
$data['email_id'] = $input['emailID'];
$data['comments'] = "";
$data['enabled'] = 1;
$data['created_at'] = Carbon::now();
$data['created_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['updated_at'] = Carbon::now();
$data['updated_by'] = $this->userRepository->getFirstAmongEqualsUserID();
return $data;
}
|
php
|
public function prepareList_emailDataForInsert($input) {
$data = [];
$data['title'] = $input['listID']." ".$input['emailID'];
$data['list_id'] = $input['listID'];
$data['email_id'] = $input['emailID'];
$data['comments'] = "";
$data['enabled'] = 1;
$data['created_at'] = Carbon::now();
$data['created_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['updated_at'] = Carbon::now();
$data['updated_by'] = $this->userRepository->getFirstAmongEqualsUserID();
return $data;
}
|
[
"public",
"function",
"prepareList_emailDataForInsert",
"(",
"$",
"input",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'title'",
"]",
"=",
"$",
"input",
"[",
"'listID'",
"]",
".",
"\" \"",
".",
"$",
"input",
"[",
"'emailID'",
"]",
";",
"$",
"data",
"[",
"'list_id'",
"]",
"=",
"$",
"input",
"[",
"'listID'",
"]",
";",
"$",
"data",
"[",
"'email_id'",
"]",
"=",
"$",
"input",
"[",
"'emailID'",
"]",
";",
"$",
"data",
"[",
"'comments'",
"]",
"=",
"\"\"",
";",
"$",
"data",
"[",
"'enabled'",
"]",
"=",
"1",
";",
"$",
"data",
"[",
"'created_at'",
"]",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"$",
"data",
"[",
"'created_by'",
"]",
"=",
"$",
"this",
"->",
"userRepository",
"->",
"getFirstAmongEqualsUserID",
"(",
")",
";",
"$",
"data",
"[",
"'updated_at'",
"]",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"$",
"data",
"[",
"'updated_by'",
"]",
"=",
"$",
"this",
"->",
"userRepository",
"->",
"getFirstAmongEqualsUserID",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Prepare the data for creating a new record in the "list_email" db table
@param array $input POST and processed vars merged into one array
@return array
|
[
"Prepare",
"the",
"data",
"for",
"creating",
"a",
"new",
"record",
"in",
"the",
"list_email",
"db",
"table"
] |
4b5da1af5d25d5fb4be5199f3cf22da313d475f3
|
https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/FrontendProcessing/SubscribeToList.php#L200-L216
|
239,667
|
lasallecrm/lasallecrm-l5-listmanagement-pkg
|
src/FrontendProcessing/SubscribeToList.php
|
SubscribeToList.preparePeoplesDataForInsert
|
public function preparePeoplesDataForInsert($input) {
$data = [];
$data['user_id'] = null; // Set users up as PEOPLES in the admin
$data['title'] = $input['first_name']." ".$input['surname'];
$data['salutation'] = "";
$data['first_name'] = $input['first_name'];
$data['middle_name'] = "";
$data['surname'] = $input['surname'];
$data['position'] = "";
$data['description'] = "";
$data['comments'] = "Created by front-end subscription to an email list";
$data['birthday'] = null;
$data['anniversary'] = null;
$data['created_at'] = Carbon::now();
$data['created_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['updated_at'] = Carbon::now();
$data['updated_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['profile'] = null;
$data['featured_image'] = null;
return $data;
}
|
php
|
public function preparePeoplesDataForInsert($input) {
$data = [];
$data['user_id'] = null; // Set users up as PEOPLES in the admin
$data['title'] = $input['first_name']." ".$input['surname'];
$data['salutation'] = "";
$data['first_name'] = $input['first_name'];
$data['middle_name'] = "";
$data['surname'] = $input['surname'];
$data['position'] = "";
$data['description'] = "";
$data['comments'] = "Created by front-end subscription to an email list";
$data['birthday'] = null;
$data['anniversary'] = null;
$data['created_at'] = Carbon::now();
$data['created_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['updated_at'] = Carbon::now();
$data['updated_by'] = $this->userRepository->getFirstAmongEqualsUserID();
$data['profile'] = null;
$data['featured_image'] = null;
return $data;
}
|
[
"public",
"function",
"preparePeoplesDataForInsert",
"(",
"$",
"input",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'user_id'",
"]",
"=",
"null",
";",
"// Set users up as PEOPLES in the admin",
"$",
"data",
"[",
"'title'",
"]",
"=",
"$",
"input",
"[",
"'first_name'",
"]",
".",
"\" \"",
".",
"$",
"input",
"[",
"'surname'",
"]",
";",
"$",
"data",
"[",
"'salutation'",
"]",
"=",
"\"\"",
";",
"$",
"data",
"[",
"'first_name'",
"]",
"=",
"$",
"input",
"[",
"'first_name'",
"]",
";",
"$",
"data",
"[",
"'middle_name'",
"]",
"=",
"\"\"",
";",
"$",
"data",
"[",
"'surname'",
"]",
"=",
"$",
"input",
"[",
"'surname'",
"]",
";",
"$",
"data",
"[",
"'position'",
"]",
"=",
"\"\"",
";",
"$",
"data",
"[",
"'description'",
"]",
"=",
"\"\"",
";",
"$",
"data",
"[",
"'comments'",
"]",
"=",
"\"Created by front-end subscription to an email list\"",
";",
"$",
"data",
"[",
"'birthday'",
"]",
"=",
"null",
";",
"$",
"data",
"[",
"'anniversary'",
"]",
"=",
"null",
";",
"$",
"data",
"[",
"'created_at'",
"]",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"$",
"data",
"[",
"'created_by'",
"]",
"=",
"$",
"this",
"->",
"userRepository",
"->",
"getFirstAmongEqualsUserID",
"(",
")",
";",
"$",
"data",
"[",
"'updated_at'",
"]",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"$",
"data",
"[",
"'updated_by'",
"]",
"=",
"$",
"this",
"->",
"userRepository",
"->",
"getFirstAmongEqualsUserID",
"(",
")",
";",
"$",
"data",
"[",
"'profile'",
"]",
"=",
"null",
";",
"$",
"data",
"[",
"'featured_image'",
"]",
"=",
"null",
";",
"return",
"$",
"data",
";",
"}"
] |
Prepare the data for creating a new record in the "peoplesl" db table
@param array $input POST and processed vars merged into one array
@return array
|
[
"Prepare",
"the",
"data",
"for",
"creating",
"a",
"new",
"record",
"in",
"the",
"peoplesl",
"db",
"table"
] |
4b5da1af5d25d5fb4be5199f3cf22da313d475f3
|
https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/FrontendProcessing/SubscribeToList.php#L245-L271
|
239,668
|
webriq/core
|
module/Customize/src/Grid/Customize/Controller/ImportExportController.php
|
ImportExportController.getValidReturnUri
|
protected function getValidReturnUri( $returnUri, $default = null )
{
$match = array();
$returnUri = ltrim( str_replace( '\\', '/', $returnUri ), "\n\r\t\v\e\f" );
if ( ! preg_match( '#^/([^/].*)?$#', $returnUri, $match ) )
{
return $default;
}
return $returnUri;
}
|
php
|
protected function getValidReturnUri( $returnUri, $default = null )
{
$match = array();
$returnUri = ltrim( str_replace( '\\', '/', $returnUri ), "\n\r\t\v\e\f" );
if ( ! preg_match( '#^/([^/].*)?$#', $returnUri, $match ) )
{
return $default;
}
return $returnUri;
}
|
[
"protected",
"function",
"getValidReturnUri",
"(",
"$",
"returnUri",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"match",
"=",
"array",
"(",
")",
";",
"$",
"returnUri",
"=",
"ltrim",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"returnUri",
")",
",",
"\"\\n\\r\\t\\v\\e\\f\"",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'#^/([^/].*)?$#'",
",",
"$",
"returnUri",
",",
"$",
"match",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"returnUri",
";",
"}"
] |
Gte valid return-uri
@param string $returnUri
@param string|null $default
@return string|null
|
[
"Gte",
"valid",
"return",
"-",
"uri"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Controller/ImportExportController.php#L54-L65
|
239,669
|
webriq/core
|
module/Customize/src/Grid/Customize/Controller/ImportExportController.php
|
ImportExportController.exportAction
|
public function exportAction()
{
$params = $this->params();
$paragraphId = $params->fromRoute( 'paragraphId' );
$serviceLocator = $this->getServiceLocator();
$paragraphModel = $serviceLocator->get( 'Grid\Paragraph\Model\Paragraph\Model' );
$paragraph = $paragraphModel->find( $paragraphId );
if ( empty( $paragraph ) )
{
$this->getResponse()
->setResultCode( 404 );
return;
}
$zipFile = $serviceLocator->get( 'Grid\Customize\Model\Exporter' )
->export( $paragraph->id );
$name = strtolower( $paragraph->name );
if ( empty( $name ) )
{
$name = 'paragraph-' . $paragraph->id;
}
$response = Readfile::fromFile(
$zipFile,
'application/zip',
$name . '.zip',
true
);
$this->getEvent()
->setResponse( $response );
return $response;
}
|
php
|
public function exportAction()
{
$params = $this->params();
$paragraphId = $params->fromRoute( 'paragraphId' );
$serviceLocator = $this->getServiceLocator();
$paragraphModel = $serviceLocator->get( 'Grid\Paragraph\Model\Paragraph\Model' );
$paragraph = $paragraphModel->find( $paragraphId );
if ( empty( $paragraph ) )
{
$this->getResponse()
->setResultCode( 404 );
return;
}
$zipFile = $serviceLocator->get( 'Grid\Customize\Model\Exporter' )
->export( $paragraph->id );
$name = strtolower( $paragraph->name );
if ( empty( $name ) )
{
$name = 'paragraph-' . $paragraph->id;
}
$response = Readfile::fromFile(
$zipFile,
'application/zip',
$name . '.zip',
true
);
$this->getEvent()
->setResponse( $response );
return $response;
}
|
[
"public",
"function",
"exportAction",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"params",
"(",
")",
";",
"$",
"paragraphId",
"=",
"$",
"params",
"->",
"fromRoute",
"(",
"'paragraphId'",
")",
";",
"$",
"serviceLocator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
";",
"$",
"paragraphModel",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Grid\\Paragraph\\Model\\Paragraph\\Model'",
")",
";",
"$",
"paragraph",
"=",
"$",
"paragraphModel",
"->",
"find",
"(",
"$",
"paragraphId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"paragraph",
")",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setResultCode",
"(",
"404",
")",
";",
"return",
";",
"}",
"$",
"zipFile",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Grid\\Customize\\Model\\Exporter'",
")",
"->",
"export",
"(",
"$",
"paragraph",
"->",
"id",
")",
";",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"paragraph",
"->",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"'paragraph-'",
".",
"$",
"paragraph",
"->",
"id",
";",
"}",
"$",
"response",
"=",
"Readfile",
"::",
"fromFile",
"(",
"$",
"zipFile",
",",
"'application/zip'",
",",
"$",
"name",
".",
"'.zip'",
",",
"true",
")",
";",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Export paragraph action
|
[
"Export",
"paragraph",
"action"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Controller/ImportExportController.php#L179-L216
|
239,670
|
PlatoCreative/plato-external-login
|
src/security/ExternalLoginAuthenticator.php
|
ExternalMemberAuthenticator.authenticateExternalMember
|
protected function authenticateExternalMember($data, ValidationResult &$result = null, Member $member = null)
{
$result = $result ?: ValidationResult::create();
$ssLoginUserName = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME');
$email = !empty($data['Email']) ? $data['Email'] : null;
if ($email != $ssLoginUserName) {
return;
}
// Check for default admin user
$member = Member::get()->find(
Member::config()->get('unique_identifier_field'),
$ssLoginUserName
);
if (!$member) {
return;
}
$member->checkLoginPassword($data['Password'], $result);
return $member;
}
|
php
|
protected function authenticateExternalMember($data, ValidationResult &$result = null, Member $member = null)
{
$result = $result ?: ValidationResult::create();
$ssLoginUserName = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME');
$email = !empty($data['Email']) ? $data['Email'] : null;
if ($email != $ssLoginUserName) {
return;
}
// Check for default admin user
$member = Member::get()->find(
Member::config()->get('unique_identifier_field'),
$ssLoginUserName
);
if (!$member) {
return;
}
$member->checkLoginPassword($data['Password'], $result);
return $member;
}
|
[
"protected",
"function",
"authenticateExternalMember",
"(",
"$",
"data",
",",
"ValidationResult",
"&",
"$",
"result",
"=",
"null",
",",
"Member",
"$",
"member",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"?",
":",
"ValidationResult",
"::",
"create",
"(",
")",
";",
"$",
"ssLoginUserName",
"=",
"Environment",
"::",
"getEnv",
"(",
"'SS_DEFAULT_ADMIN_USERNAME'",
")",
";",
"$",
"email",
"=",
"!",
"empty",
"(",
"$",
"data",
"[",
"'Email'",
"]",
")",
"?",
"$",
"data",
"[",
"'Email'",
"]",
":",
"null",
";",
"if",
"(",
"$",
"email",
"!=",
"$",
"ssLoginUserName",
")",
"{",
"return",
";",
"}",
"// Check for default admin user",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"find",
"(",
"Member",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'unique_identifier_field'",
")",
",",
"$",
"ssLoginUserName",
")",
";",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"return",
";",
"}",
"$",
"member",
"->",
"checkLoginPassword",
"(",
"$",
"data",
"[",
"'Password'",
"]",
",",
"$",
"result",
")",
";",
"return",
"$",
"member",
";",
"}"
] |
Attempt to find and authenticate external member if possible from the given data
@param array $data Form submitted data
@param ValidationResult $result
@param Member $member This third parameter is used in the CMSAuthenticator(s)
@return Member|Null
|
[
"Attempt",
"to",
"find",
"and",
"authenticate",
"external",
"member",
"if",
"possible",
"from",
"the",
"given",
"data"
] |
365277a84551e630b03ba24a49f26d536fdf3601
|
https://github.com/PlatoCreative/plato-external-login/blob/365277a84551e630b03ba24a49f26d536fdf3601/src/security/ExternalLoginAuthenticator.php#L55-L79
|
239,671
|
Aureja/JobQueue
|
src/JobRestoreManager.php
|
JobRestoreManager.saveReport
|
private function saveReport(JobConfigurationInterface $configuration)
{
$report = $this->reportManager->create($configuration);
$report
->setEndedAt()
->setOutput('Job was dead and restored.')
->setSuccessful(true);
$this->reportManager->add($report, true);
}
|
php
|
private function saveReport(JobConfigurationInterface $configuration)
{
$report = $this->reportManager->create($configuration);
$report
->setEndedAt()
->setOutput('Job was dead and restored.')
->setSuccessful(true);
$this->reportManager->add($report, true);
}
|
[
"private",
"function",
"saveReport",
"(",
"JobConfigurationInterface",
"$",
"configuration",
")",
"{",
"$",
"report",
"=",
"$",
"this",
"->",
"reportManager",
"->",
"create",
"(",
"$",
"configuration",
")",
";",
"$",
"report",
"->",
"setEndedAt",
"(",
")",
"->",
"setOutput",
"(",
"'Job was dead and restored.'",
")",
"->",
"setSuccessful",
"(",
"true",
")",
";",
"$",
"this",
"->",
"reportManager",
"->",
"add",
"(",
"$",
"report",
",",
"true",
")",
";",
"}"
] |
Create restored job report.
@param JobConfigurationInterface $configuration
@return JobReportInterface
|
[
"Create",
"restored",
"job",
"report",
"."
] |
0e488ca123d3105cf791173e3147ede1bcf39018
|
https://github.com/Aureja/JobQueue/blob/0e488ca123d3105cf791173e3147ede1bcf39018/src/JobRestoreManager.php#L83-L92
|
239,672
|
Aureja/JobQueue
|
src/JobRestoreManager.php
|
JobRestoreManager.isDead
|
private function isDead(JobConfigurationInterface $configuration)
{
$report = $this->reportManager->getLastStartedByConfiguration($configuration);
return $report && $report->getPid() && (false === $report->isSuccessful()) && !posix_getsid($report->getPid());
}
|
php
|
private function isDead(JobConfigurationInterface $configuration)
{
$report = $this->reportManager->getLastStartedByConfiguration($configuration);
return $report && $report->getPid() && (false === $report->isSuccessful()) && !posix_getsid($report->getPid());
}
|
[
"private",
"function",
"isDead",
"(",
"JobConfigurationInterface",
"$",
"configuration",
")",
"{",
"$",
"report",
"=",
"$",
"this",
"->",
"reportManager",
"->",
"getLastStartedByConfiguration",
"(",
"$",
"configuration",
")",
";",
"return",
"$",
"report",
"&&",
"$",
"report",
"->",
"getPid",
"(",
")",
"&&",
"(",
"false",
"===",
"$",
"report",
"->",
"isSuccessful",
"(",
")",
")",
"&&",
"!",
"posix_getsid",
"(",
"$",
"report",
"->",
"getPid",
"(",
")",
")",
";",
"}"
] |
Checks or job is dead.
@param JobConfigurationInterface $configuration
@return bool
|
[
"Checks",
"or",
"job",
"is",
"dead",
"."
] |
0e488ca123d3105cf791173e3147ede1bcf39018
|
https://github.com/Aureja/JobQueue/blob/0e488ca123d3105cf791173e3147ede1bcf39018/src/JobRestoreManager.php#L101-L106
|
239,673
|
Puzzlout/FrameworkMvcLegacy
|
src/GeneratorEngine/Core/ResourceConstantsClassGenerator.php
|
ResourceConstantsClassGenerator.WriteContent
|
public function WriteContent() {
$output = $this->WriteGetListMethod();
$output .= PhpCodeSnippets::CRLF;
fwrite($this->writer, $output);
}
|
php
|
public function WriteContent() {
$output = $this->WriteGetListMethod();
$output .= PhpCodeSnippets::CRLF;
fwrite($this->writer, $output);
}
|
[
"public",
"function",
"WriteContent",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"WriteGetListMethod",
"(",
")",
";",
"$",
"output",
".=",
"PhpCodeSnippets",
"::",
"CRLF",
";",
"fwrite",
"(",
"$",
"this",
"->",
"writer",
",",
"$",
"output",
")",
";",
"}"
] |
Write the content of the class, method by method.
|
[
"Write",
"the",
"content",
"of",
"the",
"class",
"method",
"by",
"method",
"."
] |
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
|
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/GeneratorEngine/Core/ResourceConstantsClassGenerator.php#L145-L149
|
239,674
|
Puzzlout/FrameworkMvcLegacy
|
src/GeneratorEngine/Core/ResourceConstantsClassGenerator.php
|
ResourceConstantsClassGenerator.WriteNewArrayAndItsContents
|
public function WriteNewArrayAndItsContents($array, $arrayOpened = false, $tabAmount = 0) {
$output = "";
foreach ($array as $key => $value) {
if (is_array($value)) {
$output .= $this->WriteAssociativeArrayValueAsNewArray($key, $tabAmount); //new array opened
$output .= $this->WriteNewArrayAndItsContents($value, true, $tabAmount);
} else {
$output .= $this->WriteAssociativeArrayValueWithKeyAndValue($key, $value, $tabAmount);
}
}
if ($arrayOpened) {
$output .= $this->CloseArray($tabAmount - 1);
}
return $output;
}
|
php
|
public function WriteNewArrayAndItsContents($array, $arrayOpened = false, $tabAmount = 0) {
$output = "";
foreach ($array as $key => $value) {
if (is_array($value)) {
$output .= $this->WriteAssociativeArrayValueAsNewArray($key, $tabAmount); //new array opened
$output .= $this->WriteNewArrayAndItsContents($value, true, $tabAmount);
} else {
$output .= $this->WriteAssociativeArrayValueWithKeyAndValue($key, $value, $tabAmount);
}
}
if ($arrayOpened) {
$output .= $this->CloseArray($tabAmount - 1);
}
return $output;
}
|
[
"public",
"function",
"WriteNewArrayAndItsContents",
"(",
"$",
"array",
",",
"$",
"arrayOpened",
"=",
"false",
",",
"$",
"tabAmount",
"=",
"0",
")",
"{",
"$",
"output",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"WriteAssociativeArrayValueAsNewArray",
"(",
"$",
"key",
",",
"$",
"tabAmount",
")",
";",
"//new array opened",
"$",
"output",
".=",
"$",
"this",
"->",
"WriteNewArrayAndItsContents",
"(",
"$",
"value",
",",
"true",
",",
"$",
"tabAmount",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"WriteAssociativeArrayValueWithKeyAndValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"tabAmount",
")",
";",
"}",
"}",
"if",
"(",
"$",
"arrayOpened",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"CloseArray",
"(",
"$",
"tabAmount",
"-",
"1",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Recursively writes an array from an array of values.
@param array $array the array to loop through to generate the values given.
@param type $arrayOpened flag to specify if an array is opened and needs to
be closed before moving on.
@param type $tabAmount the number of tabs or 2 spaces to print in the generated
code.
@return string the code generated.
|
[
"Recursively",
"writes",
"an",
"array",
"from",
"an",
"array",
"of",
"values",
"."
] |
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
|
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/GeneratorEngine/Core/ResourceConstantsClassGenerator.php#L190-L204
|
239,675
|
DGAC/MattermostModule
|
src/MattermostMessenger/Controller/MattermostChatController.php
|
MattermostChatController.ackAction
|
public function ackAction()
{
$json = array();
$postId = $this->params()->fromQuery('postid', null);
$response = $this->mattermost->saveReaction($postId, 'ok');
$json['result'] = $response;
return new JsonModel($json);
}
|
php
|
public function ackAction()
{
$json = array();
$postId = $this->params()->fromQuery('postid', null);
$response = $this->mattermost->saveReaction($postId, 'ok');
$json['result'] = $response;
return new JsonModel($json);
}
|
[
"public",
"function",
"ackAction",
"(",
")",
"{",
"$",
"json",
"=",
"array",
"(",
")",
";",
"$",
"postId",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'postid'",
",",
"null",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"mattermost",
"->",
"saveReaction",
"(",
"$",
"postId",
",",
"'ok'",
")",
";",
"$",
"json",
"[",
"'result'",
"]",
"=",
"$",
"response",
";",
"return",
"new",
"JsonModel",
"(",
"$",
"json",
")",
";",
"}"
] |
Post a 'ok' reaction to send an acknowledge
@return JsonModel
|
[
"Post",
"a",
"ok",
"reaction",
"to",
"send",
"an",
"acknowledge"
] |
02da5791d70715d2478d816c28fc034707c9d341
|
https://github.com/DGAC/MattermostModule/blob/02da5791d70715d2478d816c28fc034707c9d341/src/MattermostMessenger/Controller/MattermostChatController.php#L251-L258
|
239,676
|
DGAC/MattermostModule
|
src/MattermostMessenger/Controller/MattermostChatController.php
|
MattermostChatController.isAckAction
|
public function isAckAction()
{
$json = array();
$postId = $this->params()->fromQuery('postid', null);
$myReactions = $this->mattermost->getMyReactions($postId);
$ok = array_filter($myReactions, function($v){
return strcmp($v['emoji_name'], 'ok') == 0;
});
$json['ack'] = count($ok) == 1;
return new JsonModel($json);
}
|
php
|
public function isAckAction()
{
$json = array();
$postId = $this->params()->fromQuery('postid', null);
$myReactions = $this->mattermost->getMyReactions($postId);
$ok = array_filter($myReactions, function($v){
return strcmp($v['emoji_name'], 'ok') == 0;
});
$json['ack'] = count($ok) == 1;
return new JsonModel($json);
}
|
[
"public",
"function",
"isAckAction",
"(",
")",
"{",
"$",
"json",
"=",
"array",
"(",
")",
";",
"$",
"postId",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'postid'",
",",
"null",
")",
";",
"$",
"myReactions",
"=",
"$",
"this",
"->",
"mattermost",
"->",
"getMyReactions",
"(",
"$",
"postId",
")",
";",
"$",
"ok",
"=",
"array_filter",
"(",
"$",
"myReactions",
",",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"strcmp",
"(",
"$",
"v",
"[",
"'emoji_name'",
"]",
",",
"'ok'",
")",
"==",
"0",
";",
"}",
")",
";",
"$",
"json",
"[",
"'ack'",
"]",
"=",
"count",
"(",
"$",
"ok",
")",
"==",
"1",
";",
"return",
"new",
"JsonModel",
"(",
"$",
"json",
")",
";",
"}"
] |
Test if the post has a "ok" reaction, signifying the post has already been aknowledged
@return JsonModel
|
[
"Test",
"if",
"the",
"post",
"has",
"a",
"ok",
"reaction",
"signifying",
"the",
"post",
"has",
"already",
"been",
"aknowledged"
] |
02da5791d70715d2478d816c28fc034707c9d341
|
https://github.com/DGAC/MattermostModule/blob/02da5791d70715d2478d816c28fc034707c9d341/src/MattermostMessenger/Controller/MattermostChatController.php#L279-L289
|
239,677
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrate
|
public function migrate(array $filters)
{
$this->filters =$filters;
foreach ($this->academicPeriods() as $period) {
$this->period = $period->id;
$this->setDestinationConnectionByPeriod($this->period);
$this->switchToDestinationConnection();
$this->output->info('Migrating period: ' . $period->name . '(' . $period->id . ')');
$this->migrateTeachers();
$this->migrateLocations();
$this->migrateCurriculum();
$this->migrateClassrooms();
$this->migrateEnrollments();
$this->seedDays();
$this->seedShifts();
$this->migrateTimeslots();
$this->migrateLessons();
}
}
|
php
|
public function migrate(array $filters)
{
$this->filters =$filters;
foreach ($this->academicPeriods() as $period) {
$this->period = $period->id;
$this->setDestinationConnectionByPeriod($this->period);
$this->switchToDestinationConnection();
$this->output->info('Migrating period: ' . $period->name . '(' . $period->id . ')');
$this->migrateTeachers();
$this->migrateLocations();
$this->migrateCurriculum();
$this->migrateClassrooms();
$this->migrateEnrollments();
$this->seedDays();
$this->seedShifts();
$this->migrateTimeslots();
$this->migrateLessons();
}
}
|
[
"public",
"function",
"migrate",
"(",
"array",
"$",
"filters",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"$",
"filters",
";",
"foreach",
"(",
"$",
"this",
"->",
"academicPeriods",
"(",
")",
"as",
"$",
"period",
")",
"{",
"$",
"this",
"->",
"period",
"=",
"$",
"period",
"->",
"id",
";",
"$",
"this",
"->",
"setDestinationConnectionByPeriod",
"(",
"$",
"this",
"->",
"period",
")",
";",
"$",
"this",
"->",
"switchToDestinationConnection",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'Migrating period: '",
".",
"$",
"period",
"->",
"name",
".",
"'('",
".",
"$",
"period",
"->",
"id",
".",
"')'",
")",
";",
"$",
"this",
"->",
"migrateTeachers",
"(",
")",
";",
"$",
"this",
"->",
"migrateLocations",
"(",
")",
";",
"$",
"this",
"->",
"migrateCurriculum",
"(",
")",
";",
"$",
"this",
"->",
"migrateClassrooms",
"(",
")",
";",
"$",
"this",
"->",
"migrateEnrollments",
"(",
")",
";",
"$",
"this",
"->",
"seedDays",
"(",
")",
";",
"$",
"this",
"->",
"seedShifts",
"(",
")",
";",
"$",
"this",
"->",
"migrateTimeslots",
"(",
")",
";",
"$",
"this",
"->",
"migrateLessons",
"(",
")",
";",
"}",
"}"
] |
Migrate old database to new database.
@param array $filters
@return void
|
[
"Migrate",
"old",
"database",
"to",
"new",
"database",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L366-L384
|
239,678
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateTeachers
|
protected function migrateTeachers()
{
$this->output->info('### Migrating teachers ###');
foreach ($this->teachers() as $teacher) {
$this->showMigratingInfo($teacher, 1);
$this->output->info(' email: ' . $teacher->email);
$this->migrateTeacher($teacher);
}
$this->output->info(
'### END Migrating teachers. Migrated ' . count($this->teachers()) . ' teachers ###');
}
|
php
|
protected function migrateTeachers()
{
$this->output->info('### Migrating teachers ###');
foreach ($this->teachers() as $teacher) {
$this->showMigratingInfo($teacher, 1);
$this->output->info(' email: ' . $teacher->email);
$this->migrateTeacher($teacher);
}
$this->output->info(
'### END Migrating teachers. Migrated ' . count($this->teachers()) . ' teachers ###');
}
|
[
"protected",
"function",
"migrateTeachers",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Migrating teachers ###'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"teachers",
"(",
")",
"as",
"$",
"teacher",
")",
"{",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"teacher",
",",
"1",
")",
";",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"' email: '",
".",
"$",
"teacher",
"->",
"email",
")",
";",
"$",
"this",
"->",
"migrateTeacher",
"(",
"$",
"teacher",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### END Migrating teachers. Migrated '",
".",
"count",
"(",
"$",
"this",
"->",
"teachers",
"(",
")",
")",
".",
"' teachers ###'",
")",
";",
"}"
] |
Migrate teachers.
|
[
"Migrate",
"teachers",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L389-L399
|
239,679
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateTeacher
|
protected function migrateTeacher(Teacher $teacher) {
$user = User::firstOrNew([
'email' => $teacher->email,
]);
$user->name = $teacher->name;
$user->password = bcrypt('secret');
$user->remember_token = str_random(10);
$user->save();
//TODO: migrate teacher codes, create roles and assign to user/teachers
}
|
php
|
protected function migrateTeacher(Teacher $teacher) {
$user = User::firstOrNew([
'email' => $teacher->email,
]);
$user->name = $teacher->name;
$user->password = bcrypt('secret');
$user->remember_token = str_random(10);
$user->save();
//TODO: migrate teacher codes, create roles and assign to user/teachers
}
|
[
"protected",
"function",
"migrateTeacher",
"(",
"Teacher",
"$",
"teacher",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"firstOrNew",
"(",
"[",
"'email'",
"=>",
"$",
"teacher",
"->",
"email",
",",
"]",
")",
";",
"$",
"user",
"->",
"name",
"=",
"$",
"teacher",
"->",
"name",
";",
"$",
"user",
"->",
"password",
"=",
"bcrypt",
"(",
"'secret'",
")",
";",
"$",
"user",
"->",
"remember_token",
"=",
"str_random",
"(",
"10",
")",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"//TODO: migrate teacher codes, create roles and assign to user/teachers",
"}"
] |
Migrate teacher.
@param Teacher $teacher
|
[
"Migrate",
"teacher",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L406-L415
|
239,680
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateEnrollment
|
protected function migrateEnrollment($enrollment)
{
$user = $this->migratePerson($enrollment->person);
try {
$enrollment = ScoolEnrollment::firstOrNew([
'user_id' => $user->id,
'study_id' => $this->translateStudyId($enrollment->study_id),
'course_id' => $this->translateCourseId($enrollment->course_id),
'classroom_id' => $this->translateClassroomId($enrollment->group_id)
]);
$enrollment->state='Validated';
$enrollment->save();
return $enrollment;
} catch (\Exception $e) {
$this->output->error(
'Error migrating enrollment. ' . class_basename($e) . ' ' . $e->getMessage());
return null;
}
}
|
php
|
protected function migrateEnrollment($enrollment)
{
$user = $this->migratePerson($enrollment->person);
try {
$enrollment = ScoolEnrollment::firstOrNew([
'user_id' => $user->id,
'study_id' => $this->translateStudyId($enrollment->study_id),
'course_id' => $this->translateCourseId($enrollment->course_id),
'classroom_id' => $this->translateClassroomId($enrollment->group_id)
]);
$enrollment->state='Validated';
$enrollment->save();
return $enrollment;
} catch (\Exception $e) {
$this->output->error(
'Error migrating enrollment. ' . class_basename($e) . ' ' . $e->getMessage());
return null;
}
}
|
[
"protected",
"function",
"migrateEnrollment",
"(",
"$",
"enrollment",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"migratePerson",
"(",
"$",
"enrollment",
"->",
"person",
")",
";",
"try",
"{",
"$",
"enrollment",
"=",
"ScoolEnrollment",
"::",
"firstOrNew",
"(",
"[",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'study_id'",
"=>",
"$",
"this",
"->",
"translateStudyId",
"(",
"$",
"enrollment",
"->",
"study_id",
")",
",",
"'course_id'",
"=>",
"$",
"this",
"->",
"translateCourseId",
"(",
"$",
"enrollment",
"->",
"course_id",
")",
",",
"'classroom_id'",
"=>",
"$",
"this",
"->",
"translateClassroomId",
"(",
"$",
"enrollment",
"->",
"group_id",
")",
"]",
")",
";",
"$",
"enrollment",
"->",
"state",
"=",
"'Validated'",
";",
"$",
"enrollment",
"->",
"save",
"(",
")",
";",
"return",
"$",
"enrollment",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"error",
"(",
"'Error migrating enrollment. '",
".",
"class_basename",
"(",
"$",
"e",
")",
".",
"' '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Migrate ebre-escool enrollment to scool enrollment.
@param $enrollment
@return null
|
[
"Migrate",
"ebre",
"-",
"escool",
"enrollment",
"to",
"scool",
"enrollment",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L423-L441
|
239,681
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateLesson
|
protected function migrateLesson($oldLesson)
{
if ($this->lessonNotExists($oldLesson)) {
DB::beginTransaction();
try {
$lesson = new ScoolLesson;
$lesson->location_id = $this->translateLocationId($oldLesson->location_id);
$lesson->day_id = $this->translateDayId($oldLesson->day);
$lesson->timeslot_id = $this->translateTimeslotId($oldLesson->time_slot_id);
$lesson->state='Validated';
$lesson->save();
$lesson->addTeacher($this->translateTeacher($oldLesson->teacher_id));
$module = Module::findOrFail($this->translateModuleId($oldLesson->study_module_id));
foreach ($module->submodules as $submodule) {
$lesson->addSubmodule($submodule);
}
$classroom = Classroom::findOrFail($this->translateClassroomId($oldLesson->classroom_group_id));
$lesson->addClassroom($classroom);
$lesson_migration = new LessonMigration();
$lesson_migration->newlesson_id = $lesson->id;
$lesson_migration->lesson()->associate($oldLesson);
$lesson_migration->save();
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->output->error(
'Error migrating lesson. ' . class_basename($e) . ' ' . $e->getMessage());
return null;
}
}
}
|
php
|
protected function migrateLesson($oldLesson)
{
if ($this->lessonNotExists($oldLesson)) {
DB::beginTransaction();
try {
$lesson = new ScoolLesson;
$lesson->location_id = $this->translateLocationId($oldLesson->location_id);
$lesson->day_id = $this->translateDayId($oldLesson->day);
$lesson->timeslot_id = $this->translateTimeslotId($oldLesson->time_slot_id);
$lesson->state='Validated';
$lesson->save();
$lesson->addTeacher($this->translateTeacher($oldLesson->teacher_id));
$module = Module::findOrFail($this->translateModuleId($oldLesson->study_module_id));
foreach ($module->submodules as $submodule) {
$lesson->addSubmodule($submodule);
}
$classroom = Classroom::findOrFail($this->translateClassroomId($oldLesson->classroom_group_id));
$lesson->addClassroom($classroom);
$lesson_migration = new LessonMigration();
$lesson_migration->newlesson_id = $lesson->id;
$lesson_migration->lesson()->associate($oldLesson);
$lesson_migration->save();
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
$this->output->error(
'Error migrating lesson. ' . class_basename($e) . ' ' . $e->getMessage());
return null;
}
}
}
|
[
"protected",
"function",
"migrateLesson",
"(",
"$",
"oldLesson",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lessonNotExists",
"(",
"$",
"oldLesson",
")",
")",
"{",
"DB",
"::",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"lesson",
"=",
"new",
"ScoolLesson",
";",
"$",
"lesson",
"->",
"location_id",
"=",
"$",
"this",
"->",
"translateLocationId",
"(",
"$",
"oldLesson",
"->",
"location_id",
")",
";",
"$",
"lesson",
"->",
"day_id",
"=",
"$",
"this",
"->",
"translateDayId",
"(",
"$",
"oldLesson",
"->",
"day",
")",
";",
"$",
"lesson",
"->",
"timeslot_id",
"=",
"$",
"this",
"->",
"translateTimeslotId",
"(",
"$",
"oldLesson",
"->",
"time_slot_id",
")",
";",
"$",
"lesson",
"->",
"state",
"=",
"'Validated'",
";",
"$",
"lesson",
"->",
"save",
"(",
")",
";",
"$",
"lesson",
"->",
"addTeacher",
"(",
"$",
"this",
"->",
"translateTeacher",
"(",
"$",
"oldLesson",
"->",
"teacher_id",
")",
")",
";",
"$",
"module",
"=",
"Module",
"::",
"findOrFail",
"(",
"$",
"this",
"->",
"translateModuleId",
"(",
"$",
"oldLesson",
"->",
"study_module_id",
")",
")",
";",
"foreach",
"(",
"$",
"module",
"->",
"submodules",
"as",
"$",
"submodule",
")",
"{",
"$",
"lesson",
"->",
"addSubmodule",
"(",
"$",
"submodule",
")",
";",
"}",
"$",
"classroom",
"=",
"Classroom",
"::",
"findOrFail",
"(",
"$",
"this",
"->",
"translateClassroomId",
"(",
"$",
"oldLesson",
"->",
"classroom_group_id",
")",
")",
";",
"$",
"lesson",
"->",
"addClassroom",
"(",
"$",
"classroom",
")",
";",
"$",
"lesson_migration",
"=",
"new",
"LessonMigration",
"(",
")",
";",
"$",
"lesson_migration",
"->",
"newlesson_id",
"=",
"$",
"lesson",
"->",
"id",
";",
"$",
"lesson_migration",
"->",
"lesson",
"(",
")",
"->",
"associate",
"(",
"$",
"oldLesson",
")",
";",
"$",
"lesson_migration",
"->",
"save",
"(",
")",
";",
"DB",
"::",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"DB",
"::",
"rollBack",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"error",
"(",
"'Error migrating lesson. '",
".",
"class_basename",
"(",
"$",
"e",
")",
".",
"' '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}",
"}"
] |
Migrate lesson.
|
[
"Migrate",
"lesson",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L447-L480
|
239,682
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateEnrollmentDetail
|
protected function migrateEnrollmentDetail($enrollmentDetail,$enrollment_id)
{
try {
$enrollment = ScoolEnrollmentSubmodule::firstOrNew([
'enrollment_id' => $enrollment_id,
'module_id' => $this->translateModuleId($enrollmentDetail->moduleid),
'submodule_id' => $this->translateSubmoduleId($enrollmentDetail->submoduleid),
]);
$enrollment->state='Validated';
$enrollment->save();
} catch (\Exception $e) {
$this->output->error(
'Error migrating enrollment detail. ' . class_basename($e) . ' ' . $e->getMessage());
}
}
|
php
|
protected function migrateEnrollmentDetail($enrollmentDetail,$enrollment_id)
{
try {
$enrollment = ScoolEnrollmentSubmodule::firstOrNew([
'enrollment_id' => $enrollment_id,
'module_id' => $this->translateModuleId($enrollmentDetail->moduleid),
'submodule_id' => $this->translateSubmoduleId($enrollmentDetail->submoduleid),
]);
$enrollment->state='Validated';
$enrollment->save();
} catch (\Exception $e) {
$this->output->error(
'Error migrating enrollment detail. ' . class_basename($e) . ' ' . $e->getMessage());
}
}
|
[
"protected",
"function",
"migrateEnrollmentDetail",
"(",
"$",
"enrollmentDetail",
",",
"$",
"enrollment_id",
")",
"{",
"try",
"{",
"$",
"enrollment",
"=",
"ScoolEnrollmentSubmodule",
"::",
"firstOrNew",
"(",
"[",
"'enrollment_id'",
"=>",
"$",
"enrollment_id",
",",
"'module_id'",
"=>",
"$",
"this",
"->",
"translateModuleId",
"(",
"$",
"enrollmentDetail",
"->",
"moduleid",
")",
",",
"'submodule_id'",
"=>",
"$",
"this",
"->",
"translateSubmoduleId",
"(",
"$",
"enrollmentDetail",
"->",
"submoduleid",
")",
",",
"]",
")",
";",
"$",
"enrollment",
"->",
"state",
"=",
"'Validated'",
";",
"$",
"enrollment",
"->",
"save",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"error",
"(",
"'Error migrating enrollment detail. '",
".",
"class_basename",
"(",
"$",
"e",
")",
".",
"' '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Migrate ebre-escool enrollment detail to scool enrollment.
@param $enrollmentDetail
@param $enrollment_id
|
[
"Migrate",
"ebre",
"-",
"escool",
"enrollment",
"detail",
"to",
"scool",
"enrollment",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L525-L539
|
239,683
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.translateLocationId
|
protected function translateLocationId($oldLocationId)
{
$location = ScoolLocation::where('name',Location::findOrFail($oldLocationId)->name)->first();
if ( $location != null ) {
return $location->id;
}
throw new LocationNotFoundByNameException();
}
|
php
|
protected function translateLocationId($oldLocationId)
{
$location = ScoolLocation::where('name',Location::findOrFail($oldLocationId)->name)->first();
if ( $location != null ) {
return $location->id;
}
throw new LocationNotFoundByNameException();
}
|
[
"protected",
"function",
"translateLocationId",
"(",
"$",
"oldLocationId",
")",
"{",
"$",
"location",
"=",
"ScoolLocation",
"::",
"where",
"(",
"'name'",
",",
"Location",
"::",
"findOrFail",
"(",
"$",
"oldLocationId",
")",
"->",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"location",
"!=",
"null",
")",
"{",
"return",
"$",
"location",
"->",
"id",
";",
"}",
"throw",
"new",
"LocationNotFoundByNameException",
"(",
")",
";",
"}"
] |
Translate location id.
@param $oldLocationId
@return mixed
@throws LocationNotFoundByNameException
|
[
"Translate",
"location",
"id",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L559-L566
|
239,684
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.translateTimeslotId
|
protected function translateTimeslotId($oldTimeslotId)
{
$timeslot = ScoolTimeslot::where('order',Timeslot::findOrFail($oldTimeslotId)->order)->first();
if ( $timeslot != null ) {
return $timeslot->id;
}
throw new TimeslotNotFoundByNameException();
}
|
php
|
protected function translateTimeslotId($oldTimeslotId)
{
$timeslot = ScoolTimeslot::where('order',Timeslot::findOrFail($oldTimeslotId)->order)->first();
if ( $timeslot != null ) {
return $timeslot->id;
}
throw new TimeslotNotFoundByNameException();
}
|
[
"protected",
"function",
"translateTimeslotId",
"(",
"$",
"oldTimeslotId",
")",
"{",
"$",
"timeslot",
"=",
"ScoolTimeslot",
"::",
"where",
"(",
"'order'",
",",
"Timeslot",
"::",
"findOrFail",
"(",
"$",
"oldTimeslotId",
")",
"->",
"order",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"timeslot",
"!=",
"null",
")",
"{",
"return",
"$",
"timeslot",
"->",
"id",
";",
"}",
"throw",
"new",
"TimeslotNotFoundByNameException",
"(",
")",
";",
"}"
] |
Translate timeslot id.
@param $oldTimeslotId
@return mixed
@throws TimeslotNotFoundByNameException
|
[
"Translate",
"timeslot",
"id",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L603-L610
|
239,685
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.translateModuleId
|
protected function translateModuleId($oldModuleId)
{
$module = Module::where('name',StudyModule::findOrFail($oldModuleId)->name)->first();
if ( $module != null ) {
return $module->id;
}
throw new ModuleNotFoundByNameException();
}
|
php
|
protected function translateModuleId($oldModuleId)
{
$module = Module::where('name',StudyModule::findOrFail($oldModuleId)->name)->first();
if ( $module != null ) {
return $module->id;
}
throw new ModuleNotFoundByNameException();
}
|
[
"protected",
"function",
"translateModuleId",
"(",
"$",
"oldModuleId",
")",
"{",
"$",
"module",
"=",
"Module",
"::",
"where",
"(",
"'name'",
",",
"StudyModule",
"::",
"findOrFail",
"(",
"$",
"oldModuleId",
")",
"->",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"module",
"!=",
"null",
")",
"{",
"return",
"$",
"module",
"->",
"id",
";",
"}",
"throw",
"new",
"ModuleNotFoundByNameException",
"(",
")",
";",
"}"
] |
Translate module id.
@param $oldModuleId
@return
@throws ModuleNotFoundByNameException
|
[
"Translate",
"module",
"id",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L619-L626
|
239,686
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.translateSubmoduleId
|
protected function translateSubmoduleId($oldSubModuleId)
{
$submodule = Submodule::where('name',StudySubModule::findOrFail($oldSubModuleId)->name)->first();
if ( $submodule != null ) {
return $submodule->id;
}
throw new SubmoduleNotFoundByNameException();
}
|
php
|
protected function translateSubmoduleId($oldSubModuleId)
{
$submodule = Submodule::where('name',StudySubModule::findOrFail($oldSubModuleId)->name)->first();
if ( $submodule != null ) {
return $submodule->id;
}
throw new SubmoduleNotFoundByNameException();
}
|
[
"protected",
"function",
"translateSubmoduleId",
"(",
"$",
"oldSubModuleId",
")",
"{",
"$",
"submodule",
"=",
"Submodule",
"::",
"where",
"(",
"'name'",
",",
"StudySubModule",
"::",
"findOrFail",
"(",
"$",
"oldSubModuleId",
")",
"->",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"submodule",
"!=",
"null",
")",
"{",
"return",
"$",
"submodule",
"->",
"id",
";",
"}",
"throw",
"new",
"SubmoduleNotFoundByNameException",
"(",
")",
";",
"}"
] |
Translate submodule id.
@param $oldSubModuleId
@return
@throws SubmoduleNotFoundByNameException
|
[
"Translate",
"submodule",
"id",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L635-L642
|
239,687
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.translateStudyId
|
protected function translateStudyId($oldStudyId)
{
$study = ScoolStudy::where('name',Study::findOrFail($oldStudyId)->name)->first();
if ( $study != null ) {
return $study->id;
}
throw new StudyNotFoundByNameException();
}
|
php
|
protected function translateStudyId($oldStudyId)
{
$study = ScoolStudy::where('name',Study::findOrFail($oldStudyId)->name)->first();
if ( $study != null ) {
return $study->id;
}
throw new StudyNotFoundByNameException();
}
|
[
"protected",
"function",
"translateStudyId",
"(",
"$",
"oldStudyId",
")",
"{",
"$",
"study",
"=",
"ScoolStudy",
"::",
"where",
"(",
"'name'",
",",
"Study",
"::",
"findOrFail",
"(",
"$",
"oldStudyId",
")",
"->",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"study",
"!=",
"null",
")",
"{",
"return",
"$",
"study",
"->",
"id",
";",
"}",
"throw",
"new",
"StudyNotFoundByNameException",
"(",
")",
";",
"}"
] |
Translate old ebre-escool study id to scool id.
@param $oldStudyId
@return mixed
@throws StudyNotFoundByNameException
|
[
"Translate",
"old",
"ebre",
"-",
"escool",
"study",
"id",
"to",
"scool",
"id",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L652-L659
|
239,688
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.translateCourseId
|
protected function translateCourseId($oldCourseId)
{
$course = ScoolCourse::where('name',Course::findOrFail($oldCourseId)->name)->first();
if ( $course != null ) {
return $course->id;
}
throw new CourseNotFoundByNameException();
}
|
php
|
protected function translateCourseId($oldCourseId)
{
$course = ScoolCourse::where('name',Course::findOrFail($oldCourseId)->name)->first();
if ( $course != null ) {
return $course->id;
}
throw new CourseNotFoundByNameException();
}
|
[
"protected",
"function",
"translateCourseId",
"(",
"$",
"oldCourseId",
")",
"{",
"$",
"course",
"=",
"ScoolCourse",
"::",
"where",
"(",
"'name'",
",",
"Course",
"::",
"findOrFail",
"(",
"$",
"oldCourseId",
")",
"->",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"course",
"!=",
"null",
")",
"{",
"return",
"$",
"course",
"->",
"id",
";",
"}",
"throw",
"new",
"CourseNotFoundByNameException",
"(",
")",
";",
"}"
] |
Translate old ebre-escool course id to scool id.
@param $oldCourseId
@return mixed
@throws CourseNotFoundByNameException
|
[
"Translate",
"old",
"ebre",
"-",
"escool",
"course",
"id",
"to",
"scool",
"id",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L668-L675
|
239,689
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.translateClassroomId
|
protected function translateClassroomId($oldClassroomId)
{
$classroom = Classroom::where('name',ClassroomGroup::findOrFail($oldClassroomId)->name)->first();
if ( $classroom != null ) {
return $classroom->id;
}
throw new ClassroomNotFoundByNameException();
}
|
php
|
protected function translateClassroomId($oldClassroomId)
{
$classroom = Classroom::where('name',ClassroomGroup::findOrFail($oldClassroomId)->name)->first();
if ( $classroom != null ) {
return $classroom->id;
}
throw new ClassroomNotFoundByNameException();
}
|
[
"protected",
"function",
"translateClassroomId",
"(",
"$",
"oldClassroomId",
")",
"{",
"$",
"classroom",
"=",
"Classroom",
"::",
"where",
"(",
"'name'",
",",
"ClassroomGroup",
"::",
"findOrFail",
"(",
"$",
"oldClassroomId",
")",
"->",
"name",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"classroom",
"!=",
"null",
")",
"{",
"return",
"$",
"classroom",
"->",
"id",
";",
"}",
"throw",
"new",
"ClassroomNotFoundByNameException",
"(",
")",
";",
"}"
] |
Translate old ebre-escool classroom id to scool id.
@param $oldClassroomId
@return integer
@throws ClassroomNotFoundByNameException
|
[
"Translate",
"old",
"ebre",
"-",
"escool",
"classroom",
"id",
"to",
"scool",
"id",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L684-L691
|
239,690
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migratePerson
|
protected function migratePerson($person)
{
//TODO create person in personal data table
$user = User::firstOrNew([
'email' => $person->email,
]);
$user->name = $person->name;
$user->password = bcrypt('secret');
$user->remember_token = str_random(10);
$user->save();
return $user;
}
|
php
|
protected function migratePerson($person)
{
//TODO create person in personal data table
$user = User::firstOrNew([
'email' => $person->email,
]);
$user->name = $person->name;
$user->password = bcrypt('secret');
$user->remember_token = str_random(10);
$user->save();
return $user;
}
|
[
"protected",
"function",
"migratePerson",
"(",
"$",
"person",
")",
"{",
"//TODO create person in personal data table",
"$",
"user",
"=",
"User",
"::",
"firstOrNew",
"(",
"[",
"'email'",
"=>",
"$",
"person",
"->",
"email",
",",
"]",
")",
";",
"$",
"user",
"->",
"name",
"=",
"$",
"person",
"->",
"name",
";",
"$",
"user",
"->",
"password",
"=",
"bcrypt",
"(",
"'secret'",
")",
";",
"$",
"user",
"->",
"remember_token",
"=",
"str_random",
"(",
"10",
")",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
Migrate ebre-escool person to scool person.
@param $person
|
[
"Migrate",
"ebre",
"-",
"escool",
"person",
"to",
"scool",
"person",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L698-L709
|
239,691
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateClassrooms
|
protected function migrateClassrooms()
{
$this->output->info('### Migrating classrooms ###');
foreach ($classrooms = $this->classrooms() as $classroom) {
$this->showMigratingInfo($classroom, 1);
$this->migrateClassroom($classroom);
}
$this->output->info(
'### END Migrating classrooms. Migrated ' . count($classrooms) . ' locations ###');
}
|
php
|
protected function migrateClassrooms()
{
$this->output->info('### Migrating classrooms ###');
foreach ($classrooms = $this->classrooms() as $classroom) {
$this->showMigratingInfo($classroom, 1);
$this->migrateClassroom($classroom);
}
$this->output->info(
'### END Migrating classrooms. Migrated ' . count($classrooms) . ' locations ###');
}
|
[
"protected",
"function",
"migrateClassrooms",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Migrating classrooms ###'",
")",
";",
"foreach",
"(",
"$",
"classrooms",
"=",
"$",
"this",
"->",
"classrooms",
"(",
")",
"as",
"$",
"classroom",
")",
"{",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"classroom",
",",
"1",
")",
";",
"$",
"this",
"->",
"migrateClassroom",
"(",
"$",
"classroom",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### END Migrating classrooms. Migrated '",
".",
"count",
"(",
"$",
"classrooms",
")",
".",
"' locations ###'",
")",
";",
"}"
] |
Migrate classrooms.
|
[
"Migrate",
"classrooms",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L714-L723
|
239,692
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateLocations
|
protected function migrateLocations()
{
$this->output->info('### Migrating locations ###');
foreach ($this->locations() as $location) {
$this->showMigratingInfo($location, 1);
$this->migrateLocation($location);
}
$this->output->info(
'### END Migrating locations. Migrated ' . count($this->locations()) . ' locations ###');
}
|
php
|
protected function migrateLocations()
{
$this->output->info('### Migrating locations ###');
foreach ($this->locations() as $location) {
$this->showMigratingInfo($location, 1);
$this->migrateLocation($location);
}
$this->output->info(
'### END Migrating locations. Migrated ' . count($this->locations()) . ' locations ###');
}
|
[
"protected",
"function",
"migrateLocations",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Migrating locations ###'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"locations",
"(",
")",
"as",
"$",
"location",
")",
"{",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"location",
",",
"1",
")",
";",
"$",
"this",
"->",
"migrateLocation",
"(",
"$",
"location",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### END Migrating locations. Migrated '",
".",
"count",
"(",
"$",
"this",
"->",
"locations",
"(",
")",
")",
".",
"' locations ###'",
")",
";",
"}"
] |
Migrate locations.
|
[
"Migrate",
"locations",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L728-L737
|
239,693
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateLocation
|
protected function migrateLocation($srcLocation) {
$location = ScoolLocation::firstOrNew([
'name' => $srcLocation->name,
]);
$location->save();
$location->shortname = $srcLocation->shortName;
$location->description = $srcLocation->description;
$location->code = $srcLocation->external_code;
}
|
php
|
protected function migrateLocation($srcLocation) {
$location = ScoolLocation::firstOrNew([
'name' => $srcLocation->name,
]);
$location->save();
$location->shortname = $srcLocation->shortName;
$location->description = $srcLocation->description;
$location->code = $srcLocation->external_code;
}
|
[
"protected",
"function",
"migrateLocation",
"(",
"$",
"srcLocation",
")",
"{",
"$",
"location",
"=",
"ScoolLocation",
"::",
"firstOrNew",
"(",
"[",
"'name'",
"=>",
"$",
"srcLocation",
"->",
"name",
",",
"]",
")",
";",
"$",
"location",
"->",
"save",
"(",
")",
";",
"$",
"location",
"->",
"shortname",
"=",
"$",
"srcLocation",
"->",
"shortName",
";",
"$",
"location",
"->",
"description",
"=",
"$",
"srcLocation",
"->",
"description",
";",
"$",
"location",
"->",
"code",
"=",
"$",
"srcLocation",
"->",
"external_code",
";",
"}"
] |
Migrate location.
@param $srcLocation
|
[
"Migrate",
"location",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L744-L752
|
239,694
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateClassroom
|
protected function migrateClassroom($srcClassroom) {
$classroom = Classroom::firstOrNew([
'name' => $srcClassroom->name,
]);
$classroom->save();
$this->addCourseToClassroom($classroom, $srcClassroom->course_id);
$classroom->shortname = $srcClassroom->shortName;
$classroom->description = $srcClassroom->description;
$classroom->code = $srcClassroom->external_code;
}
|
php
|
protected function migrateClassroom($srcClassroom) {
$classroom = Classroom::firstOrNew([
'name' => $srcClassroom->name,
]);
$classroom->save();
$this->addCourseToClassroom($classroom, $srcClassroom->course_id);
$classroom->shortname = $srcClassroom->shortName;
$classroom->description = $srcClassroom->description;
$classroom->code = $srcClassroom->external_code;
}
|
[
"protected",
"function",
"migrateClassroom",
"(",
"$",
"srcClassroom",
")",
"{",
"$",
"classroom",
"=",
"Classroom",
"::",
"firstOrNew",
"(",
"[",
"'name'",
"=>",
"$",
"srcClassroom",
"->",
"name",
",",
"]",
")",
";",
"$",
"classroom",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"addCourseToClassroom",
"(",
"$",
"classroom",
",",
"$",
"srcClassroom",
"->",
"course_id",
")",
";",
"$",
"classroom",
"->",
"shortname",
"=",
"$",
"srcClassroom",
"->",
"shortName",
";",
"$",
"classroom",
"->",
"description",
"=",
"$",
"srcClassroom",
"->",
"description",
";",
"$",
"classroom",
"->",
"code",
"=",
"$",
"srcClassroom",
"->",
"external_code",
";",
"}"
] |
Migrate classroom.
@param $srcClassroom
|
[
"Migrate",
"classroom",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L759-L768
|
239,695
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateCurriculum
|
private function migrateCurriculum()
{
foreach ($this->departments() as $department) {
$this->setDepartment($department);
$this->showMigratingInfo($department,1);
$this->migrateDepartment($department);
foreach ($this->studies($department) as $study) {
$this->setStudy($study);
$this->showMigratingInfo($study,2);
$this->migrateStudy($study);
$this->addStudyToDeparment();
foreach ($this->courses($study) as $course) {
$this->setCourse($course);
$this->showMigratingInfo($course,3);
$this->migrateCourse($course);
$this->addCourseToStudy();
foreach ($this->modules($course) as $module) {
$this->setModule($module);
$this->showMigratingInfo($module, 4);
$this->migrateModule($module);
$this->addModuleToCourse();
foreach ($this->submodules($module) as $submodule) {
$this->setSubmodule($submodule);
$this->showMigratingInfo($submodule, 5);
$this->migrateSubmodule($submodule);
$this->addSubModuleToModule();
}
}
}
}
}
}
|
php
|
private function migrateCurriculum()
{
foreach ($this->departments() as $department) {
$this->setDepartment($department);
$this->showMigratingInfo($department,1);
$this->migrateDepartment($department);
foreach ($this->studies($department) as $study) {
$this->setStudy($study);
$this->showMigratingInfo($study,2);
$this->migrateStudy($study);
$this->addStudyToDeparment();
foreach ($this->courses($study) as $course) {
$this->setCourse($course);
$this->showMigratingInfo($course,3);
$this->migrateCourse($course);
$this->addCourseToStudy();
foreach ($this->modules($course) as $module) {
$this->setModule($module);
$this->showMigratingInfo($module, 4);
$this->migrateModule($module);
$this->addModuleToCourse();
foreach ($this->submodules($module) as $submodule) {
$this->setSubmodule($submodule);
$this->showMigratingInfo($submodule, 5);
$this->migrateSubmodule($submodule);
$this->addSubModuleToModule();
}
}
}
}
}
}
|
[
"private",
"function",
"migrateCurriculum",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"departments",
"(",
")",
"as",
"$",
"department",
")",
"{",
"$",
"this",
"->",
"setDepartment",
"(",
"$",
"department",
")",
";",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"department",
",",
"1",
")",
";",
"$",
"this",
"->",
"migrateDepartment",
"(",
"$",
"department",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"studies",
"(",
"$",
"department",
")",
"as",
"$",
"study",
")",
"{",
"$",
"this",
"->",
"setStudy",
"(",
"$",
"study",
")",
";",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"study",
",",
"2",
")",
";",
"$",
"this",
"->",
"migrateStudy",
"(",
"$",
"study",
")",
";",
"$",
"this",
"->",
"addStudyToDeparment",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"courses",
"(",
"$",
"study",
")",
"as",
"$",
"course",
")",
"{",
"$",
"this",
"->",
"setCourse",
"(",
"$",
"course",
")",
";",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"course",
",",
"3",
")",
";",
"$",
"this",
"->",
"migrateCourse",
"(",
"$",
"course",
")",
";",
"$",
"this",
"->",
"addCourseToStudy",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"(",
"$",
"course",
")",
"as",
"$",
"module",
")",
"{",
"$",
"this",
"->",
"setModule",
"(",
"$",
"module",
")",
";",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"module",
",",
"4",
")",
";",
"$",
"this",
"->",
"migrateModule",
"(",
"$",
"module",
")",
";",
"$",
"this",
"->",
"addModuleToCourse",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"submodules",
"(",
"$",
"module",
")",
"as",
"$",
"submodule",
")",
"{",
"$",
"this",
"->",
"setSubmodule",
"(",
"$",
"submodule",
")",
";",
"$",
"this",
"->",
"showMigratingInfo",
"(",
"$",
"submodule",
",",
"5",
")",
";",
"$",
"this",
"->",
"migrateSubmodule",
"(",
"$",
"submodule",
")",
";",
"$",
"this",
"->",
"addSubModuleToModule",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] |
Migrate curriculum.
|
[
"Migrate",
"curriculum",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L775-L806
|
239,696
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateEnrollments
|
private function migrateEnrollments()
{
$this->output->info('### Migrating enrollments ###');
foreach ($this->enrollments() as $enrollment) {
if ($enrollment->person == null ) {
$this->output->error('Skipping enrolmment because no personal data');
continue;
}
$enrollment->showMigratingInfo($this->output,1);
$newEnrollment = $this->migrateEnrollment($enrollment);
if ($newEnrollment) $this->migrateEnrollmentDetails($enrollment, $newEnrollment);
}
$this->output->info('### END Migrating enrollments ###');
}
|
php
|
private function migrateEnrollments()
{
$this->output->info('### Migrating enrollments ###');
foreach ($this->enrollments() as $enrollment) {
if ($enrollment->person == null ) {
$this->output->error('Skipping enrolmment because no personal data');
continue;
}
$enrollment->showMigratingInfo($this->output,1);
$newEnrollment = $this->migrateEnrollment($enrollment);
if ($newEnrollment) $this->migrateEnrollmentDetails($enrollment, $newEnrollment);
}
$this->output->info('### END Migrating enrollments ###');
}
|
[
"private",
"function",
"migrateEnrollments",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Migrating enrollments ###'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"enrollments",
"(",
")",
"as",
"$",
"enrollment",
")",
"{",
"if",
"(",
"$",
"enrollment",
"->",
"person",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"error",
"(",
"'Skipping enrolmment because no personal data'",
")",
";",
"continue",
";",
"}",
"$",
"enrollment",
"->",
"showMigratingInfo",
"(",
"$",
"this",
"->",
"output",
",",
"1",
")",
";",
"$",
"newEnrollment",
"=",
"$",
"this",
"->",
"migrateEnrollment",
"(",
"$",
"enrollment",
")",
";",
"if",
"(",
"$",
"newEnrollment",
")",
"$",
"this",
"->",
"migrateEnrollmentDetails",
"(",
"$",
"enrollment",
",",
"$",
"newEnrollment",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### END Migrating enrollments ###'",
")",
";",
"}"
] |
Migrate enrollment.
|
[
"Migrate",
"enrollment",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L811-L824
|
239,697
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.seedDays
|
protected function seedDays()
{
$this->output->info('### Seeding days###');
//%u ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
$timestamp = strtotime('next Monday');
$days = array();
for ($i = 1; $i < 8; $i++) {
$days[$i] = strftime('%A', $timestamp);
$timestamp = strtotime('+1 day', $timestamp);
}
foreach ($days as $dayNumber => $day) {
$this->output->info('### Seeding day: ' . $day . ' ###');
$dayModel = Day::firstOrNew([
'code' => $dayNumber,
]
);
$dayModel->name = $day;
$dayModel->code = $dayNumber;
$dayModel->lective = true;
if ($dayNumber == 6 || $dayNumber == 7) {
$dayModel->lective = false;
}
$dayModel->save();
}
$this->output->info('### END Seeding days###');
}
|
php
|
protected function seedDays()
{
$this->output->info('### Seeding days###');
//%u ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
$timestamp = strtotime('next Monday');
$days = array();
for ($i = 1; $i < 8; $i++) {
$days[$i] = strftime('%A', $timestamp);
$timestamp = strtotime('+1 day', $timestamp);
}
foreach ($days as $dayNumber => $day) {
$this->output->info('### Seeding day: ' . $day . ' ###');
$dayModel = Day::firstOrNew([
'code' => $dayNumber,
]
);
$dayModel->name = $day;
$dayModel->code = $dayNumber;
$dayModel->lective = true;
if ($dayNumber == 6 || $dayNumber == 7) {
$dayModel->lective = false;
}
$dayModel->save();
}
$this->output->info('### END Seeding days###');
}
|
[
"protected",
"function",
"seedDays",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Seeding days###'",
")",
";",
"//%u\tISO-8601 numeric representation of the day of the week\t1 (for Monday) through 7 (for Sunday)",
"$",
"timestamp",
"=",
"strtotime",
"(",
"'next Monday'",
")",
";",
"$",
"days",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"8",
";",
"$",
"i",
"++",
")",
"{",
"$",
"days",
"[",
"$",
"i",
"]",
"=",
"strftime",
"(",
"'%A'",
",",
"$",
"timestamp",
")",
";",
"$",
"timestamp",
"=",
"strtotime",
"(",
"'+1 day'",
",",
"$",
"timestamp",
")",
";",
"}",
"foreach",
"(",
"$",
"days",
"as",
"$",
"dayNumber",
"=>",
"$",
"day",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Seeding day: '",
".",
"$",
"day",
".",
"' ###'",
")",
";",
"$",
"dayModel",
"=",
"Day",
"::",
"firstOrNew",
"(",
"[",
"'code'",
"=>",
"$",
"dayNumber",
",",
"]",
")",
";",
"$",
"dayModel",
"->",
"name",
"=",
"$",
"day",
";",
"$",
"dayModel",
"->",
"code",
"=",
"$",
"dayNumber",
";",
"$",
"dayModel",
"->",
"lective",
"=",
"true",
";",
"if",
"(",
"$",
"dayNumber",
"==",
"6",
"||",
"$",
"dayNumber",
"==",
"7",
")",
"{",
"$",
"dayModel",
"->",
"lective",
"=",
"false",
";",
"}",
"$",
"dayModel",
"->",
"save",
"(",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### END Seeding days###'",
")",
";",
"}"
] |
Seed days of the week with ISO-8601 numeric code.
|
[
"Seed",
"days",
"of",
"the",
"week",
"with",
"ISO",
"-",
"8601",
"numeric",
"code",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L829-L855
|
239,698
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateTimeslots
|
protected function migrateTimeslots()
{
$this->output->info('### Migrating timeslots ###');
foreach ($this->timeslots() as $timeslot) {
$timeslot->showMigratingInfo($this->output,1);
$this->migrateTimeslot($timeslot);
}
$this->output->info('### END OF Migrating timeslots ###');
}
|
php
|
protected function migrateTimeslots()
{
$this->output->info('### Migrating timeslots ###');
foreach ($this->timeslots() as $timeslot) {
$timeslot->showMigratingInfo($this->output,1);
$this->migrateTimeslot($timeslot);
}
$this->output->info('### END OF Migrating timeslots ###');
}
|
[
"protected",
"function",
"migrateTimeslots",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Migrating timeslots ###'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"timeslots",
"(",
")",
"as",
"$",
"timeslot",
")",
"{",
"$",
"timeslot",
"->",
"showMigratingInfo",
"(",
"$",
"this",
"->",
"output",
",",
"1",
")",
";",
"$",
"this",
"->",
"migrateTimeslot",
"(",
"$",
"timeslot",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### END OF Migrating timeslots ###'",
")",
";",
"}"
] |
Migrate timeslots.
|
[
"Migrate",
"timeslots",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L881-L889
|
239,699
|
acacha/ebre_escool_model
|
src/Services/EbreEscoolMigrator.php
|
EbreEscoolMigrator.migrateLessons
|
protected function migrateLessons()
{
$this->output->info('### Migrating lessons ###');
if ($this->checkLessonsMigrationState()) {
foreach ($this->lessons() as $lesson) {
$lesson->showMigratingInfo($this->output,1);
$this->migrateLesson($lesson);
}
}
$this->output->info('### END OF Migrating lessons ###');
}
|
php
|
protected function migrateLessons()
{
$this->output->info('### Migrating lessons ###');
if ($this->checkLessonsMigrationState()) {
foreach ($this->lessons() as $lesson) {
$lesson->showMigratingInfo($this->output,1);
$this->migrateLesson($lesson);
}
}
$this->output->info('### END OF Migrating lessons ###');
}
|
[
"protected",
"function",
"migrateLessons",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### Migrating lessons ###'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"checkLessonsMigrationState",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"lessons",
"(",
")",
"as",
"$",
"lesson",
")",
"{",
"$",
"lesson",
"->",
"showMigratingInfo",
"(",
"$",
"this",
"->",
"output",
",",
"1",
")",
";",
"$",
"this",
"->",
"migrateLesson",
"(",
"$",
"lesson",
")",
";",
"}",
"}",
"$",
"this",
"->",
"output",
"->",
"info",
"(",
"'### END OF Migrating lessons ###'",
")",
";",
"}"
] |
Migrate lessons.
|
[
"Migrate",
"lessons",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Services/EbreEscoolMigrator.php#L894-L904
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.