repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
voryx/Thruway | src/Authentication/AuthenticationManager.php | AuthenticationManager.handleAuthenticateMessage | public function handleAuthenticateMessage(Realm $realm, Session $session, AuthenticateMessage $msg)
{
if ($session->getAuthenticationDetails() === null) {
throw new \Exception('Authenticate with no previous auth details');
}
$authMethod = $session->getAuthenticationDetails()->getAuthMethod();
// find the auth method
foreach ($this->authMethods as $am => $authMethodInfo) {
if ($authMethod == $am) {
$this->onAuthenticateHandler($authMethod, $authMethodInfo, $realm, $session, $msg);
}
}
} | php | public function handleAuthenticateMessage(Realm $realm, Session $session, AuthenticateMessage $msg)
{
if ($session->getAuthenticationDetails() === null) {
throw new \Exception('Authenticate with no previous auth details');
}
$authMethod = $session->getAuthenticationDetails()->getAuthMethod();
// find the auth method
foreach ($this->authMethods as $am => $authMethodInfo) {
if ($authMethod == $am) {
$this->onAuthenticateHandler($authMethod, $authMethodInfo, $realm, $session, $msg);
}
}
} | [
"public",
"function",
"handleAuthenticateMessage",
"(",
"Realm",
"$",
"realm",
",",
"Session",
"$",
"session",
",",
"AuthenticateMessage",
"$",
"msg",
")",
"{",
"if",
"(",
"$",
"session",
"->",
"getAuthenticationDetails",
"(",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Authenticate with no previous auth details'",
")",
";",
"}",
"$",
"authMethod",
"=",
"$",
"session",
"->",
"getAuthenticationDetails",
"(",
")",
"->",
"getAuthMethod",
"(",
")",
";",
"// find the auth method",
"foreach",
"(",
"$",
"this",
"->",
"authMethods",
"as",
"$",
"am",
"=>",
"$",
"authMethodInfo",
")",
"{",
"if",
"(",
"$",
"authMethod",
"==",
"$",
"am",
")",
"{",
"$",
"this",
"->",
"onAuthenticateHandler",
"(",
"$",
"authMethod",
",",
"$",
"authMethodInfo",
",",
"$",
"realm",
",",
"$",
"session",
",",
"$",
"msg",
")",
";",
"}",
"}",
"}"
] | Handle Authenticate message
@param \Thruway\Realm $realm
@param \Thruway\Session $session
@param \Thruway\Message\AuthenticateMessage $msg
@throws \Exception | [
"Handle",
"Authenticate",
"message"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/src/Authentication/AuthenticationManager.php#L329-L343 |
voryx/Thruway | src/Authentication/AuthenticationManager.php | AuthenticationManager.onAuthenticateHandler | private function onAuthenticateHandler($authMethod, $authMethodInfo, Realm $realm, Session $session, AuthenticateMessage $msg)
{
$onAuthenticateSuccess = function ($res) use ($realm, $session) {
if (count($res) < 1) {
$session->abort(new \stdClass(), 'thruway.error.authentication_failure');
return;
}
// we should figure out a way to have the router send the welcome
// message so that the roles and extras that go along with it can be
// filled in
if ($res[0] === 'SUCCESS') {
$this->sendWelcomeMessage($session, $res[1]);
} elseif (isset($res[0]) && $res[0] === 'FAILURE') {
$this->abortSessionUsingResponse($session, $res);
} else {
$session->abort(new \stdClass(), 'thruway.error.authentication_failure');
}
};
$onAuthenticateError = function () use ($session) {
Logger::error($this, 'onauthenticate rejected the promise');
$session->abort(new \stdClass(), 'thruway.error.unknown');
};
$extra = new \stdClass();
$extra->challenge_details = $session->getAuthenticationDetails()->getChallengeDetails();
$arguments = new \stdClass();
$arguments->extra = $extra;
$arguments->authid = $session->getAuthenticationDetails()->getAuthId();
$arguments->challenge = $session->getAuthenticationDetails()->getChallenge();
$arguments->signature = $msg->getSignature();
$arguments->authmethod = $authMethod;
$arguments->hello_message = $session->getHelloMessage();
// now we send our authenticate information to the RPC
$onAuthenticateHandler = $authMethodInfo['handlers']->onauthenticate;
$this->session->call($onAuthenticateHandler, [$arguments])
->then($onAuthenticateSuccess, $onAuthenticateError);
} | php | private function onAuthenticateHandler($authMethod, $authMethodInfo, Realm $realm, Session $session, AuthenticateMessage $msg)
{
$onAuthenticateSuccess = function ($res) use ($realm, $session) {
if (count($res) < 1) {
$session->abort(new \stdClass(), 'thruway.error.authentication_failure');
return;
}
// we should figure out a way to have the router send the welcome
// message so that the roles and extras that go along with it can be
// filled in
if ($res[0] === 'SUCCESS') {
$this->sendWelcomeMessage($session, $res[1]);
} elseif (isset($res[0]) && $res[0] === 'FAILURE') {
$this->abortSessionUsingResponse($session, $res);
} else {
$session->abort(new \stdClass(), 'thruway.error.authentication_failure');
}
};
$onAuthenticateError = function () use ($session) {
Logger::error($this, 'onauthenticate rejected the promise');
$session->abort(new \stdClass(), 'thruway.error.unknown');
};
$extra = new \stdClass();
$extra->challenge_details = $session->getAuthenticationDetails()->getChallengeDetails();
$arguments = new \stdClass();
$arguments->extra = $extra;
$arguments->authid = $session->getAuthenticationDetails()->getAuthId();
$arguments->challenge = $session->getAuthenticationDetails()->getChallenge();
$arguments->signature = $msg->getSignature();
$arguments->authmethod = $authMethod;
$arguments->hello_message = $session->getHelloMessage();
// now we send our authenticate information to the RPC
$onAuthenticateHandler = $authMethodInfo['handlers']->onauthenticate;
$this->session->call($onAuthenticateHandler, [$arguments])
->then($onAuthenticateSuccess, $onAuthenticateError);
} | [
"private",
"function",
"onAuthenticateHandler",
"(",
"$",
"authMethod",
",",
"$",
"authMethodInfo",
",",
"Realm",
"$",
"realm",
",",
"Session",
"$",
"session",
",",
"AuthenticateMessage",
"$",
"msg",
")",
"{",
"$",
"onAuthenticateSuccess",
"=",
"function",
"(",
"$",
"res",
")",
"use",
"(",
"$",
"realm",
",",
"$",
"session",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"res",
")",
"<",
"1",
")",
"{",
"$",
"session",
"->",
"abort",
"(",
"new",
"\\",
"stdClass",
"(",
")",
",",
"'thruway.error.authentication_failure'",
")",
";",
"return",
";",
"}",
"// we should figure out a way to have the router send the welcome",
"// message so that the roles and extras that go along with it can be",
"// filled in",
"if",
"(",
"$",
"res",
"[",
"0",
"]",
"===",
"'SUCCESS'",
")",
"{",
"$",
"this",
"->",
"sendWelcomeMessage",
"(",
"$",
"session",
",",
"$",
"res",
"[",
"1",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"res",
"[",
"0",
"]",
")",
"&&",
"$",
"res",
"[",
"0",
"]",
"===",
"'FAILURE'",
")",
"{",
"$",
"this",
"->",
"abortSessionUsingResponse",
"(",
"$",
"session",
",",
"$",
"res",
")",
";",
"}",
"else",
"{",
"$",
"session",
"->",
"abort",
"(",
"new",
"\\",
"stdClass",
"(",
")",
",",
"'thruway.error.authentication_failure'",
")",
";",
"}",
"}",
";",
"$",
"onAuthenticateError",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"session",
")",
"{",
"Logger",
"::",
"error",
"(",
"$",
"this",
",",
"'onauthenticate rejected the promise'",
")",
";",
"$",
"session",
"->",
"abort",
"(",
"new",
"\\",
"stdClass",
"(",
")",
",",
"'thruway.error.unknown'",
")",
";",
"}",
";",
"$",
"extra",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"extra",
"->",
"challenge_details",
"=",
"$",
"session",
"->",
"getAuthenticationDetails",
"(",
")",
"->",
"getChallengeDetails",
"(",
")",
";",
"$",
"arguments",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"arguments",
"->",
"extra",
"=",
"$",
"extra",
";",
"$",
"arguments",
"->",
"authid",
"=",
"$",
"session",
"->",
"getAuthenticationDetails",
"(",
")",
"->",
"getAuthId",
"(",
")",
";",
"$",
"arguments",
"->",
"challenge",
"=",
"$",
"session",
"->",
"getAuthenticationDetails",
"(",
")",
"->",
"getChallenge",
"(",
")",
";",
"$",
"arguments",
"->",
"signature",
"=",
"$",
"msg",
"->",
"getSignature",
"(",
")",
";",
"$",
"arguments",
"->",
"authmethod",
"=",
"$",
"authMethod",
";",
"$",
"arguments",
"->",
"hello_message",
"=",
"$",
"session",
"->",
"getHelloMessage",
"(",
")",
";",
"// now we send our authenticate information to the RPC",
"$",
"onAuthenticateHandler",
"=",
"$",
"authMethodInfo",
"[",
"'handlers'",
"]",
"->",
"onauthenticate",
";",
"$",
"this",
"->",
"session",
"->",
"call",
"(",
"$",
"onAuthenticateHandler",
",",
"[",
"$",
"arguments",
"]",
")",
"->",
"then",
"(",
"$",
"onAuthenticateSuccess",
",",
"$",
"onAuthenticateError",
")",
";",
"}"
] | Call the handler that was registered to handle the Authenticate Message
@param $authMethod
@param $authMethodInfo
@param Realm $realm
@param Session $session
@param AuthenticateMessage $msg | [
"Call",
"the",
"handler",
"that",
"was",
"registered",
"to",
"handle",
"the",
"Authenticate",
"Message"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/src/Authentication/AuthenticationManager.php#L354-L399 |
voryx/Thruway | src/Authentication/AuthenticationManager.php | AuthenticationManager.registerAuthMethod | public function registerAuthMethod(array $args, $kwargs, $details)
{
// TODO: should return different error
if (!is_array($args)) {
return ['Received non-array arguments in registerAuthMethod'];
}
if (count($args) < 2) {
return ['Not enough arguments sent to registerAuthMethod'];
}
list($authMethod, $methodInfo, $authRealms) = $args;
// TODO: validate this stuff
if (isset($this->authMethods[$authMethod])) {
// error - there is alreay a registered authMethod of this name
return ['ERROR', 'Method registration already exists'];
}
if (!isset($methodInfo->onhello)) {
return ['ERROR', 'Authentication provider must provide "onhello" handler'];
}
if (!isset($methodInfo->onauthenticate)) {
return ['ERROR', 'Authentication provider must provide "onauthenticate" handler'];
}
if (!isset($details->caller)) {
return ['ERROR', 'Invocation must provide "caller" detail on registration'];
}
$this->authMethods[$authMethod] = [
'authMethod' => $authMethod,
'handlers' => $methodInfo,
'auth_realms' => $authRealms,
'session_id' => $details->caller
];
return ['SUCCESS'];
} | php | public function registerAuthMethod(array $args, $kwargs, $details)
{
// TODO: should return different error
if (!is_array($args)) {
return ['Received non-array arguments in registerAuthMethod'];
}
if (count($args) < 2) {
return ['Not enough arguments sent to registerAuthMethod'];
}
list($authMethod, $methodInfo, $authRealms) = $args;
// TODO: validate this stuff
if (isset($this->authMethods[$authMethod])) {
// error - there is alreay a registered authMethod of this name
return ['ERROR', 'Method registration already exists'];
}
if (!isset($methodInfo->onhello)) {
return ['ERROR', 'Authentication provider must provide "onhello" handler'];
}
if (!isset($methodInfo->onauthenticate)) {
return ['ERROR', 'Authentication provider must provide "onauthenticate" handler'];
}
if (!isset($details->caller)) {
return ['ERROR', 'Invocation must provide "caller" detail on registration'];
}
$this->authMethods[$authMethod] = [
'authMethod' => $authMethod,
'handlers' => $methodInfo,
'auth_realms' => $authRealms,
'session_id' => $details->caller
];
return ['SUCCESS'];
} | [
"public",
"function",
"registerAuthMethod",
"(",
"array",
"$",
"args",
",",
"$",
"kwargs",
",",
"$",
"details",
")",
"{",
"// TODO: should return different error",
"if",
"(",
"!",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"return",
"[",
"'Received non-array arguments in registerAuthMethod'",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"<",
"2",
")",
"{",
"return",
"[",
"'Not enough arguments sent to registerAuthMethod'",
"]",
";",
"}",
"list",
"(",
"$",
"authMethod",
",",
"$",
"methodInfo",
",",
"$",
"authRealms",
")",
"=",
"$",
"args",
";",
"// TODO: validate this stuff",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"authMethods",
"[",
"$",
"authMethod",
"]",
")",
")",
"{",
"// error - there is alreay a registered authMethod of this name",
"return",
"[",
"'ERROR'",
",",
"'Method registration already exists'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"methodInfo",
"->",
"onhello",
")",
")",
"{",
"return",
"[",
"'ERROR'",
",",
"'Authentication provider must provide \"onhello\" handler'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"methodInfo",
"->",
"onauthenticate",
")",
")",
"{",
"return",
"[",
"'ERROR'",
",",
"'Authentication provider must provide \"onauthenticate\" handler'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"details",
"->",
"caller",
")",
")",
"{",
"return",
"[",
"'ERROR'",
",",
"'Invocation must provide \"caller\" detail on registration'",
"]",
";",
"}",
"$",
"this",
"->",
"authMethods",
"[",
"$",
"authMethod",
"]",
"=",
"[",
"'authMethod'",
"=>",
"$",
"authMethod",
",",
"'handlers'",
"=>",
"$",
"methodInfo",
",",
"'auth_realms'",
"=>",
"$",
"authRealms",
",",
"'session_id'",
"=>",
"$",
"details",
"->",
"caller",
"]",
";",
"return",
"[",
"'SUCCESS'",
"]",
";",
"}"
] | This is called via a WAMP RPC URI. It is registered as thruway.auth.registermethod
it takes arguments in an array - ["methodName", ["realm1", "realm2", "*"],
@param array $args
@param array $kwargs
@param array $details
@return array | [
"This",
"is",
"called",
"via",
"a",
"WAMP",
"RPC",
"URI",
".",
"It",
"is",
"registered",
"as",
"thruway",
".",
"auth",
".",
"registermethod",
"it",
"takes",
"arguments",
"in",
"an",
"array",
"-",
"[",
"methodName",
"[",
"realm1",
"realm2",
"*",
"]"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/src/Authentication/AuthenticationManager.php#L454-L494 |
voryx/Thruway | src/Authentication/AuthenticationManager.php | AuthenticationManager.realmHasAuthProvider | private function realmHasAuthProvider($realmName)
{
foreach ($this->authMethods as $authMethod) {
foreach ($authMethod['auth_realms'] as $authRealm) {
if ($authRealm === "*" || $authRealm === $realmName) {
return true;
}
}
}
return false;
} | php | private function realmHasAuthProvider($realmName)
{
foreach ($this->authMethods as $authMethod) {
foreach ($authMethod['auth_realms'] as $authRealm) {
if ($authRealm === "*" || $authRealm === $realmName) {
return true;
}
}
}
return false;
} | [
"private",
"function",
"realmHasAuthProvider",
"(",
"$",
"realmName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"authMethods",
"as",
"$",
"authMethod",
")",
"{",
"foreach",
"(",
"$",
"authMethod",
"[",
"'auth_realms'",
"]",
"as",
"$",
"authRealm",
")",
"{",
"if",
"(",
"$",
"authRealm",
"===",
"\"*\"",
"||",
"$",
"authRealm",
"===",
"$",
"realmName",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks to see if a realm has a registered auth provider
@param string $realmName
@return boolean | [
"Checks",
"to",
"see",
"if",
"a",
"realm",
"has",
"a",
"registered",
"auth",
"provider"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/src/Authentication/AuthenticationManager.php#L502-L513 |
voryx/Thruway | src/Authentication/AuthenticationManager.php | AuthenticationManager.onSessionClose | public function onSessionClose(Session $session)
{
if ($session->getRealm() && $session->getRealm()->getRealmName() === 'thruway.auth') {
// session is closing in the auth domain
// check and see if there are any registrations that came from this session
$sessionId = $session->getSessionId();
foreach ($this->authMethods as $methodName => $method) {
if (isset($method['session_id']) && $method['session_id'] === $sessionId) {
unset($this->authMethods[$methodName]);
}
}
}
} | php | public function onSessionClose(Session $session)
{
if ($session->getRealm() && $session->getRealm()->getRealmName() === 'thruway.auth') {
// session is closing in the auth domain
// check and see if there are any registrations that came from this session
$sessionId = $session->getSessionId();
foreach ($this->authMethods as $methodName => $method) {
if (isset($method['session_id']) && $method['session_id'] === $sessionId) {
unset($this->authMethods[$methodName]);
}
}
}
} | [
"public",
"function",
"onSessionClose",
"(",
"Session",
"$",
"session",
")",
"{",
"if",
"(",
"$",
"session",
"->",
"getRealm",
"(",
")",
"&&",
"$",
"session",
"->",
"getRealm",
"(",
")",
"->",
"getRealmName",
"(",
")",
"===",
"'thruway.auth'",
")",
"{",
"// session is closing in the auth domain",
"// check and see if there are any registrations that came from this session",
"$",
"sessionId",
"=",
"$",
"session",
"->",
"getSessionId",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"authMethods",
"as",
"$",
"methodName",
"=>",
"$",
"method",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"method",
"[",
"'session_id'",
"]",
")",
"&&",
"$",
"method",
"[",
"'session_id'",
"]",
"===",
"$",
"sessionId",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"authMethods",
"[",
"$",
"methodName",
"]",
")",
";",
"}",
"}",
"}",
"}"
] | This allows the AuthenticationManager to clean out auth methods that were registered by
sessions that are dieing. Otherwise the method could be hijacked by another client in the
thruway.auth realm.
@param \Thruway\Session $session | [
"This",
"allows",
"the",
"AuthenticationManager",
"to",
"clean",
"out",
"auth",
"methods",
"that",
"were",
"registered",
"by",
"sessions",
"that",
"are",
"dieing",
".",
"Otherwise",
"the",
"method",
"could",
"be",
"hijacked",
"by",
"another",
"client",
"in",
"the",
"thruway",
".",
"auth",
"realm",
"."
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/src/Authentication/AuthenticationManager.php#L522-L535 |
voryx/Thruway | src/Authentication/AuthenticationManager.php | AuthenticationManager.abortSessionUsingResponse | private function abortSessionUsingResponse(Session $session, $response)
{
// $response needs to be a failure
if (!isset($response[0]) || $response[0] !== 'FAILURE') {
return false;
}
if (!isset($response[1]) || !is_object($response[1])) {
// there are no other details to send - just fail it
$session->abort(new \stdClass(), 'thruway.error.authentication_failure');
return true;
}
$details = new \stdClass();
if (isset($response[1]->details) && is_object($response[1]->details)) {
$details = $response[1]->details;
}
$abortUri = 'thruway.error.authentication_failure';
if (isset($response[1]->abort_uri) && is_scalar($response[1]->abort_uri)) {
$abortUri = $response[1]->abort_uri;
}
$session->abort($details, $abortUri);
return true;
} | php | private function abortSessionUsingResponse(Session $session, $response)
{
// $response needs to be a failure
if (!isset($response[0]) || $response[0] !== 'FAILURE') {
return false;
}
if (!isset($response[1]) || !is_object($response[1])) {
// there are no other details to send - just fail it
$session->abort(new \stdClass(), 'thruway.error.authentication_failure');
return true;
}
$details = new \stdClass();
if (isset($response[1]->details) && is_object($response[1]->details)) {
$details = $response[1]->details;
}
$abortUri = 'thruway.error.authentication_failure';
if (isset($response[1]->abort_uri) && is_scalar($response[1]->abort_uri)) {
$abortUri = $response[1]->abort_uri;
}
$session->abort($details, $abortUri);
return true;
} | [
"private",
"function",
"abortSessionUsingResponse",
"(",
"Session",
"$",
"session",
",",
"$",
"response",
")",
"{",
"// $response needs to be a failure",
"if",
"(",
"!",
"isset",
"(",
"$",
"response",
"[",
"0",
"]",
")",
"||",
"$",
"response",
"[",
"0",
"]",
"!==",
"'FAILURE'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"response",
"[",
"1",
"]",
")",
"||",
"!",
"is_object",
"(",
"$",
"response",
"[",
"1",
"]",
")",
")",
"{",
"// there are no other details to send - just fail it",
"$",
"session",
"->",
"abort",
"(",
"new",
"\\",
"stdClass",
"(",
")",
",",
"'thruway.error.authentication_failure'",
")",
";",
"return",
"true",
";",
"}",
"$",
"details",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"1",
"]",
"->",
"details",
")",
"&&",
"is_object",
"(",
"$",
"response",
"[",
"1",
"]",
"->",
"details",
")",
")",
"{",
"$",
"details",
"=",
"$",
"response",
"[",
"1",
"]",
"->",
"details",
";",
"}",
"$",
"abortUri",
"=",
"'thruway.error.authentication_failure'",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"1",
"]",
"->",
"abort_uri",
")",
"&&",
"is_scalar",
"(",
"$",
"response",
"[",
"1",
"]",
"->",
"abort_uri",
")",
")",
"{",
"$",
"abortUri",
"=",
"$",
"response",
"[",
"1",
"]",
"->",
"abort_uri",
";",
"}",
"$",
"session",
"->",
"abort",
"(",
"$",
"details",
",",
"$",
"abortUri",
")",
";",
"return",
"true",
";",
"}"
] | Send an abort message to the session if the Authenticator sent a FAILURE response
Returns true if the abort was sent, false otherwise
@param Session $session
@param $response
@return bool
@throws \Exception | [
"Send",
"an",
"abort",
"message",
"to",
"the",
"session",
"if",
"the",
"Authenticator",
"sent",
"a",
"FAILURE",
"response",
"Returns",
"true",
"if",
"the",
"abort",
"was",
"sent",
"false",
"otherwise"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/src/Authentication/AuthenticationManager.php#L586-L611 |
voryx/Thruway | Examples/100Clients/RelayClient.php | RelayClient.theFunction | public function theFunction()
{
$futureResult = new \React\Promise\Deferred();
$this->session->call('com.example.thefunction' . ($this->number + 1), [])
->then(function ($res) use ($futureResult) {
if (is_scalar($res[0])) {
$res[0] = $res[0] . ".";
}
$futureResult->resolve($res[0]);
});
return $futureResult->promise();
} | php | public function theFunction()
{
$futureResult = new \React\Promise\Deferred();
$this->session->call('com.example.thefunction' . ($this->number + 1), [])
->then(function ($res) use ($futureResult) {
if (is_scalar($res[0])) {
$res[0] = $res[0] . ".";
}
$futureResult->resolve($res[0]);
});
return $futureResult->promise();
} | [
"public",
"function",
"theFunction",
"(",
")",
"{",
"$",
"futureResult",
"=",
"new",
"\\",
"React",
"\\",
"Promise",
"\\",
"Deferred",
"(",
")",
";",
"$",
"this",
"->",
"session",
"->",
"call",
"(",
"'com.example.thefunction'",
".",
"(",
"$",
"this",
"->",
"number",
"+",
"1",
")",
",",
"[",
"]",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"res",
")",
"use",
"(",
"$",
"futureResult",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"res",
"[",
"0",
"]",
")",
")",
"{",
"$",
"res",
"[",
"0",
"]",
"=",
"$",
"res",
"[",
"0",
"]",
".",
"\".\"",
";",
"}",
"$",
"futureResult",
"->",
"resolve",
"(",
"$",
"res",
"[",
"0",
"]",
")",
";",
"}",
")",
";",
"return",
"$",
"futureResult",
"->",
"promise",
"(",
")",
";",
"}"
] | Handle for RPC 'com.example.thefunction{$number}'
@return \React\Promise\Promise | [
"Handle",
"for",
"RPC",
"com",
".",
"example",
".",
"thefunction",
"{",
"$number",
"}"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/Examples/100Clients/RelayClient.php#L39-L52 |
voryx/Thruway | Examples/100Clients/RelayClient.php | RelayClient.onSessionStart | public function onSessionStart($session, $transport)
{
$session->register('com.example.thefunction' . $this->number, [$this, 'theFunction'])
->then(function () {
$this->registeredDeferred->resolve();
});
} | php | public function onSessionStart($session, $transport)
{
$session->register('com.example.thefunction' . $this->number, [$this, 'theFunction'])
->then(function () {
$this->registeredDeferred->resolve();
});
} | [
"public",
"function",
"onSessionStart",
"(",
"$",
"session",
",",
"$",
"transport",
")",
"{",
"$",
"session",
"->",
"register",
"(",
"'com.example.thefunction'",
".",
"$",
"this",
"->",
"number",
",",
"[",
"$",
"this",
",",
"'theFunction'",
"]",
")",
"->",
"then",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"registeredDeferred",
"->",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}"
] | Handle on session start
@param \Thruway\ClientSession $session
@param \Thruway\Transport\TransportInterface $transport | [
"Handle",
"on",
"session",
"start"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/Examples/100Clients/RelayClient.php#L60-L66 |
voryx/Thruway | src/Transport/InternalClientTransport.php | InternalClientTransport.sendMessage | public function sendMessage(Message $msg)
{
if (is_callable($this->sendMessageFunction)) {
call_user_func_array($this->sendMessageFunction, [$msg]);
}
} | php | public function sendMessage(Message $msg)
{
if (is_callable($this->sendMessageFunction)) {
call_user_func_array($this->sendMessageFunction, [$msg]);
}
} | [
"public",
"function",
"sendMessage",
"(",
"Message",
"$",
"msg",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"sendMessageFunction",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"sendMessageFunction",
",",
"[",
"$",
"msg",
"]",
")",
";",
"}",
"}"
] | Send message
@param \Thruway\Message\Message $msg
@throws \Exception | [
"Send",
"message"
] | train | https://github.com/voryx/Thruway/blob/b86c0cddbec8fb69ff583e093d4cc169011fcbfb/src/Transport/InternalClientTransport.php#L33-L38 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Utils/CurlBuilder.php | CurlBuilder.execFollow | private function execFollow() {
$mr = 5;
$body = null;
if (ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")) {
$this->setOptions(array(
CURLOPT_FOLLOWLOCATION => $mr > 0,
CURLOPT_MAXREDIRS => $mr
));
} else {
$this->setOption(CURLOPT_FOLLOWLOCATION, false);
if ($mr > 0) {
$original_url = $this->getInfo(CURLINFO_EFFECTIVE_URL);
$newurl = $original_url;
$this->setOptions(array(
CURLOPT_HEADER => true,
CURLOPT_FORBID_REUSE => false
));
do {
$this->setOption(CURLOPT_URL, $newurl);
$response = curl_exec($this->curl);
$header_size = $this->getInfo(CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
if ($this->getErrorNumber()) {
$code = 0;
} else {
$code = $this->getInfo(CURLINFO_HTTP_CODE);
if ($code == 301 || $code == 302) {
preg_match('/Location:(.*?)\n/i', $header, $matches);
$newurl = trim(array_pop($matches));
} else {
$code = 0;
}
}
} while ($code && --$mr);
if (!$mr) {
if ($mr === null) {
trigger_error('Too many redirects.', E_USER_WARNING);
}
return false;
}
$this->headers = $this->parseHeaders($header);
}
}
if (!$body) {
$this->setOption(CURLOPT_HEADER, true);
$response = $this->execute();
$header_size = $this->getInfo(CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$this->headers = $this->parseHeaders($header);
}
return $body;
} | php | private function execFollow() {
$mr = 5;
$body = null;
if (ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")) {
$this->setOptions(array(
CURLOPT_FOLLOWLOCATION => $mr > 0,
CURLOPT_MAXREDIRS => $mr
));
} else {
$this->setOption(CURLOPT_FOLLOWLOCATION, false);
if ($mr > 0) {
$original_url = $this->getInfo(CURLINFO_EFFECTIVE_URL);
$newurl = $original_url;
$this->setOptions(array(
CURLOPT_HEADER => true,
CURLOPT_FORBID_REUSE => false
));
do {
$this->setOption(CURLOPT_URL, $newurl);
$response = curl_exec($this->curl);
$header_size = $this->getInfo(CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
if ($this->getErrorNumber()) {
$code = 0;
} else {
$code = $this->getInfo(CURLINFO_HTTP_CODE);
if ($code == 301 || $code == 302) {
preg_match('/Location:(.*?)\n/i', $header, $matches);
$newurl = trim(array_pop($matches));
} else {
$code = 0;
}
}
} while ($code && --$mr);
if (!$mr) {
if ($mr === null) {
trigger_error('Too many redirects.', E_USER_WARNING);
}
return false;
}
$this->headers = $this->parseHeaders($header);
}
}
if (!$body) {
$this->setOption(CURLOPT_HEADER, true);
$response = $this->execute();
$header_size = $this->getInfo(CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$this->headers = $this->parseHeaders($header);
}
return $body;
} | [
"private",
"function",
"execFollow",
"(",
")",
"{",
"$",
"mr",
"=",
"5",
";",
"$",
"body",
"=",
"null",
";",
"if",
"(",
"ini_get",
"(",
"\"open_basedir\"",
")",
"==",
"\"\"",
"&&",
"ini_get",
"(",
"\"safe_mode\"",
"==",
"\"Off\"",
")",
")",
"{",
"$",
"this",
"->",
"setOptions",
"(",
"array",
"(",
"CURLOPT_FOLLOWLOCATION",
"=>",
"$",
"mr",
">",
"0",
",",
"CURLOPT_MAXREDIRS",
"=>",
"$",
"mr",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setOption",
"(",
"CURLOPT_FOLLOWLOCATION",
",",
"false",
")",
";",
"if",
"(",
"$",
"mr",
">",
"0",
")",
"{",
"$",
"original_url",
"=",
"$",
"this",
"->",
"getInfo",
"(",
"CURLINFO_EFFECTIVE_URL",
")",
";",
"$",
"newurl",
"=",
"$",
"original_url",
";",
"$",
"this",
"->",
"setOptions",
"(",
"array",
"(",
"CURLOPT_HEADER",
"=>",
"true",
",",
"CURLOPT_FORBID_REUSE",
"=>",
"false",
")",
")",
";",
"do",
"{",
"$",
"this",
"->",
"setOption",
"(",
"CURLOPT_URL",
",",
"$",
"newurl",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"curl",
")",
";",
"$",
"header_size",
"=",
"$",
"this",
"->",
"getInfo",
"(",
"CURLINFO_HEADER_SIZE",
")",
";",
"$",
"header",
"=",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"$",
"header_size",
")",
";",
"$",
"body",
"=",
"substr",
"(",
"$",
"response",
",",
"$",
"header_size",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getErrorNumber",
"(",
")",
")",
"{",
"$",
"code",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"getInfo",
"(",
"CURLINFO_HTTP_CODE",
")",
";",
"if",
"(",
"$",
"code",
"==",
"301",
"||",
"$",
"code",
"==",
"302",
")",
"{",
"preg_match",
"(",
"'/Location:(.*?)\\n/i'",
",",
"$",
"header",
",",
"$",
"matches",
")",
";",
"$",
"newurl",
"=",
"trim",
"(",
"array_pop",
"(",
"$",
"matches",
")",
")",
";",
"}",
"else",
"{",
"$",
"code",
"=",
"0",
";",
"}",
"}",
"}",
"while",
"(",
"$",
"code",
"&&",
"--",
"$",
"mr",
")",
";",
"if",
"(",
"!",
"$",
"mr",
")",
"{",
"if",
"(",
"$",
"mr",
"===",
"null",
")",
"{",
"trigger_error",
"(",
"'Too many redirects.'",
",",
"E_USER_WARNING",
")",
";",
"}",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"headers",
"=",
"$",
"this",
"->",
"parseHeaders",
"(",
"$",
"header",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"body",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"CURLOPT_HEADER",
",",
"true",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"execute",
"(",
")",
";",
"$",
"header_size",
"=",
"$",
"this",
"->",
"getInfo",
"(",
"CURLINFO_HEADER_SIZE",
")",
";",
"$",
"header",
"=",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"$",
"header_size",
")",
";",
"$",
"body",
"=",
"substr",
"(",
"$",
"response",
",",
"$",
"header_size",
")",
";",
"$",
"this",
"->",
"headers",
"=",
"$",
"this",
"->",
"parseHeaders",
"(",
"$",
"header",
")",
";",
"}",
"return",
"$",
"body",
";",
"}"
] | Function which acts as a replacement for curl's default
FOLLOW_LOCATION option, since that gives errors when
combining it with open basedir.
@see http://slopjong.de/2012/03/31/curl-follow-locations-with-safe_mode-enabled-or-open_basedir-set/
@access private
@return false|string | [
"Function",
"which",
"acts",
"as",
"a",
"replacement",
"for",
"curl",
"s",
"default",
"FOLLOW_LOCATION",
"option",
"since",
"that",
"gives",
"errors",
"when",
"combining",
"it",
"with",
"open",
"basedir",
"."
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Utils/CurlBuilder.php#L184-L252 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Following.php | Following.users | public function users(array $data = [])
{
$response = $this->request->get("me/following/users", $data);
return new Collection($this->master, $response, "User");
} | php | public function users(array $data = [])
{
$response = $this->request->get("me/following/users", $data);
return new Collection($this->master, $response, "User");
} | [
"public",
"function",
"users",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/following/users\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"User\"",
")",
";",
"}"
] | Get the authenticated user's following users
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return Collection | [
"Get",
"the",
"authenticated",
"user",
"s",
"following",
"users"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Following.php#L27-L31 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Following.php | Following.boards | public function boards(array $data = [])
{
$response = $this->request->get("me/following/boards", $data);
return new Collection($this->master, $response, "Board");
} | php | public function boards(array $data = [])
{
$response = $this->request->get("me/following/boards", $data);
return new Collection($this->master, $response, "Board");
} | [
"public",
"function",
"boards",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/following/boards\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"Board\"",
")",
";",
"}"
] | Get the authenticated user's following boards
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return Collection | [
"Get",
"the",
"authenticated",
"user",
"s",
"following",
"boards"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Following.php#L41-L45 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Following.php | Following.interests | public function interests(array $data = [])
{
$response = $this->request->get("me/following/interests", $data);
return new Collection($this->master, $response, "Interest");
} | php | public function interests(array $data = [])
{
$response = $this->request->get("me/following/interests", $data);
return new Collection($this->master, $response, "Interest");
} | [
"public",
"function",
"interests",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/following/interests\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"Interest\"",
")",
";",
"}"
] | Get the authenticated user's following interest
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return Collection | [
"Get",
"the",
"authenticated",
"user",
"s",
"following",
"interest"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Following.php#L55-L59 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Auth/PinterestOAuth.php | PinterestOAuth.getLoginUrl | public function getLoginUrl($redirect_uri, $scopes = array("read_public"), $response_type = "code")
{
$queryparams = array(
"response_type" => $response_type,
"redirect_uri" => $redirect_uri,
"client_id" => $this->client_id,
"client_secret" => $this->client_secret,
"scope" => implode(",", $scopes),
"state" => $this->state
);
// Build url and return it
return sprintf("%s?%s", self::AUTH_HOST, http_build_query($queryparams));
} | php | public function getLoginUrl($redirect_uri, $scopes = array("read_public"), $response_type = "code")
{
$queryparams = array(
"response_type" => $response_type,
"redirect_uri" => $redirect_uri,
"client_id" => $this->client_id,
"client_secret" => $this->client_secret,
"scope" => implode(",", $scopes),
"state" => $this->state
);
// Build url and return it
return sprintf("%s?%s", self::AUTH_HOST, http_build_query($queryparams));
} | [
"public",
"function",
"getLoginUrl",
"(",
"$",
"redirect_uri",
",",
"$",
"scopes",
"=",
"array",
"(",
"\"read_public\"",
")",
",",
"$",
"response_type",
"=",
"\"code\"",
")",
"{",
"$",
"queryparams",
"=",
"array",
"(",
"\"response_type\"",
"=>",
"$",
"response_type",
",",
"\"redirect_uri\"",
"=>",
"$",
"redirect_uri",
",",
"\"client_id\"",
"=>",
"$",
"this",
"->",
"client_id",
",",
"\"client_secret\"",
"=>",
"$",
"this",
"->",
"client_secret",
",",
"\"scope\"",
"=>",
"implode",
"(",
"\",\"",
",",
"$",
"scopes",
")",
",",
"\"state\"",
"=>",
"$",
"this",
"->",
"state",
")",
";",
"// Build url and return it",
"return",
"sprintf",
"(",
"\"%s?%s\"",
",",
"self",
"::",
"AUTH_HOST",
",",
"http_build_query",
"(",
"$",
"queryparams",
")",
")",
";",
"}"
] | Returns the login url
@access public
@param array $scopes
@param string $redirect_uri
@return string | [
"Returns",
"the",
"login",
"url"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Auth/PinterestOAuth.php#L79-L92 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Auth/PinterestOAuth.php | PinterestOAuth.getOAuthToken | public function getOAuthToken($code)
{
// Build data array
$data = array(
"grant_type" => "authorization_code",
"client_id" => $this->client_id,
"client_secret" => $this->client_secret,
"code" => $code
);
// Perform post request
$response = $this->request->post("oauth/token", $data);
return $response;
} | php | public function getOAuthToken($code)
{
// Build data array
$data = array(
"grant_type" => "authorization_code",
"client_id" => $this->client_id,
"client_secret" => $this->client_secret,
"code" => $code
);
// Perform post request
$response = $this->request->post("oauth/token", $data);
return $response;
} | [
"public",
"function",
"getOAuthToken",
"(",
"$",
"code",
")",
"{",
"// Build data array",
"$",
"data",
"=",
"array",
"(",
"\"grant_type\"",
"=>",
"\"authorization_code\"",
",",
"\"client_id\"",
"=>",
"$",
"this",
"->",
"client_id",
",",
"\"client_secret\"",
"=>",
"$",
"this",
"->",
"client_secret",
",",
"\"code\"",
"=>",
"$",
"code",
")",
";",
"// Perform post request",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"post",
"(",
"\"oauth/token\"",
",",
"$",
"data",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Change the code for an access_token
@param string $code
@return \DirkGroenen\Pinterest\Transport\Response | [
"Change",
"the",
"code",
"for",
"an",
"access_token"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Auth/PinterestOAuth.php#L132-L146 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Boards.php | Boards.get | public function get($board_id, array $data = [])
{
$response = $this->request->get(sprintf("boards/%s", $board_id), $data);
return new Board($this->master, $response);
} | php | public function get($board_id, array $data = [])
{
$response = $this->request->get(sprintf("boards/%s", $board_id), $data);
return new Board($this->master, $response);
} | [
"public",
"function",
"get",
"(",
"$",
"board_id",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"sprintf",
"(",
"\"boards/%s\"",
",",
"$",
"board_id",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"Board",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Find the provided board
@access public
@param string $board_id
@param array $data
@throws Exceptions/PinterestExceptions
@return Board | [
"Find",
"the",
"provided",
"board"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Boards.php#L26-L30 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Boards.php | Boards.create | public function create(array $data)
{
$response = $this->request->post("boards", $data);
return new Board($this->master, $response);
} | php | public function create(array $data)
{
$response = $this->request->post("boards", $data);
return new Board($this->master, $response);
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"post",
"(",
"\"boards\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Board",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Create a new board
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return Board | [
"Create",
"a",
"new",
"board"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Boards.php#L40-L44 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Boards.php | Boards.edit | public function edit($board_id, array $data, $fields = null)
{
$query = (!$fields) ? array() : array("fields" => $fields);
$response = $this->request->update(sprintf("boards/%s", $board_id), $data, $query);
return new Board($this->master, $response);
} | php | public function edit($board_id, array $data, $fields = null)
{
$query = (!$fields) ? array() : array("fields" => $fields);
$response = $this->request->update(sprintf("boards/%s", $board_id), $data, $query);
return new Board($this->master, $response);
} | [
"public",
"function",
"edit",
"(",
"$",
"board_id",
",",
"array",
"$",
"data",
",",
"$",
"fields",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"(",
"!",
"$",
"fields",
")",
"?",
"array",
"(",
")",
":",
"array",
"(",
"\"fields\"",
"=>",
"$",
"fields",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"update",
"(",
"sprintf",
"(",
"\"boards/%s\"",
",",
"$",
"board_id",
")",
",",
"$",
"data",
",",
"$",
"query",
")",
";",
"return",
"new",
"Board",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Edit a board
@access public
@param string $board_id
@param array $data
@param string $fields
@throws Exceptions/PinterestExceptions
@return Board | [
"Edit",
"a",
"board"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Boards.php#L56-L62 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Transport/Request.php | Request.get | public function get($endpoint, array $parameters = array())
{
if (!empty($parameters)) {
$path = sprintf("%s/?%s", $endpoint, http_build_query($parameters));
} else {
$path = $endpoint;
}
return $this->execute("GET", sprintf("%s%s", $this->host, $path));
} | php | public function get($endpoint, array $parameters = array())
{
if (!empty($parameters)) {
$path = sprintf("%s/?%s", $endpoint, http_build_query($parameters));
} else {
$path = $endpoint;
}
return $this->execute("GET", sprintf("%s%s", $this->host, $path));
} | [
"public",
"function",
"get",
"(",
"$",
"endpoint",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"path",
"=",
"sprintf",
"(",
"\"%s/?%s\"",
",",
"$",
"endpoint",
",",
"http_build_query",
"(",
"$",
"parameters",
")",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"endpoint",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"\"GET\"",
",",
"sprintf",
"(",
"\"%s%s\"",
",",
"$",
"this",
"->",
"host",
",",
"$",
"path",
")",
")",
";",
"}"
] | Make a get request to the given endpoint
@access public
@param string $endpoint
@param array $parameters
@return Response | [
"Make",
"a",
"get",
"request",
"to",
"the",
"given",
"endpoint"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Transport/Request.php#L77-L86 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Transport/Request.php | Request.post | public function post($endpoint, array $parameters = array())
{
return $this->execute("POST", sprintf("%s%s", $this->host, $endpoint), $parameters);
} | php | public function post($endpoint, array $parameters = array())
{
return $this->execute("POST", sprintf("%s%s", $this->host, $endpoint), $parameters);
} | [
"public",
"function",
"post",
"(",
"$",
"endpoint",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"execute",
"(",
"\"POST\"",
",",
"sprintf",
"(",
"\"%s%s\"",
",",
"$",
"this",
"->",
"host",
",",
"$",
"endpoint",
")",
",",
"$",
"parameters",
")",
";",
"}"
] | Make a post request to the given endpoint
@access public
@param string $endpoint
@param array $parameters
@return Response | [
"Make",
"a",
"post",
"request",
"to",
"the",
"given",
"endpoint"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Transport/Request.php#L96-L99 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Transport/Request.php | Request.delete | public function delete($endpoint, array $parameters = array())
{
return $this->execute("DELETE", sprintf("%s%s", $this->host, $endpoint) . "/", $parameters);
} | php | public function delete($endpoint, array $parameters = array())
{
return $this->execute("DELETE", sprintf("%s%s", $this->host, $endpoint) . "/", $parameters);
} | [
"public",
"function",
"delete",
"(",
"$",
"endpoint",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"execute",
"(",
"\"DELETE\"",
",",
"sprintf",
"(",
"\"%s%s\"",
",",
"$",
"this",
"->",
"host",
",",
"$",
"endpoint",
")",
".",
"\"/\"",
",",
"$",
"parameters",
")",
";",
"}"
] | Make a delete request to the given endpoint
@access public
@param string $endpoint
@param array $parameters
@return Response | [
"Make",
"a",
"delete",
"request",
"to",
"the",
"given",
"endpoint"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Transport/Request.php#L109-L112 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Transport/Request.php | Request.update | public function update($endpoint, array $parameters = array(), array $queryparameters = array())
{
if (!empty($queryparameters)) {
$path = sprintf("%s/?%s", $endpoint, http_build_query($queryparameters));
} else {
$path = $endpoint;
}
return $this->execute("PATCH", sprintf("%s%s", $this->host, $path), $parameters);
} | php | public function update($endpoint, array $parameters = array(), array $queryparameters = array())
{
if (!empty($queryparameters)) {
$path = sprintf("%s/?%s", $endpoint, http_build_query($queryparameters));
} else {
$path = $endpoint;
}
return $this->execute("PATCH", sprintf("%s%s", $this->host, $path), $parameters);
} | [
"public",
"function",
"update",
"(",
"$",
"endpoint",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"array",
"$",
"queryparameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryparameters",
")",
")",
"{",
"$",
"path",
"=",
"sprintf",
"(",
"\"%s/?%s\"",
",",
"$",
"endpoint",
",",
"http_build_query",
"(",
"$",
"queryparameters",
")",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"endpoint",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"\"PATCH\"",
",",
"sprintf",
"(",
"\"%s%s\"",
",",
"$",
"this",
"->",
"host",
",",
"$",
"path",
")",
",",
"$",
"parameters",
")",
";",
"}"
] | Make an update request to the given endpoint
@access public
@param string $endpoint
@param array $parameters
@param array $queryparameters
@return Response | [
"Make",
"an",
"update",
"request",
"to",
"the",
"given",
"endpoint"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Transport/Request.php#L123-L132 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Transport/Request.php | Request.execute | public function execute($method, $apiCall, array $parameters = array(), $headers = array())
{
// Check if the access token needs to be added
if ($this->access_token != null) {
$headers = array_merge($headers, array(
"Authorization: Bearer " . $this->access_token,
));
}
// Force cURL to not send Expect header to workaround bug with Akamai CDN not handling
// this type of requests correctly
$headers = array_merge($headers, array(
"Expect:",
));
// Setup CURL
$ch = $this->curlbuilder->create();
// Set default options
$ch->setOptions(array(
CURLOPT_URL => $apiCall,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_CONNECTTIMEOUT => 20,
CURLOPT_TIMEOUT => 90,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HEADER => false,
CURLINFO_HEADER_OUT => true
));
switch ($method) {
case 'POST':
$ch->setOptions(array(
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POST => count($parameters),
CURLOPT_POSTFIELDS => $parameters
));
if (!class_exists('\CURLFile') && defined('CURLOPT_SAFE_UPLOAD')) {
$ch->setOption(CURLOPT_SAFE_UPLOAD, false);
}
elseif (class_exists('\CURLFile') && defined('CURLOPT_SAFE_UPLOAD')) {
$ch->setOption(CURLOPT_SAFE_UPLOAD, true);
}
break;
case 'DELETE':
$ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE");
break;
case 'PATCH':
$ch->setOptions(array(
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POST => count($parameters),
CURLOPT_POSTFIELDS => $parameters
));
break;
default:
$ch->setOption(CURLOPT_CUSTOMREQUEST, "GET");
break;
}
// Execute request and catch response
$response_data = $ch->execute();
if ($response_data === false && !$ch->hasErrors()) {
throw new CurlException("Error: Curl request failed");
}
else if($ch->hasErrors()) {
throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber());
}
// Initiate the response
$response = new Response($response_data, $ch);
// Check the response code
if ($response->getResponseCode() >= 400) {
throw new PinterestException('Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->getMessage(), $response->getResponseCode());
}
// Get headers from last request
$this->headers = $ch->getHeaders();
// Close curl resource
$ch->close();
// Return the response
return $response;
} | php | public function execute($method, $apiCall, array $parameters = array(), $headers = array())
{
// Check if the access token needs to be added
if ($this->access_token != null) {
$headers = array_merge($headers, array(
"Authorization: Bearer " . $this->access_token,
));
}
// Force cURL to not send Expect header to workaround bug with Akamai CDN not handling
// this type of requests correctly
$headers = array_merge($headers, array(
"Expect:",
));
// Setup CURL
$ch = $this->curlbuilder->create();
// Set default options
$ch->setOptions(array(
CURLOPT_URL => $apiCall,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_CONNECTTIMEOUT => 20,
CURLOPT_TIMEOUT => 90,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HEADER => false,
CURLINFO_HEADER_OUT => true
));
switch ($method) {
case 'POST':
$ch->setOptions(array(
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POST => count($parameters),
CURLOPT_POSTFIELDS => $parameters
));
if (!class_exists('\CURLFile') && defined('CURLOPT_SAFE_UPLOAD')) {
$ch->setOption(CURLOPT_SAFE_UPLOAD, false);
}
elseif (class_exists('\CURLFile') && defined('CURLOPT_SAFE_UPLOAD')) {
$ch->setOption(CURLOPT_SAFE_UPLOAD, true);
}
break;
case 'DELETE':
$ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE");
break;
case 'PATCH':
$ch->setOptions(array(
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POST => count($parameters),
CURLOPT_POSTFIELDS => $parameters
));
break;
default:
$ch->setOption(CURLOPT_CUSTOMREQUEST, "GET");
break;
}
// Execute request and catch response
$response_data = $ch->execute();
if ($response_data === false && !$ch->hasErrors()) {
throw new CurlException("Error: Curl request failed");
}
else if($ch->hasErrors()) {
throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber());
}
// Initiate the response
$response = new Response($response_data, $ch);
// Check the response code
if ($response->getResponseCode() >= 400) {
throw new PinterestException('Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->getMessage(), $response->getResponseCode());
}
// Get headers from last request
$this->headers = $ch->getHeaders();
// Close curl resource
$ch->close();
// Return the response
return $response;
} | [
"public",
"function",
"execute",
"(",
"$",
"method",
",",
"$",
"apiCall",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"// Check if the access token needs to be added",
"if",
"(",
"$",
"this",
"->",
"access_token",
"!=",
"null",
")",
"{",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"headers",
",",
"array",
"(",
"\"Authorization: Bearer \"",
".",
"$",
"this",
"->",
"access_token",
",",
")",
")",
";",
"}",
"// Force cURL to not send Expect header to workaround bug with Akamai CDN not handling",
"// this type of requests correctly",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"headers",
",",
"array",
"(",
"\"Expect:\"",
",",
")",
")",
";",
"// Setup CURL",
"$",
"ch",
"=",
"$",
"this",
"->",
"curlbuilder",
"->",
"create",
"(",
")",
";",
"// Set default options",
"$",
"ch",
"->",
"setOptions",
"(",
"array",
"(",
"CURLOPT_URL",
"=>",
"$",
"apiCall",
",",
"CURLOPT_HTTPHEADER",
"=>",
"$",
"headers",
",",
"CURLOPT_CONNECTTIMEOUT",
"=>",
"20",
",",
"CURLOPT_TIMEOUT",
"=>",
"90",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"CURLOPT_SSL_VERIFYPEER",
"=>",
"false",
",",
"CURLOPT_SSL_VERIFYHOST",
"=>",
"false",
",",
"CURLOPT_HEADER",
"=>",
"false",
",",
"CURLINFO_HEADER_OUT",
"=>",
"true",
")",
")",
";",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"'POST'",
":",
"$",
"ch",
"->",
"setOptions",
"(",
"array",
"(",
"CURLOPT_CUSTOMREQUEST",
"=>",
"\"POST\"",
",",
"CURLOPT_POST",
"=>",
"count",
"(",
"$",
"parameters",
")",
",",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"parameters",
")",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"'\\CURLFile'",
")",
"&&",
"defined",
"(",
"'CURLOPT_SAFE_UPLOAD'",
")",
")",
"{",
"$",
"ch",
"->",
"setOption",
"(",
"CURLOPT_SAFE_UPLOAD",
",",
"false",
")",
";",
"}",
"elseif",
"(",
"class_exists",
"(",
"'\\CURLFile'",
")",
"&&",
"defined",
"(",
"'CURLOPT_SAFE_UPLOAD'",
")",
")",
"{",
"$",
"ch",
"->",
"setOption",
"(",
"CURLOPT_SAFE_UPLOAD",
",",
"true",
")",
";",
"}",
"break",
";",
"case",
"'DELETE'",
":",
"$",
"ch",
"->",
"setOption",
"(",
"CURLOPT_CUSTOMREQUEST",
",",
"\"DELETE\"",
")",
";",
"break",
";",
"case",
"'PATCH'",
":",
"$",
"ch",
"->",
"setOptions",
"(",
"array",
"(",
"CURLOPT_CUSTOMREQUEST",
"=>",
"\"PATCH\"",
",",
"CURLOPT_POST",
"=>",
"count",
"(",
"$",
"parameters",
")",
",",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"parameters",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"ch",
"->",
"setOption",
"(",
"CURLOPT_CUSTOMREQUEST",
",",
"\"GET\"",
")",
";",
"break",
";",
"}",
"// Execute request and catch response",
"$",
"response_data",
"=",
"$",
"ch",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"$",
"response_data",
"===",
"false",
"&&",
"!",
"$",
"ch",
"->",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"CurlException",
"(",
"\"Error: Curl request failed\"",
")",
";",
"}",
"else",
"if",
"(",
"$",
"ch",
"->",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"PinterestException",
"(",
"'Error: execute() - cURL error: '",
".",
"$",
"ch",
"->",
"getErrors",
"(",
")",
",",
"$",
"ch",
"->",
"getErrorNumber",
"(",
")",
")",
";",
"}",
"// Initiate the response",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"response_data",
",",
"$",
"ch",
")",
";",
"// Check the response code",
"if",
"(",
"$",
"response",
"->",
"getResponseCode",
"(",
")",
">=",
"400",
")",
"{",
"throw",
"new",
"PinterestException",
"(",
"'Pinterest error (code: '",
".",
"$",
"response",
"->",
"getResponseCode",
"(",
")",
".",
"') with message: '",
".",
"$",
"response",
"->",
"getMessage",
"(",
")",
",",
"$",
"response",
"->",
"getResponseCode",
"(",
")",
")",
";",
"}",
"// Get headers from last request",
"$",
"this",
"->",
"headers",
"=",
"$",
"ch",
"->",
"getHeaders",
"(",
")",
";",
"// Close curl resource",
"$",
"ch",
"->",
"close",
"(",
")",
";",
"// Return the response",
"return",
"$",
"response",
";",
"}"
] | Execute the http request
@access public
@param string $method
@param string $apiCall
@param array $parameters
@param array $headers
@return Response
@throws CurlException
@throws PinterestException | [
"Execute",
"the",
"http",
"request"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Transport/Request.php#L156-L244 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Users.php | Users.me | public function me(array $data = [])
{
$response = $this->request->get("me", $data);
return new User($this->master, $response);
} | php | public function me(array $data = [])
{
$response = $this->request->get("me", $data);
return new User($this->master, $response);
} | [
"public",
"function",
"me",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"User",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Get the current user
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return User | [
"Get",
"the",
"current",
"user"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Users.php#L26-L30 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Users.php | Users.find | public function find($username, array $data = [])
{
$response = $this->request->get(sprintf("users/%s", $username), $data);
return new User($this->master, $response);
} | php | public function find($username, array $data = [])
{
$response = $this->request->get(sprintf("users/%s", $username), $data);
return new User($this->master, $response);
} | [
"public",
"function",
"find",
"(",
"$",
"username",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"sprintf",
"(",
"\"users/%s\"",
",",
"$",
"username",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"User",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Get the provided user
@access public
@param string $username
@param array $data
@throws Exceptions/PinterestExceptions
@return User | [
"Get",
"the",
"provided",
"user"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Users.php#L41-L45 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Users.php | Users.getMePins | public function getMePins(array $data = [])
{
$response = $this->request->get("me/pins", $data);
return new Collection($this->master, $response, "Pin");
} | php | public function getMePins(array $data = [])
{
$response = $this->request->get("me/pins", $data);
return new Collection($this->master, $response, "Pin");
} | [
"public",
"function",
"getMePins",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/pins\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"Pin\"",
")",
";",
"}"
] | Get the authenticated user's pins
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return Collection | [
"Get",
"the",
"authenticated",
"user",
"s",
"pins"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Users.php#L55-L59 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Users.php | Users.searchMePins | public function searchMePins($query, array $data = [])
{
$data["query"] = $query;
$response = $this->request->get("me/search/pins", $data);
return new Collection($this->master, $response, "Pin");
} | php | public function searchMePins($query, array $data = [])
{
$data["query"] = $query;
$response = $this->request->get("me/search/pins", $data);
return new Collection($this->master, $response, "Pin");
} | [
"public",
"function",
"searchMePins",
"(",
"$",
"query",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"[",
"\"query\"",
"]",
"=",
"$",
"query",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/search/pins\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"Pin\"",
")",
";",
"}"
] | Search in the user's pins
@param string $query
@param array $data
@throws Exceptions/PinterestExceptions
@return Collection | [
"Search",
"in",
"the",
"user",
"s",
"pins"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Users.php#L69-L74 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Users.php | Users.getMeBoards | public function getMeBoards(array $data = [])
{
$response = $this->request->get("me/boards", $data);
return new Collection($this->master, $response, "Board");
} | php | public function getMeBoards(array $data = [])
{
$response = $this->request->get("me/boards", $data);
return new Collection($this->master, $response, "Board");
} | [
"public",
"function",
"getMeBoards",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/boards\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"Board\"",
")",
";",
"}"
] | Get the authenticated user's boards
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return Collection | [
"Get",
"the",
"authenticated",
"user",
"s",
"boards"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Users.php#L100-L104 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Users.php | Users.getMeLikes | public function getMeLikes(array $data = [])
{
$response = $this->request->get("me/likes", $data);
return new Collection($this->master, $response, "Pin");
} | php | public function getMeLikes(array $data = [])
{
$response = $this->request->get("me/likes", $data);
return new Collection($this->master, $response, "Pin");
} | [
"public",
"function",
"getMeLikes",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/likes\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"Pin\"",
")",
";",
"}"
] | Get the authenticated user's likes
@access public
@param array $data
@throws Exceptions/PinterestExceptions
@return Collection | [
"Get",
"the",
"authenticated",
"user",
"s",
"likes"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Users.php#L114-L118 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Users.php | Users.getMeFollowers | public function getMeFollowers(array $data = [])
{
$response = $this->request->get("me/followers", $data);
return new Collection($this->master, $response, "User");
} | php | public function getMeFollowers(array $data = [])
{
$response = $this->request->get("me/followers", $data);
return new Collection($this->master, $response, "User");
} | [
"public",
"function",
"getMeFollowers",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"\"me/followers\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"User\"",
")",
";",
"}"
] | Get the authenticated user's followers
@access public
@param array $data
@throws Exceptions\PinterestException
@return Collection | [
"Get",
"the",
"authenticated",
"user",
"s",
"followers"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Users.php#L128-L132 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Pins.php | Pins.get | public function get($pin_id, array $data = [])
{
$response = $this->request->get(sprintf("pins/%s", $pin_id), $data);
return new Pin($this->master, $response);
} | php | public function get($pin_id, array $data = [])
{
$response = $this->request->get(sprintf("pins/%s", $pin_id), $data);
return new Pin($this->master, $response);
} | [
"public",
"function",
"get",
"(",
"$",
"pin_id",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"sprintf",
"(",
"\"pins/%s\"",
",",
"$",
"pin_id",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"Pin",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Get a pin object
@access public
@param string $pin_id
@param array $data
@throws \DirkGroenen\Pinterest\Exceptions\PinterestException
@return Pin | [
"Get",
"a",
"pin",
"object"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Pins.php#L27-L31 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Pins.php | Pins.fromBoard | public function fromBoard($board_id, array $data = [])
{
$response = $this->request->get(sprintf("boards/%s/pins", $board_id), $data);
return new Collection($this->master, $response, "Pin");
} | php | public function fromBoard($board_id, array $data = [])
{
$response = $this->request->get(sprintf("boards/%s/pins", $board_id), $data);
return new Collection($this->master, $response, "Pin");
} | [
"public",
"function",
"fromBoard",
"(",
"$",
"board_id",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"sprintf",
"(",
"\"boards/%s/pins\"",
",",
"$",
"board_id",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
",",
"\"Pin\"",
")",
";",
"}"
] | Get all pins from the given board
@access public
@param string $board_id
@param array $data
@throws \DirkGroenen\Pinterest\Exceptions\PinterestException
@return Collection | [
"Get",
"all",
"pins",
"from",
"the",
"given",
"board"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Pins.php#L42-L46 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Pins.php | Pins.create | public function create(array $data)
{
if (array_key_exists("image", $data)) {
if (class_exists('\CURLFile')) {
$data["image"] = new \CURLFile($data['image']);
} else {
$data["image"] = '@' . $data['image'];
}
}
$response = $this->request->post("pins", $data);
return new Pin($this->master, $response);
} | php | public function create(array $data)
{
if (array_key_exists("image", $data)) {
if (class_exists('\CURLFile')) {
$data["image"] = new \CURLFile($data['image']);
} else {
$data["image"] = '@' . $data['image'];
}
}
$response = $this->request->post("pins", $data);
return new Pin($this->master, $response);
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"\"image\"",
",",
"$",
"data",
")",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'\\CURLFile'",
")",
")",
"{",
"$",
"data",
"[",
"\"image\"",
"]",
"=",
"new",
"\\",
"CURLFile",
"(",
"$",
"data",
"[",
"'image'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"\"image\"",
"]",
"=",
"'@'",
".",
"$",
"data",
"[",
"'image'",
"]",
";",
"}",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"post",
"(",
"\"pins\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"Pin",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Create a pin
@access public
@param array $data
@throws \DirkGroenen\Pinterest\Exceptions\PinterestException
@return Pin | [
"Create",
"a",
"pin"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Pins.php#L56-L68 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Endpoints/Pins.php | Pins.edit | public function edit($pin_id, array $data, $fields = null)
{
$query = (!$fields) ? array() : array("fields" => $fields);
$response = $this->request->update(sprintf("pins/%s/", $pin_id), $data, $query);
return new Pin($this->master, $response);
} | php | public function edit($pin_id, array $data, $fields = null)
{
$query = (!$fields) ? array() : array("fields" => $fields);
$response = $this->request->update(sprintf("pins/%s/", $pin_id), $data, $query);
return new Pin($this->master, $response);
} | [
"public",
"function",
"edit",
"(",
"$",
"pin_id",
",",
"array",
"$",
"data",
",",
"$",
"fields",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"(",
"!",
"$",
"fields",
")",
"?",
"array",
"(",
")",
":",
"array",
"(",
"\"fields\"",
"=>",
"$",
"fields",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"->",
"update",
"(",
"sprintf",
"(",
"\"pins/%s/\"",
",",
"$",
"pin_id",
")",
",",
"$",
"data",
",",
"$",
"query",
")",
";",
"return",
"new",
"Pin",
"(",
"$",
"this",
"->",
"master",
",",
"$",
"response",
")",
";",
"}"
] | Edit a pin
@access public
@param string $pin_id
@param array $data
@param string $fields
@throws \DirkGroenen\Pinterest\Exceptions\PinterestException
@return Pin | [
"Edit",
"a",
"pin"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Endpoints/Pins.php#L80-L86 |
dirkgroenen/Pinterest-API-PHP | src/Pinterest/Models/Collection.php | Collection.buildCollectionModels | private function buildCollectionModels(array $items)
{
$modelcollection = [];
foreach ($items as $item) {
$class = new \ReflectionClass("\\DirkGroenen\\Pinterest\\Models\\" . $this->model);
$modelcollection[] = $class->newInstanceArgs([$this->master, $item]);
}
return $modelcollection;
} | php | private function buildCollectionModels(array $items)
{
$modelcollection = [];
foreach ($items as $item) {
$class = new \ReflectionClass("\\DirkGroenen\\Pinterest\\Models\\" . $this->model);
$modelcollection[] = $class->newInstanceArgs([$this->master, $item]);
}
return $modelcollection;
} | [
"private",
"function",
"buildCollectionModels",
"(",
"array",
"$",
"items",
")",
"{",
"$",
"modelcollection",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"\"\\\\DirkGroenen\\\\Pinterest\\\\Models\\\\\"",
".",
"$",
"this",
"->",
"model",
")",
";",
"$",
"modelcollection",
"[",
"]",
"=",
"$",
"class",
"->",
"newInstanceArgs",
"(",
"[",
"$",
"this",
"->",
"master",
",",
"$",
"item",
"]",
")",
";",
"}",
"return",
"$",
"modelcollection",
";",
"}"
] | Transform each raw item into a model
@access private
@param array $items
@return array | [
"Transform",
"each",
"raw",
"item",
"into",
"a",
"model"
] | train | https://github.com/dirkgroenen/Pinterest-API-PHP/blob/2dcffb7d4f4ffbc9a43ea962d79ebcda3b06efce/src/Pinterest/Models/Collection.php#L114-L124 |
laracasts/Integrated | src/AnnotationReader.php | AnnotationReader.having | public function having($annotation)
{
$methods = [];
foreach ($this->reflectInto($this->reference) as $method) {
if ($this->hasAnnotation($annotation, $method)) {
$methods[] = $method->getName();
}
}
// We'll reverse the results to ensure that this package's
// hooks are called *before* the user's.
return array_reverse($methods);
} | php | public function having($annotation)
{
$methods = [];
foreach ($this->reflectInto($this->reference) as $method) {
if ($this->hasAnnotation($annotation, $method)) {
$methods[] = $method->getName();
}
}
// We'll reverse the results to ensure that this package's
// hooks are called *before* the user's.
return array_reverse($methods);
} | [
"public",
"function",
"having",
"(",
"$",
"annotation",
")",
"{",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"reflectInto",
"(",
"$",
"this",
"->",
"reference",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAnnotation",
"(",
"$",
"annotation",
",",
"$",
"method",
")",
")",
"{",
"$",
"methods",
"[",
"]",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"// We'll reverse the results to ensure that this package's",
"// hooks are called *before* the user's.",
"return",
"array_reverse",
"(",
"$",
"methods",
")",
";",
"}"
] | Get method names for the referenced object
which contain the given annotation.
@param string $annotation
@return array | [
"Get",
"method",
"names",
"for",
"the",
"referenced",
"object",
"which",
"contain",
"the",
"given",
"annotation",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/AnnotationReader.php#L34-L48 |
laracasts/Integrated | src/Extensions/Traits/WorksWithDatabase.php | WorksWithDatabase.getDbAdapter | protected function getDbAdapter()
{
if (! $this->db) {
try {
$config = $this->getPackageConfig('pdo');
} catch (IntegratedException $e) {
throw new IntegratedException(
"Thank you for riding Johnny Cab. To input your destination (and use the database adapter with Selenium), " .
"you must specify your db connection in a integrated.json file." .
"\n\nSee: https://github.com/laracasts/Integrated/wiki/Configuration#database-credentials"
);
}
$connection = new Connection($this->getPackageConfig('pdo'));
$this->db = new Adapter($connection);
}
return $this->db;
} | php | protected function getDbAdapter()
{
if (! $this->db) {
try {
$config = $this->getPackageConfig('pdo');
} catch (IntegratedException $e) {
throw new IntegratedException(
"Thank you for riding Johnny Cab. To input your destination (and use the database adapter with Selenium), " .
"you must specify your db connection in a integrated.json file." .
"\n\nSee: https://github.com/laracasts/Integrated/wiki/Configuration#database-credentials"
);
}
$connection = new Connection($this->getPackageConfig('pdo'));
$this->db = new Adapter($connection);
}
return $this->db;
} | [
"protected",
"function",
"getDbAdapter",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"db",
")",
"{",
"try",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getPackageConfig",
"(",
"'pdo'",
")",
";",
"}",
"catch",
"(",
"IntegratedException",
"$",
"e",
")",
"{",
"throw",
"new",
"IntegratedException",
"(",
"\"Thank you for riding Johnny Cab. To input your destination (and use the database adapter with Selenium), \"",
".",
"\"you must specify your db connection in a integrated.json file.\"",
".",
"\"\\n\\nSee: https://github.com/laracasts/Integrated/wiki/Configuration#database-credentials\"",
")",
";",
"}",
"$",
"connection",
"=",
"new",
"Connection",
"(",
"$",
"this",
"->",
"getPackageConfig",
"(",
"'pdo'",
")",
")",
";",
"$",
"this",
"->",
"db",
"=",
"new",
"Adapter",
"(",
"$",
"connection",
")",
";",
"}",
"return",
"$",
"this",
"->",
"db",
";",
"}"
] | Get the adapter to the database.
@return Adapter | [
"Get",
"the",
"adapter",
"to",
"the",
"database",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/WorksWithDatabase.php#L25-L43 |
laracasts/Integrated | src/Extensions/Traits/WorksWithDatabase.php | WorksWithDatabase.seeRowsWereReturned | protected function seeRowsWereReturned($table, $data)
{
// If the user has imported the Laravel application trait, we can use Laravel to
// work with the database.
if (isset($this->app) || in_array('Laracasts\Integrated\Services\Laravel\Application', class_uses($this))) {
return $this->app['db']->table($table)->where($data)->count();
}
// Otherwise, we'll default to the database adapter that Integrated provides.
return $this->getDbAdapter()->table($table)->whereExists($data);
} | php | protected function seeRowsWereReturned($table, $data)
{
// If the user has imported the Laravel application trait, we can use Laravel to
// work with the database.
if (isset($this->app) || in_array('Laracasts\Integrated\Services\Laravel\Application', class_uses($this))) {
return $this->app['db']->table($table)->where($data)->count();
}
// Otherwise, we'll default to the database adapter that Integrated provides.
return $this->getDbAdapter()->table($table)->whereExists($data);
} | [
"protected",
"function",
"seeRowsWereReturned",
"(",
"$",
"table",
",",
"$",
"data",
")",
"{",
"// If the user has imported the Laravel application trait, we can use Laravel to",
"// work with the database.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"app",
")",
"||",
"in_array",
"(",
"'Laracasts\\Integrated\\Services\\Laravel\\Application'",
",",
"class_uses",
"(",
"$",
"this",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"[",
"'db'",
"]",
"->",
"table",
"(",
"$",
"table",
")",
"->",
"where",
"(",
"$",
"data",
")",
"->",
"count",
"(",
")",
";",
"}",
"// Otherwise, we'll default to the database adapter that Integrated provides.",
"return",
"$",
"this",
"->",
"getDbAdapter",
"(",
")",
"->",
"table",
"(",
"$",
"table",
")",
"->",
"whereExists",
"(",
"$",
"data",
")",
";",
"}"
] | Get the number of rows that match the given condition.
@param string $table
@param array $data
@return integer | [
"Get",
"the",
"number",
"of",
"rows",
"that",
"match",
"the",
"given",
"condition",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/WorksWithDatabase.php#L52-L64 |
laracasts/Integrated | src/Extensions/Goutte.php | Goutte.baseUrl | public function baseUrl()
{
if (isset($this->baseUrl)) {
return $this->baseUrl;
}
$config = $this->getPackageConfig();
if (isset($config['baseUrl'])) {
return $config['baseUrl'];
}
return 'http://localhost:8888';
} | php | public function baseUrl()
{
if (isset($this->baseUrl)) {
return $this->baseUrl;
}
$config = $this->getPackageConfig();
if (isset($config['baseUrl'])) {
return $config['baseUrl'];
}
return 'http://localhost:8888';
} | [
"public",
"function",
"baseUrl",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"baseUrl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"baseUrl",
";",
"}",
"$",
"config",
"=",
"$",
"this",
"->",
"getPackageConfig",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'baseUrl'",
"]",
")",
")",
"{",
"return",
"$",
"config",
"[",
"'baseUrl'",
"]",
";",
"}",
"return",
"'http://localhost:8888'",
";",
"}"
] | Get the base url for all requests.
@return string | [
"Get",
"the",
"base",
"url",
"for",
"all",
"requests",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Goutte.php#L27-L40 |
laracasts/Integrated | src/Extensions/Goutte.php | Goutte.submitForm | public function submitForm($buttonText, $formData = null)
{
$this->client()->submit(
$this->fillForm($buttonText, $formData)
);
$this->currentPage = $this->client()->getHistory()->current()->getUri();
$this->clearInputs()->assertPageLoaded($this->currentPage());
return $this;
} | php | public function submitForm($buttonText, $formData = null)
{
$this->client()->submit(
$this->fillForm($buttonText, $formData)
);
$this->currentPage = $this->client()->getHistory()->current()->getUri();
$this->clearInputs()->assertPageLoaded($this->currentPage());
return $this;
} | [
"public",
"function",
"submitForm",
"(",
"$",
"buttonText",
",",
"$",
"formData",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"client",
"(",
")",
"->",
"submit",
"(",
"$",
"this",
"->",
"fillForm",
"(",
"$",
"buttonText",
",",
"$",
"formData",
")",
")",
";",
"$",
"this",
"->",
"currentPage",
"=",
"$",
"this",
"->",
"client",
"(",
")",
"->",
"getHistory",
"(",
")",
"->",
"current",
"(",
")",
"->",
"getUri",
"(",
")",
";",
"$",
"this",
"->",
"clearInputs",
"(",
")",
"->",
"assertPageLoaded",
"(",
"$",
"this",
"->",
"currentPage",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Submit a form on the page.
@param string $buttonText
@param array|null $formData
@return static | [
"Submit",
"a",
"form",
"on",
"the",
"page",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Goutte.php#L49-L60 |
laracasts/Integrated | src/Extensions/Goutte.php | Goutte.makeRequest | protected function makeRequest($requestType, $uri)
{
$this->crawler = $this->client()->request('GET', $uri);
$this->clearInputs()->assertPageLoaded($uri);
return $this;
} | php | protected function makeRequest($requestType, $uri)
{
$this->crawler = $this->client()->request('GET', $uri);
$this->clearInputs()->assertPageLoaded($uri);
return $this;
} | [
"protected",
"function",
"makeRequest",
"(",
"$",
"requestType",
",",
"$",
"uri",
")",
"{",
"$",
"this",
"->",
"crawler",
"=",
"$",
"this",
"->",
"client",
"(",
")",
"->",
"request",
"(",
"'GET'",
",",
"$",
"uri",
")",
";",
"$",
"this",
"->",
"clearInputs",
"(",
")",
"->",
"assertPageLoaded",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Call a URI in the application.
@param string $requestType
@param string $uri
@param array $parameters
@return static | [
"Call",
"a",
"URI",
"in",
"the",
"application",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Goutte.php#L70-L77 |
laracasts/Integrated | src/Database/Adapter.php | Adapter.whereExists | public function whereExists(array $data)
{
$this->parseConstraints($data);
$query = $this->connection->getPdo()->prepare($this->getSelectQuery());
return $this->execute($query)->fetch();
} | php | public function whereExists(array $data)
{
$this->parseConstraints($data);
$query = $this->connection->getPdo()->prepare($this->getSelectQuery());
return $this->execute($query)->fetch();
} | [
"public",
"function",
"whereExists",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"parseConstraints",
"(",
"$",
"data",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"getPdo",
"(",
")",
"->",
"prepare",
"(",
"$",
"this",
"->",
"getSelectQuery",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
")",
"->",
"fetch",
"(",
")",
";",
"}"
] | See if the table contains records that match the given data.
@param array $data
@return boolean | [
"See",
"if",
"the",
"table",
"contains",
"records",
"that",
"match",
"the",
"given",
"data",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Database/Adapter.php#L57-L64 |
laracasts/Integrated | src/Database/Adapter.php | Adapter.parseConstraints | protected function parseConstraints(array $wheres)
{
foreach ($wheres as $column => $value) {
$this->wheres[] = "{$column} = ?";
$this->bindings[] = $value;
}
} | php | protected function parseConstraints(array $wheres)
{
foreach ($wheres as $column => $value) {
$this->wheres[] = "{$column} = ?";
$this->bindings[] = $value;
}
} | [
"protected",
"function",
"parseConstraints",
"(",
"array",
"$",
"wheres",
")",
"{",
"foreach",
"(",
"$",
"wheres",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
"\"{$column} = ?\"",
";",
"$",
"this",
"->",
"bindings",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Parse the "where" constraints.
@param array $wheres
@return void | [
"Parse",
"the",
"where",
"constraints",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Database/Adapter.php#L72-L78 |
laracasts/Integrated | src/Database/Adapter.php | Adapter.execute | protected function execute($query)
{
$query->execute($this->bindings);
$this->bindings = [];
$this->wheres = [];
return $query;
} | php | protected function execute($query)
{
$query->execute($this->bindings);
$this->bindings = [];
$this->wheres = [];
return $query;
} | [
"protected",
"function",
"execute",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"execute",
"(",
"$",
"this",
"->",
"bindings",
")",
";",
"$",
"this",
"->",
"bindings",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"wheres",
"=",
"[",
"]",
";",
"return",
"$",
"query",
";",
"}"
] | Execute the query.
@param \PDOStatement $query
@return \PDOStatement | [
"Execute",
"the",
"query",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Database/Adapter.php#L99-L107 |
laracasts/Integrated | src/File.php | File.put | public function put($path, $contents)
{
$this->makeDirectory(dirname($path));
return file_put_contents($path, $contents);
} | php | public function put($path, $contents)
{
$this->makeDirectory(dirname($path));
return file_put_contents($path, $contents);
} | [
"public",
"function",
"put",
"(",
"$",
"path",
",",
"$",
"contents",
")",
"{",
"$",
"this",
"->",
"makeDirectory",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
";",
"return",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"contents",
")",
";",
"}"
] | Put to a file path.
@param string $path
@param string $contents
@return mixed | [
"Put",
"to",
"a",
"file",
"path",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/File.php#L27-L32 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.visit | public function visit($uri)
{
$this->currentPage = $this->prepareUrl($uri);
$this->makeRequest('GET', $this->currentPage);
return $this;
} | php | public function visit($uri)
{
$this->currentPage = $this->prepareUrl($uri);
$this->makeRequest('GET', $this->currentPage);
return $this;
} | [
"public",
"function",
"visit",
"(",
"$",
"uri",
")",
"{",
"$",
"this",
"->",
"currentPage",
"=",
"$",
"this",
"->",
"prepareUrl",
"(",
"$",
"uri",
")",
";",
"$",
"this",
"->",
"makeRequest",
"(",
"'GET'",
",",
"$",
"this",
"->",
"currentPage",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Make a GET request to the given uri.
@param string $uri
@return static | [
"Make",
"a",
"GET",
"request",
"to",
"the",
"given",
"uri",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L86-L93 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.prepareUrl | protected function prepareUrl($url)
{
if (Str::startsWith($url, '/')) {
$url = substr($url, 1);
}
if (! Str::startsWith($url, 'http')) {
$url = sprintf("%s/%s", $this->baseUrl(), $url);
}
return trim($url, '/');
} | php | protected function prepareUrl($url)
{
if (Str::startsWith($url, '/')) {
$url = substr($url, 1);
}
if (! Str::startsWith($url, 'http')) {
$url = sprintf("%s/%s", $this->baseUrl(), $url);
}
return trim($url, '/');
} | [
"protected",
"function",
"prepareUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"Str",
"::",
"startsWith",
"(",
"$",
"url",
",",
"'/'",
")",
")",
"{",
"$",
"url",
"=",
"substr",
"(",
"$",
"url",
",",
"1",
")",
";",
"}",
"if",
"(",
"!",
"Str",
"::",
"startsWith",
"(",
"$",
"url",
",",
"'http'",
")",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"\"%s/%s\"",
",",
"$",
"this",
"->",
"baseUrl",
"(",
")",
",",
"$",
"url",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"url",
",",
"'/'",
")",
";",
"}"
] | Prepare the relative URL, given by the user.
@param string $url
@return string | [
"Prepare",
"the",
"relative",
"URL",
"given",
"by",
"the",
"user",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L101-L112 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.assertSee | protected function assertSee($text, $message, $negate = false)
{
try {
$text = preg_quote($text, '/');
$method = $negate ? 'assertNotRegExp' : 'assertRegExp';
$this->$method("/{$text}/i", $this->response(), $message);
} catch (PHPUnitException $e) {
$this->logLatestContent();
throw $e;
}
return $this;
} | php | protected function assertSee($text, $message, $negate = false)
{
try {
$text = preg_quote($text, '/');
$method = $negate ? 'assertNotRegExp' : 'assertRegExp';
$this->$method("/{$text}/i", $this->response(), $message);
} catch (PHPUnitException $e) {
$this->logLatestContent();
throw $e;
}
return $this;
} | [
"protected",
"function",
"assertSee",
"(",
"$",
"text",
",",
"$",
"message",
",",
"$",
"negate",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"text",
"=",
"preg_quote",
"(",
"$",
"text",
",",
"'/'",
")",
";",
"$",
"method",
"=",
"$",
"negate",
"?",
"'assertNotRegExp'",
":",
"'assertRegExp'",
";",
"$",
"this",
"->",
"$",
"method",
"(",
"\"/{$text}/i\"",
",",
"$",
"this",
"->",
"response",
"(",
")",
",",
"$",
"message",
")",
";",
"}",
"catch",
"(",
"PHPUnitException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logLatestContent",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Assert that the page contains the given text.
@param string $text
@param string $message
@param boolean $negate
@return static
@throws PHPUnitException | [
"Assert",
"that",
"the",
"page",
"contains",
"the",
"given",
"text",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L123-L137 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.notSee | public function notSee($text)
{
return $this->assertSee($text, sprintf(
"Could not find '%s' on the page, '%s'.", $text, $this->currentPage
), true);
} | php | public function notSee($text)
{
return $this->assertSee($text, sprintf(
"Could not find '%s' on the page, '%s'.", $text, $this->currentPage
), true);
} | [
"public",
"function",
"notSee",
"(",
"$",
"text",
")",
"{",
"return",
"$",
"this",
"->",
"assertSee",
"(",
"$",
"text",
",",
"sprintf",
"(",
"\"Could not find '%s' on the page, '%s'.\"",
",",
"$",
"text",
",",
"$",
"this",
"->",
"currentPage",
")",
",",
"true",
")",
";",
"}"
] | Assert that the page does not contain the given text.
@param string $text
@return static
@throws PHPUnitException | [
"Assert",
"that",
"the",
"page",
"does",
"not",
"contain",
"the",
"given",
"text",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L160-L165 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.assertPageIs | public function assertPageIs($uri, $message, $negate = false)
{
$this->assertPageLoaded($uri = $this->prepareUrl($uri));
$method = $negate ? 'assertNotEquals' : 'assertEquals';
$this->$method($uri, $this->currentPage(), $message);
return $this;
} | php | public function assertPageIs($uri, $message, $negate = false)
{
$this->assertPageLoaded($uri = $this->prepareUrl($uri));
$method = $negate ? 'assertNotEquals' : 'assertEquals';
$this->$method($uri, $this->currentPage(), $message);
return $this;
} | [
"public",
"function",
"assertPageIs",
"(",
"$",
"uri",
",",
"$",
"message",
",",
"$",
"negate",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"assertPageLoaded",
"(",
"$",
"uri",
"=",
"$",
"this",
"->",
"prepareUrl",
"(",
"$",
"uri",
")",
")",
";",
"$",
"method",
"=",
"$",
"negate",
"?",
"'assertNotEquals'",
":",
"'assertEquals'",
";",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"uri",
",",
"$",
"this",
"->",
"currentPage",
"(",
")",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Assert that the page URI matches the given uri.
@param string $uri
@param message $message
@param boolean $negate
@return static | [
"Assert",
"that",
"the",
"page",
"URI",
"matches",
"the",
"given",
"uri",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L175-L184 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.attachFile | public function attachFile($element, $absolutePath)
{
$name = str_replace('#', '', $element);
$this->files[$name] = $absolutePath;
return $this->storeInput($element, $absolutePath);
} | php | public function attachFile($element, $absolutePath)
{
$name = str_replace('#', '', $element);
$this->files[$name] = $absolutePath;
return $this->storeInput($element, $absolutePath);
} | [
"public",
"function",
"attachFile",
"(",
"$",
"element",
",",
"$",
"absolutePath",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'#'",
",",
"''",
",",
"$",
"element",
")",
";",
"$",
"this",
"->",
"files",
"[",
"$",
"name",
"]",
"=",
"$",
"absolutePath",
";",
"return",
"$",
"this",
"->",
"storeInput",
"(",
"$",
"element",
",",
"$",
"absolutePath",
")",
";",
"}"
] | Attach a file to a form.
@param string $element
@param string $absolutePath
@return static | [
"Attach",
"a",
"file",
"to",
"a",
"form",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L350-L357 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.storeInput | protected function storeInput($name, $value)
{
$this->assertFilterProducedResults($name);
$name = str_replace('#', '', $name);
$this->inputs[$name] = $value;
return $this;
} | php | protected function storeInput($name, $value)
{
$this->assertFilterProducedResults($name);
$name = str_replace('#', '', $name);
$this->inputs[$name] = $value;
return $this;
} | [
"protected",
"function",
"storeInput",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"assertFilterProducedResults",
"(",
"$",
"name",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"'#'",
",",
"''",
",",
"$",
"name",
")",
";",
"$",
"this",
"->",
"inputs",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Store a form input.
@param string $name
@param string $value
@return static | [
"Store",
"a",
"form",
"input",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L366-L375 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.fillForm | protected function fillForm($buttonText, $formData = [])
{
if (! is_string($buttonText)) {
$formData = $buttonText;
$buttonText = null;
}
return $this->getForm($buttonText)->setValues($formData);
} | php | protected function fillForm($buttonText, $formData = [])
{
if (! is_string($buttonText)) {
$formData = $buttonText;
$buttonText = null;
}
return $this->getForm($buttonText)->setValues($formData);
} | [
"protected",
"function",
"fillForm",
"(",
"$",
"buttonText",
",",
"$",
"formData",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"buttonText",
")",
")",
"{",
"$",
"formData",
"=",
"$",
"buttonText",
";",
"$",
"buttonText",
"=",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"getForm",
"(",
"$",
"buttonText",
")",
"->",
"setValues",
"(",
"$",
"formData",
")",
";",
"}"
] | Fill out the form, using the given data.
@param string $buttonText
@param array $formData
@return Form | [
"Fill",
"out",
"the",
"form",
"using",
"the",
"given",
"data",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L407-L415 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.getForm | protected function getForm($button = null)
{
// If the first argument isn't a string, that means
// the user wants us to auto-find the form.
try {
if ($button) {
return $this->crawler->selectButton($button)->form();
}
return $this->crawler->filter('form')->form();
} catch (InvalidArgumentException $e) {
// We'll catch the exception, in order to provide a
// more readable failure message for the user.
throw new InvalidArgumentException(
"Couldn't find a form that contains a button with text '{$button}'."
);
}
} | php | protected function getForm($button = null)
{
// If the first argument isn't a string, that means
// the user wants us to auto-find the form.
try {
if ($button) {
return $this->crawler->selectButton($button)->form();
}
return $this->crawler->filter('form')->form();
} catch (InvalidArgumentException $e) {
// We'll catch the exception, in order to provide a
// more readable failure message for the user.
throw new InvalidArgumentException(
"Couldn't find a form that contains a button with text '{$button}'."
);
}
} | [
"protected",
"function",
"getForm",
"(",
"$",
"button",
"=",
"null",
")",
"{",
"// If the first argument isn't a string, that means",
"// the user wants us to auto-find the form.",
"try",
"{",
"if",
"(",
"$",
"button",
")",
"{",
"return",
"$",
"this",
"->",
"crawler",
"->",
"selectButton",
"(",
"$",
"button",
")",
"->",
"form",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"crawler",
"->",
"filter",
"(",
"'form'",
")",
"->",
"form",
"(",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"// We'll catch the exception, in order to provide a",
"// more readable failure message for the user.",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Couldn't find a form that contains a button with text '{$button}'.\"",
")",
";",
"}",
"}"
] | Get the form from the DOM.
@param string|null $button
@throws InvalidArgumentException
@return Form | [
"Get",
"the",
"form",
"from",
"the",
"DOM",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L424-L443 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.assertPageLoaded | protected function assertPageLoaded($uri, $message = null)
{
$status = $this->statusCode();
try {
$this->assertEquals(200, $status);
} catch (PHPUnitException $e) {
$message = $message ?: "A GET request to '{$uri}' failed. Got a {$status} code instead.";
$this->logLatestContent();
if (method_exists($this, 'handleInternalError')) {
$this->handleInternalError($message);
}
throw new PHPUnitException($message);
}
} | php | protected function assertPageLoaded($uri, $message = null)
{
$status = $this->statusCode();
try {
$this->assertEquals(200, $status);
} catch (PHPUnitException $e) {
$message = $message ?: "A GET request to '{$uri}' failed. Got a {$status} code instead.";
$this->logLatestContent();
if (method_exists($this, 'handleInternalError')) {
$this->handleInternalError($message);
}
throw new PHPUnitException($message);
}
} | [
"protected",
"function",
"assertPageLoaded",
"(",
"$",
"uri",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"statusCode",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"assertEquals",
"(",
"200",
",",
"$",
"status",
")",
";",
"}",
"catch",
"(",
"PHPUnitException",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"\"A GET request to '{$uri}' failed. Got a {$status} code instead.\"",
";",
"$",
"this",
"->",
"logLatestContent",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'handleInternalError'",
")",
")",
"{",
"$",
"this",
"->",
"handleInternalError",
"(",
"$",
"message",
")",
";",
"}",
"throw",
"new",
"PHPUnitException",
"(",
"$",
"message",
")",
";",
"}",
"}"
] | Assert that a 200 status code was returned from the last call.
@param string $uri
@param string $message
@throws PHPUnitException
@return void | [
"Assert",
"that",
"a",
"200",
"status",
"code",
"was",
"returned",
"from",
"the",
"last",
"call",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L463-L480 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.assertFilterProducedResults | protected function assertFilterProducedResults($filter)
{
$crawler = $this->filterByNameOrId($filter);
if (! count($crawler)) {
$message = "Nothing matched the '{$filter}' CSS query provided for {$this->currentPage}.";
throw new InvalidArgumentException($message);
}
} | php | protected function assertFilterProducedResults($filter)
{
$crawler = $this->filterByNameOrId($filter);
if (! count($crawler)) {
$message = "Nothing matched the '{$filter}' CSS query provided for {$this->currentPage}.";
throw new InvalidArgumentException($message);
}
} | [
"protected",
"function",
"assertFilterProducedResults",
"(",
"$",
"filter",
")",
"{",
"$",
"crawler",
"=",
"$",
"this",
"->",
"filterByNameOrId",
"(",
"$",
"filter",
")",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"crawler",
")",
")",
"{",
"$",
"message",
"=",
"\"Nothing matched the '{$filter}' CSS query provided for {$this->currentPage}.\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"}"
] | Assert that the filtered Crawler contains nodes.
@param string $filter
@throws InvalidArgumentException
@return void | [
"Assert",
"that",
"the",
"filtered",
"Crawler",
"contains",
"nodes",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L489-L498 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.assertInDatabase | public function assertInDatabase($table, array $data, $message, $negate = false)
{
$count = $this->seeRowsWereReturned($table, $data);
$method = $negate ? 'assertEquals' : 'assertGreaterThan';
$this->$method(0, $count, $message);
return $this;
} | php | public function assertInDatabase($table, array $data, $message, $negate = false)
{
$count = $this->seeRowsWereReturned($table, $data);
$method = $negate ? 'assertEquals' : 'assertGreaterThan';
$this->$method(0, $count, $message);
return $this;
} | [
"public",
"function",
"assertInDatabase",
"(",
"$",
"table",
",",
"array",
"$",
"data",
",",
"$",
"message",
",",
"$",
"negate",
"=",
"false",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"seeRowsWereReturned",
"(",
"$",
"table",
",",
"$",
"data",
")",
";",
"$",
"method",
"=",
"$",
"negate",
"?",
"'assertEquals'",
":",
"'assertGreaterThan'",
";",
"$",
"this",
"->",
"$",
"method",
"(",
"0",
",",
"$",
"count",
",",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Assert that a record is contained in the database.
@param string $table
@param array $data
@param string $message
@param boolean $negate
@return static | [
"Assert",
"that",
"a",
"record",
"is",
"contained",
"in",
"the",
"database",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L535-L543 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.seeInDatabase | public function seeInDatabase($table, array $data)
{
return $this->assertInDatabase($table, $data, sprintf(
"Didn't see row in the '%s' table that matched the attributes '%s'.",
$table, json_encode($data)
));
} | php | public function seeInDatabase($table, array $data)
{
return $this->assertInDatabase($table, $data, sprintf(
"Didn't see row in the '%s' table that matched the attributes '%s'.",
$table, json_encode($data)
));
} | [
"public",
"function",
"seeInDatabase",
"(",
"$",
"table",
",",
"array",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"assertInDatabase",
"(",
"$",
"table",
",",
"$",
"data",
",",
"sprintf",
"(",
"\"Didn't see row in the '%s' table that matched the attributes '%s'.\"",
",",
"$",
"table",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
")",
";",
"}"
] | Ensure that a database table contains a row with the given data.
@param string $table
@param array $data
@return static | [
"Ensure",
"that",
"a",
"database",
"table",
"contains",
"a",
"row",
"with",
"the",
"given",
"data",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L552-L558 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.notSeeInDatabase | public function notSeeInDatabase($table, array $data)
{
return $this->assertInDatabase($table, $data, sprintf(
"Found row(s) in the '%s' table that matched the attributes '%s', but did not expect to.",
$table, json_encode($data)
), true);
} | php | public function notSeeInDatabase($table, array $data)
{
return $this->assertInDatabase($table, $data, sprintf(
"Found row(s) in the '%s' table that matched the attributes '%s', but did not expect to.",
$table, json_encode($data)
), true);
} | [
"public",
"function",
"notSeeInDatabase",
"(",
"$",
"table",
",",
"array",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"assertInDatabase",
"(",
"$",
"table",
",",
"$",
"data",
",",
"sprintf",
"(",
"\"Found row(s) in the '%s' table that matched the attributes '%s', but did not expect to.\"",
",",
"$",
"table",
",",
"json_encode",
"(",
"$",
"data",
")",
")",
",",
"true",
")",
";",
"}"
] | Ensure that a database table does not contain a row with the given data.
@param string $table
@param array $data
@return static | [
"Ensure",
"that",
"a",
"database",
"table",
"does",
"not",
"contain",
"a",
"row",
"with",
"the",
"given",
"data",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L567-L573 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.getPackageConfig | protected function getPackageConfig($key = null)
{
if (! file_exists('integrated.json') && ! file_exists('integrated.php')) {
return [];
}
if ( ! $this->packageConfig) {
$this->loadPreferredConfigFile();
}
if ($key) {
if (! isset($this->packageConfig[$key])) {
throw new IntegratedException(
"Hmm, did you set a '{$key}' key in your integrated.(json|php) file? Can't find it!"
);
}
return $this->packageConfig[$key];
}
return $this->packageConfig;
} | php | protected function getPackageConfig($key = null)
{
if (! file_exists('integrated.json') && ! file_exists('integrated.php')) {
return [];
}
if ( ! $this->packageConfig) {
$this->loadPreferredConfigFile();
}
if ($key) {
if (! isset($this->packageConfig[$key])) {
throw new IntegratedException(
"Hmm, did you set a '{$key}' key in your integrated.(json|php) file? Can't find it!"
);
}
return $this->packageConfig[$key];
}
return $this->packageConfig;
} | [
"protected",
"function",
"getPackageConfig",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"'integrated.json'",
")",
"&&",
"!",
"file_exists",
"(",
"'integrated.php'",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"packageConfig",
")",
"{",
"$",
"this",
"->",
"loadPreferredConfigFile",
"(",
")",
";",
"}",
"if",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"packageConfig",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"IntegratedException",
"(",
"\"Hmm, did you set a '{$key}' key in your integrated.(json|php) file? Can't find it!\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"packageConfig",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"packageConfig",
";",
"}"
] | Fetch the user-provided package configuration.
@param string|null $key
@return object | [
"Fetch",
"the",
"user",
"-",
"provided",
"package",
"configuration",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L645-L666 |
laracasts/Integrated | src/Extensions/IntegrationTrait.php | IntegrationTrait.loadPreferredConfigFile | protected function loadPreferredConfigFile()
{
if (file_exists('integrated.php')) {
return $this->packageConfig = require('integrated.php');
}
if (file_exists('integrated.json')) {
$this->packageConfig = json_decode(file_get_contents('integrated.json'), true);
}
} | php | protected function loadPreferredConfigFile()
{
if (file_exists('integrated.php')) {
return $this->packageConfig = require('integrated.php');
}
if (file_exists('integrated.json')) {
$this->packageConfig = json_decode(file_get_contents('integrated.json'), true);
}
} | [
"protected",
"function",
"loadPreferredConfigFile",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"'integrated.php'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"packageConfig",
"=",
"require",
"(",
"'integrated.php'",
")",
";",
"}",
"if",
"(",
"file_exists",
"(",
"'integrated.json'",
")",
")",
"{",
"$",
"this",
"->",
"packageConfig",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"'integrated.json'",
")",
",",
"true",
")",
";",
"}",
"}"
] | Load the configuration file.
@return void | [
"Load",
"the",
"configuration",
"file",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/IntegrationTrait.php#L673-L682 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.makeRequest | protected function makeRequest($requestType, $uri, $parameters = [])
{
try {
$this->closeBrowser();
$this->session = $this->newSession()->open($uri);
$this->updateCurrentUrl();
} catch (CurlExec $e) {
throw new CurlExec(
"Hold on there, partner. Did you maybe forget to boot up Selenium? " .
"\n\njava -jar selenium-server-standalone-*.jar" .
"\n\n" . $e->getMessage()
);
}
return $this;
} | php | protected function makeRequest($requestType, $uri, $parameters = [])
{
try {
$this->closeBrowser();
$this->session = $this->newSession()->open($uri);
$this->updateCurrentUrl();
} catch (CurlExec $e) {
throw new CurlExec(
"Hold on there, partner. Did you maybe forget to boot up Selenium? " .
"\n\njava -jar selenium-server-standalone-*.jar" .
"\n\n" . $e->getMessage()
);
}
return $this;
} | [
"protected",
"function",
"makeRequest",
"(",
"$",
"requestType",
",",
"$",
"uri",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"closeBrowser",
"(",
")",
";",
"$",
"this",
"->",
"session",
"=",
"$",
"this",
"->",
"newSession",
"(",
")",
"->",
"open",
"(",
"$",
"uri",
")",
";",
"$",
"this",
"->",
"updateCurrentUrl",
"(",
")",
";",
"}",
"catch",
"(",
"CurlExec",
"$",
"e",
")",
"{",
"throw",
"new",
"CurlExec",
"(",
"\"Hold on there, partner. Did you maybe forget to boot up Selenium? \"",
".",
"\"\\n\\njava -jar selenium-server-standalone-*.jar\"",
".",
"\"\\n\\n\"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Call a URI in the application.
@param string $requestType
@param string $uri
@param array $parameters
@return self | [
"Call",
"a",
"URI",
"in",
"the",
"application",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L65-L80 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.click | public function click($name)
{
$page = $this->currentPage();
try {
$link = $this->findByBody($name)->click();
} catch (InvalidArgumentException $e) {
$link = $this->findByNameOrId($name)->click();
}
$this->updateCurrentUrl();
$this->assertPageLoaded(
$page,
"Successfully clicked on a link with a body, name, or class of '{$name}', " .
"but its destination, {$page}, did not produce a 200 status code."
);
return $this;
} | php | public function click($name)
{
$page = $this->currentPage();
try {
$link = $this->findByBody($name)->click();
} catch (InvalidArgumentException $e) {
$link = $this->findByNameOrId($name)->click();
}
$this->updateCurrentUrl();
$this->assertPageLoaded(
$page,
"Successfully clicked on a link with a body, name, or class of '{$name}', " .
"but its destination, {$page}, did not produce a 200 status code."
);
return $this;
} | [
"public",
"function",
"click",
"(",
"$",
"name",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"currentPage",
"(",
")",
";",
"try",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"findByBody",
"(",
"$",
"name",
")",
"->",
"click",
"(",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"findByNameOrId",
"(",
"$",
"name",
")",
"->",
"click",
"(",
")",
";",
"}",
"$",
"this",
"->",
"updateCurrentUrl",
"(",
")",
";",
"$",
"this",
"->",
"assertPageLoaded",
"(",
"$",
"page",
",",
"\"Successfully clicked on a link with a body, name, or class of '{$name}', \"",
".",
"\"but its destination, {$page}, did not produce a 200 status code.\"",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Click a link with the given body.
@param string $name
@return static | [
"Click",
"a",
"link",
"with",
"the",
"given",
"body",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L88-L107 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.findByNameOrId | protected function findByNameOrId($name, $element = '*')
{
$name = str_replace('#', '', $name);
try {
return $this->session->element('css selector', "#{$name}, *[name={$name}]");
} catch (NoSuchElement $e) {
throw new InvalidArgumentException(
"Couldn't find an element, '{$element}', with a name or class attribute of '{$name}'."
);
}
} | php | protected function findByNameOrId($name, $element = '*')
{
$name = str_replace('#', '', $name);
try {
return $this->session->element('css selector', "#{$name}, *[name={$name}]");
} catch (NoSuchElement $e) {
throw new InvalidArgumentException(
"Couldn't find an element, '{$element}', with a name or class attribute of '{$name}'."
);
}
} | [
"protected",
"function",
"findByNameOrId",
"(",
"$",
"name",
",",
"$",
"element",
"=",
"'*'",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'#'",
",",
"''",
",",
"$",
"name",
")",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"session",
"->",
"element",
"(",
"'css selector'",
",",
"\"#{$name}, *[name={$name}]\"",
")",
";",
"}",
"catch",
"(",
"NoSuchElement",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Couldn't find an element, '{$element}', with a name or class attribute of '{$name}'.\"",
")",
";",
"}",
"}"
] | Filter according to an element's name or id attribute.
@param string $name
@param string $element
@return Crawler | [
"Filter",
"according",
"to",
"an",
"element",
"s",
"name",
"or",
"id",
"attribute",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L131-L142 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.findByValue | protected function findByValue($value, $element = 'input')
{
try {
return $this->session->element('css selector', "{$element}[value='{$value}']");
} catch (NoSuchElement $e) {
try {
return $this->session->element('xpath', "//button[contains(text(),'{$value}')]");
} catch (NoSuchElement $e) {
throw new InvalidArgumentException(
"Crap. Couldn't find an {$element} with a 'value' attribute of '{$value}'. We also looked " .
"for a button that contains the text, '{$value}', but no dice either."
);
}
}
} | php | protected function findByValue($value, $element = 'input')
{
try {
return $this->session->element('css selector', "{$element}[value='{$value}']");
} catch (NoSuchElement $e) {
try {
return $this->session->element('xpath', "//button[contains(text(),'{$value}')]");
} catch (NoSuchElement $e) {
throw new InvalidArgumentException(
"Crap. Couldn't find an {$element} with a 'value' attribute of '{$value}'. We also looked " .
"for a button that contains the text, '{$value}', but no dice either."
);
}
}
} | [
"protected",
"function",
"findByValue",
"(",
"$",
"value",
",",
"$",
"element",
"=",
"'input'",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"session",
"->",
"element",
"(",
"'css selector'",
",",
"\"{$element}[value='{$value}']\"",
")",
";",
"}",
"catch",
"(",
"NoSuchElement",
"$",
"e",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"session",
"->",
"element",
"(",
"'xpath'",
",",
"\"//button[contains(text(),'{$value}')]\"",
")",
";",
"}",
"catch",
"(",
"NoSuchElement",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Crap. Couldn't find an {$element} with a 'value' attribute of '{$value}'. We also looked \"",
".",
"\"for a button that contains the text, '{$value}', but no dice either.\"",
")",
";",
"}",
"}",
"}"
] | Find an element by its "value" attribute.
@param string $value
@param string $element
@return \Session | [
"Find",
"an",
"element",
"by",
"its",
"value",
"attribute",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L151-L165 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.submitForm | public function submitForm($buttonText, $formData = [])
{
foreach ($formData as $name => $value) {
// Weird, but that's what you gotta do. :)
$value = ['value' => [$value]];
$element = $this->findByNameOrId($name);
$tag = $element->name();
if ($tag == 'input' && $element->attribute('type') == 'checkbox') {
$element->click();
} else {
$element->postValue($value);
}
}
$this->findByValue($buttonText)->submit();
$this->updateCurrentUrl();
return $this;
} | php | public function submitForm($buttonText, $formData = [])
{
foreach ($formData as $name => $value) {
// Weird, but that's what you gotta do. :)
$value = ['value' => [$value]];
$element = $this->findByNameOrId($name);
$tag = $element->name();
if ($tag == 'input' && $element->attribute('type') == 'checkbox') {
$element->click();
} else {
$element->postValue($value);
}
}
$this->findByValue($buttonText)->submit();
$this->updateCurrentUrl();
return $this;
} | [
"public",
"function",
"submitForm",
"(",
"$",
"buttonText",
",",
"$",
"formData",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"formData",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"// Weird, but that's what you gotta do. :)",
"$",
"value",
"=",
"[",
"'value'",
"=>",
"[",
"$",
"value",
"]",
"]",
";",
"$",
"element",
"=",
"$",
"this",
"->",
"findByNameOrId",
"(",
"$",
"name",
")",
";",
"$",
"tag",
"=",
"$",
"element",
"->",
"name",
"(",
")",
";",
"if",
"(",
"$",
"tag",
"==",
"'input'",
"&&",
"$",
"element",
"->",
"attribute",
"(",
"'type'",
")",
"==",
"'checkbox'",
")",
"{",
"$",
"element",
"->",
"click",
"(",
")",
";",
"}",
"else",
"{",
"$",
"element",
"->",
"postValue",
"(",
"$",
"value",
")",
";",
"}",
"}",
"$",
"this",
"->",
"findByValue",
"(",
"$",
"buttonText",
")",
"->",
"submit",
"(",
")",
";",
"$",
"this",
"->",
"updateCurrentUrl",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Submit a form on the page.
@param string $buttonText
@param array $formData
@return static | [
"Submit",
"a",
"form",
"on",
"the",
"page",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L174-L195 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.type | public function type($text, $element)
{
$value = ['value' => [$text]];
$this->findByNameOrId($element, $text)->postValue($value);
return $this;
} | php | public function type($text, $element)
{
$value = ['value' => [$text]];
$this->findByNameOrId($element, $text)->postValue($value);
return $this;
} | [
"public",
"function",
"type",
"(",
"$",
"text",
",",
"$",
"element",
")",
"{",
"$",
"value",
"=",
"[",
"'value'",
"=>",
"[",
"$",
"text",
"]",
"]",
";",
"$",
"this",
"->",
"findByNameOrId",
"(",
"$",
"element",
",",
"$",
"text",
")",
"->",
"postValue",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Fill in an input with the given text.
@param string $text
@param string $element
@return static | [
"Fill",
"in",
"an",
"input",
"with",
"the",
"given",
"text",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L204-L210 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.attachFile | public function attachFile($element, $absolutePath)
{
$path = ['value' => [$absolutePath]];
$this->findByNameOrId($element)->postValue($path);
return $this;
} | php | public function attachFile($element, $absolutePath)
{
$path = ['value' => [$absolutePath]];
$this->findByNameOrId($element)->postValue($path);
return $this;
} | [
"public",
"function",
"attachFile",
"(",
"$",
"element",
",",
"$",
"absolutePath",
")",
"{",
"$",
"path",
"=",
"[",
"'value'",
"=>",
"[",
"$",
"absolutePath",
"]",
"]",
";",
"$",
"this",
"->",
"findByNameOrId",
"(",
"$",
"element",
")",
"->",
"postValue",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Attach a file to a form.
@param string $element
@param string $absolutePath
@return static | [
"Attach",
"a",
"file",
"to",
"a",
"form",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L257-L264 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.seeInAlert | public function seeInAlert($text, $accept = true)
{
try {
$alert = $this->session->alert_text();
} catch (\WebDriver\Exception\NoAlertOpenError $e) {
throw new PHPUnitException(
"Could not see '{$text}' because no alert box was shown."
);
} catch (\WebDriver\Exception\UnknownError $e) {
// This would only apply to the PhantomJS driver.
// It seems to have issues with alerts, so I'm
// not sure what we can do about that...
return $this;
}
$this->assertContains($text, $alert);
if ($accept) {
$this->acceptAlert();
}
return $this;
} | php | public function seeInAlert($text, $accept = true)
{
try {
$alert = $this->session->alert_text();
} catch (\WebDriver\Exception\NoAlertOpenError $e) {
throw new PHPUnitException(
"Could not see '{$text}' because no alert box was shown."
);
} catch (\WebDriver\Exception\UnknownError $e) {
// This would only apply to the PhantomJS driver.
// It seems to have issues with alerts, so I'm
// not sure what we can do about that...
return $this;
}
$this->assertContains($text, $alert);
if ($accept) {
$this->acceptAlert();
}
return $this;
} | [
"public",
"function",
"seeInAlert",
"(",
"$",
"text",
",",
"$",
"accept",
"=",
"true",
")",
"{",
"try",
"{",
"$",
"alert",
"=",
"$",
"this",
"->",
"session",
"->",
"alert_text",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"WebDriver",
"\\",
"Exception",
"\\",
"NoAlertOpenError",
"$",
"e",
")",
"{",
"throw",
"new",
"PHPUnitException",
"(",
"\"Could not see '{$text}' because no alert box was shown.\"",
")",
";",
"}",
"catch",
"(",
"\\",
"WebDriver",
"\\",
"Exception",
"\\",
"UnknownError",
"$",
"e",
")",
"{",
"// This would only apply to the PhantomJS driver.",
"// It seems to have issues with alerts, so I'm",
"// not sure what we can do about that...",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"assertContains",
"(",
"$",
"text",
",",
"$",
"alert",
")",
";",
"if",
"(",
"$",
"accept",
")",
"{",
"$",
"this",
"->",
"acceptAlert",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Assert that an alert box is displayed, and contains the given text.
@param string $text
@param boolean $accept
@return | [
"Assert",
"that",
"an",
"alert",
"box",
"is",
"displayed",
"and",
"contains",
"the",
"given",
"text",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L284-L306 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.acceptAlert | public function acceptAlert()
{
try {
$this->session->accept_alert();
} catch (\WebDriver\Exception\NoAlertOpenError $e) {
throw new PHPUnitException(
"Well, tried to accept the alert, but there wasn't one. Dangit."
);
}
return $this;
} | php | public function acceptAlert()
{
try {
$this->session->accept_alert();
} catch (\WebDriver\Exception\NoAlertOpenError $e) {
throw new PHPUnitException(
"Well, tried to accept the alert, but there wasn't one. Dangit."
);
}
return $this;
} | [
"public",
"function",
"acceptAlert",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"session",
"->",
"accept_alert",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"WebDriver",
"\\",
"Exception",
"\\",
"NoAlertOpenError",
"$",
"e",
")",
"{",
"throw",
"new",
"PHPUnitException",
"(",
"\"Well, tried to accept the alert, but there wasn't one. Dangit.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Accept an alert.
@return static | [
"Accept",
"an",
"alert",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L313-L324 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.snap | public function snap($destination = null)
{
$destination = $destination ?: './tests/logs/screenshot.png';
$this->files()->put(
$destination,
base64_decode($this->session->screenshot())
);
return $this;
} | php | public function snap($destination = null)
{
$destination = $destination ?: './tests/logs/screenshot.png';
$this->files()->put(
$destination,
base64_decode($this->session->screenshot())
);
return $this;
} | [
"public",
"function",
"snap",
"(",
"$",
"destination",
"=",
"null",
")",
"{",
"$",
"destination",
"=",
"$",
"destination",
"?",
":",
"'./tests/logs/screenshot.png'",
";",
"$",
"this",
"->",
"files",
"(",
")",
"->",
"put",
"(",
"$",
"destination",
",",
"base64_decode",
"(",
"$",
"this",
"->",
"session",
"->",
"screenshot",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Take a snapshot of the current page.
@param string|null $destination
@return static | [
"Take",
"a",
"snapshot",
"of",
"the",
"current",
"page",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L332-L342 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.waitForElement | public function waitForElement($element, $timeout = 5000)
{
$this->session->timeouts()->postImplicit_wait(['ms' => $timeout]);
try {
$this->findByNameOrId($element);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(
"Hey, what's happening... Look, I waited {$timeout} milliseconds to see an element with " .
"a name or id of '{$element}', but no luck. \nIf you could take a look, that'd be greaaattt..."
);
}
return $this;
} | php | public function waitForElement($element, $timeout = 5000)
{
$this->session->timeouts()->postImplicit_wait(['ms' => $timeout]);
try {
$this->findByNameOrId($element);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(
"Hey, what's happening... Look, I waited {$timeout} milliseconds to see an element with " .
"a name or id of '{$element}', but no luck. \nIf you could take a look, that'd be greaaattt..."
);
}
return $this;
} | [
"public",
"function",
"waitForElement",
"(",
"$",
"element",
",",
"$",
"timeout",
"=",
"5000",
")",
"{",
"$",
"this",
"->",
"session",
"->",
"timeouts",
"(",
")",
"->",
"postImplicit_wait",
"(",
"[",
"'ms'",
"=>",
"$",
"timeout",
"]",
")",
";",
"try",
"{",
"$",
"this",
"->",
"findByNameOrId",
"(",
"$",
"element",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Hey, what's happening... Look, I waited {$timeout} milliseconds to see an element with \"",
".",
"\"a name or id of '{$element}', but no luck. \\nIf you could take a look, that'd be greaaattt...\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Continuously poll the page, until you find an element
with the given name or id.
@param string $element
@param integer $timeout
@return static | [
"Continuously",
"poll",
"the",
"page",
"until",
"you",
"find",
"an",
"element",
"with",
"the",
"given",
"name",
"or",
"id",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L430-L444 |
laracasts/Integrated | src/Extensions/Selenium.php | Selenium.newSession | protected function newSession()
{
$config = $this->getPackageConfig();
$host = isset($config['selenium']['host']) ? $config['selenium']['host'] : 'http://localhost:4444/wd/hub';
$this->webDriver = new WebDriver($host);
$capabilities = [];
return $this->session = $this->webDriver->session($this->getBrowserName(), $capabilities);
} | php | protected function newSession()
{
$config = $this->getPackageConfig();
$host = isset($config['selenium']['host']) ? $config['selenium']['host'] : 'http://localhost:4444/wd/hub';
$this->webDriver = new WebDriver($host);
$capabilities = [];
return $this->session = $this->webDriver->session($this->getBrowserName(), $capabilities);
} | [
"protected",
"function",
"newSession",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getPackageConfig",
"(",
")",
";",
"$",
"host",
"=",
"isset",
"(",
"$",
"config",
"[",
"'selenium'",
"]",
"[",
"'host'",
"]",
")",
"?",
"$",
"config",
"[",
"'selenium'",
"]",
"[",
"'host'",
"]",
":",
"'http://localhost:4444/wd/hub'",
";",
"$",
"this",
"->",
"webDriver",
"=",
"new",
"WebDriver",
"(",
"$",
"host",
")",
";",
"$",
"capabilities",
"=",
"[",
"]",
";",
"return",
"$",
"this",
"->",
"session",
"=",
"$",
"this",
"->",
"webDriver",
"->",
"session",
"(",
"$",
"this",
"->",
"getBrowserName",
"(",
")",
",",
"$",
"capabilities",
")",
";",
"}"
] | Create a new WebDriver session.
@param string $browser
@return Session | [
"Create",
"a",
"new",
"WebDriver",
"session",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Selenium.php#L452-L462 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.get | protected function get($uri, array $params = [])
{
$this->call('GET', $uri, $params, [], $this->cookies, $this->headers);
return $this;
} | php | protected function get($uri, array $params = [])
{
$this->call('GET', $uri, $params, [], $this->cookies, $this->headers);
return $this;
} | [
"protected",
"function",
"get",
"(",
"$",
"uri",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'GET'",
",",
"$",
"uri",
",",
"$",
"params",
",",
"[",
"]",
",",
"$",
"this",
"->",
"cookies",
",",
"$",
"this",
"->",
"headers",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Make a GET request to an API endpoint.
@param string $uri
@param array $params
@return static | [
"Make",
"a",
"GET",
"request",
"to",
"an",
"API",
"endpoint",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L31-L36 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.post | protected function post($uri, array $data)
{
$this->call('POST', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | php | protected function post($uri, array $data)
{
$this->call('POST', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | [
"protected",
"function",
"post",
"(",
"$",
"uri",
",",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'POST'",
",",
"$",
"uri",
",",
"$",
"data",
",",
"$",
"this",
"->",
"cookies",
",",
"[",
"]",
",",
"$",
"this",
"->",
"headers",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Make a POST request to an API endpoint.
@param string $uri
@param array $data
@return static | [
"Make",
"a",
"POST",
"request",
"to",
"an",
"API",
"endpoint",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L56-L61 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.put | protected function put($uri, array $data)
{
$this->call('PUT', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | php | protected function put($uri, array $data)
{
$this->call('PUT', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | [
"protected",
"function",
"put",
"(",
"$",
"uri",
",",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'PUT'",
",",
"$",
"uri",
",",
"$",
"data",
",",
"$",
"this",
"->",
"cookies",
",",
"[",
"]",
",",
"$",
"this",
"->",
"headers",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Make a PUT request to an API endpoint.
@param string $uri
@param array $data
@return static | [
"Make",
"a",
"PUT",
"request",
"to",
"an",
"API",
"endpoint",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L70-L75 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.patch | protected function patch($uri, array $data)
{
$this->call('PATCH', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | php | protected function patch($uri, array $data)
{
$this->call('PATCH', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | [
"protected",
"function",
"patch",
"(",
"$",
"uri",
",",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'PATCH'",
",",
"$",
"uri",
",",
"$",
"data",
",",
"$",
"this",
"->",
"cookies",
",",
"[",
"]",
",",
"$",
"this",
"->",
"headers",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Make a PATCH request to an API endpoint.
@param string $uri
@param array $data
@return static | [
"Make",
"a",
"PATCH",
"request",
"to",
"an",
"API",
"endpoint",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L84-L89 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.delete | protected function delete($uri, array $data = [])
{
$this->call('DELETE', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | php | protected function delete($uri, array $data = [])
{
$this->call('DELETE', $uri, $data, $this->cookies, [], $this->headers);
return $this;
} | [
"protected",
"function",
"delete",
"(",
"$",
"uri",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'DELETE'",
",",
"$",
"uri",
",",
"$",
"data",
",",
"$",
"this",
"->",
"cookies",
",",
"[",
"]",
",",
"$",
"this",
"->",
"headers",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Make a DELETE request to an API endpoint.
@param string $uri
@param array $data
@return static | [
"Make",
"a",
"DELETE",
"request",
"to",
"an",
"API",
"endpoint",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L98-L103 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.seeJsonEquals | protected function seeJsonEquals($expected)
{
if (is_array($expected)) {
$expected = json_encode($expected);
}
$this->assertJsonStringEqualsJsonString($expected, $this->response());
return $this;
} | php | protected function seeJsonEquals($expected)
{
if (is_array($expected)) {
$expected = json_encode($expected);
}
$this->assertJsonStringEqualsJsonString($expected, $this->response());
return $this;
} | [
"protected",
"function",
"seeJsonEquals",
"(",
"$",
"expected",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"expected",
")",
")",
"{",
"$",
"expected",
"=",
"json_encode",
"(",
"$",
"expected",
")",
";",
"}",
"$",
"this",
"->",
"assertJsonStringEqualsJsonString",
"(",
"$",
"expected",
",",
"$",
"this",
"->",
"response",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Assert that an API response equals the provided array
or json-encoded array.
@param array|string $expected
@return static | [
"Assert",
"that",
"an",
"API",
"response",
"equals",
"the",
"provided",
"array",
"or",
"json",
"-",
"encoded",
"array",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L160-L169 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.seeJsonContains | protected function seeJsonContains($expected)
{
$response = json_decode($this->response(), true);
$this->sortJson($expected);
$this->sortJson($response);
foreach ($expected as $key => $value) {
if ( ! str_contains(json_encode($response), trim(json_encode([$key => $value]), '{}'))) {
$this->fail(sprintf(
"Dang! Expected %s to exist in %s, but nope. Ideas?",
json_encode($expected), json_encode($response)
));
}
}
return $this;
} | php | protected function seeJsonContains($expected)
{
$response = json_decode($this->response(), true);
$this->sortJson($expected);
$this->sortJson($response);
foreach ($expected as $key => $value) {
if ( ! str_contains(json_encode($response), trim(json_encode([$key => $value]), '{}'))) {
$this->fail(sprintf(
"Dang! Expected %s to exist in %s, but nope. Ideas?",
json_encode($expected), json_encode($response)
));
}
}
return $this;
} | [
"protected",
"function",
"seeJsonContains",
"(",
"$",
"expected",
")",
"{",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"response",
"(",
")",
",",
"true",
")",
";",
"$",
"this",
"->",
"sortJson",
"(",
"$",
"expected",
")",
";",
"$",
"this",
"->",
"sortJson",
"(",
"$",
"response",
")",
";",
"foreach",
"(",
"$",
"expected",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"str_contains",
"(",
"json_encode",
"(",
"$",
"response",
")",
",",
"trim",
"(",
"json_encode",
"(",
"[",
"$",
"key",
"=>",
"$",
"value",
"]",
")",
",",
"'{}'",
")",
")",
")",
"{",
"$",
"this",
"->",
"fail",
"(",
"sprintf",
"(",
"\"Dang! Expected %s to exist in %s, but nope. Ideas?\"",
",",
"json_encode",
"(",
"$",
"expected",
")",
",",
"json_encode",
"(",
"$",
"response",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Assert that an API response matches the provided array.
@param array $expected
@return static | [
"Assert",
"that",
"an",
"API",
"response",
"matches",
"the",
"provided",
"array",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L177-L194 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.sortJson | protected function sortJson(&$array)
{
foreach ($array as &$value) {
if (is_array($value) && isset($value[0])) {
sort($value);
} elseif (is_array($value)) {
$this->sortJson($value);
}
}
return ksort($array);
} | php | protected function sortJson(&$array)
{
foreach ($array as &$value) {
if (is_array($value) && isset($value[0])) {
sort($value);
} elseif (is_array($value)) {
$this->sortJson($value);
}
}
return ksort($array);
} | [
"protected",
"function",
"sortJson",
"(",
"&",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"isset",
"(",
"$",
"value",
"[",
"0",
"]",
")",
")",
"{",
"sort",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"sortJson",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"ksort",
"(",
"$",
"array",
")",
";",
"}"
] | Sort a JSON response, for easy assertions and comparisons.
@param array &$array
@return array | [
"Sort",
"a",
"JSON",
"response",
"for",
"easy",
"assertions",
"and",
"comparisons",
"."
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L202-L213 |
laracasts/Integrated | src/Extensions/Traits/ApiRequests.php | ApiRequests.withHeaders | protected function withHeaders(array $headers)
{
$clean = [];
foreach ($headers as $key => $value) {
if (! Str::startsWith($key, ['HTTP_', 'CONTENT_'])) {
$key = 'HTTP_' . $key;
}
$clean[$key] = $value;
}
$this->headers = array_merge($this->headers, $clean);
return $this;
} | php | protected function withHeaders(array $headers)
{
$clean = [];
foreach ($headers as $key => $value) {
if (! Str::startsWith($key, ['HTTP_', 'CONTENT_'])) {
$key = 'HTTP_' . $key;
}
$clean[$key] = $value;
}
$this->headers = array_merge($this->headers, $clean);
return $this;
} | [
"protected",
"function",
"withHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"clean",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"Str",
"::",
"startsWith",
"(",
"$",
"key",
",",
"[",
"'HTTP_'",
",",
"'CONTENT_'",
"]",
")",
")",
"{",
"$",
"key",
"=",
"'HTTP_'",
".",
"$",
"key",
";",
"}",
"$",
"clean",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"headers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"clean",
")",
";",
"return",
"$",
"this",
";",
"}"
] | An array of headers to pass along with the request
@param array $headers
@return $this | [
"An",
"array",
"of",
"headers",
"to",
"pass",
"along",
"with",
"the",
"request"
] | train | https://github.com/laracasts/Integrated/blob/4c2dbbcd6343cdcd772e493d44b9dc4d794553a8/src/Extensions/Traits/ApiRequests.php#L221-L236 |
ongr-io/ElasticsearchBundle | DependencyInjection/ONGRElasticsearchExtension.php | ONGRElasticsearchExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
if (Kernel::MAJOR_VERSION >= 4) {
$loader->load('services4.yaml');
}
$config['cache'] = isset($config['cache']) ?
$config['cache'] : !$container->getParameter('kernel.debug');
$config['profiler'] = isset($config['profiler']) ?
$config['profiler'] : $container->getParameter('kernel.debug');
$container->setParameter('es.cache', $config['cache']);
$container->setParameter('es.analysis', $config['analysis']);
$container->setParameter('es.managers', $config['managers']);
$definition = new Definition(
'ONGR\ElasticsearchBundle\Service\ManagerFactory',
[
new Reference('es.metadata_collector'),
new Reference('es.result_converter'),
$config['profiler'] ? new Reference('es.tracer') : null,
]
);
$definition->addMethodCall('setEventDispatcher', [new Reference('event_dispatcher')]);
$definition->addMethodCall(
'setStopwatch',
[
new Reference('debug.stopwatch', ContainerInterface::NULL_ON_INVALID_REFERENCE)
]
);
$definition->setPublic(true);
$container->setDefinition('es.manager_factory', $definition);
} | php | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
if (Kernel::MAJOR_VERSION >= 4) {
$loader->load('services4.yaml');
}
$config['cache'] = isset($config['cache']) ?
$config['cache'] : !$container->getParameter('kernel.debug');
$config['profiler'] = isset($config['profiler']) ?
$config['profiler'] : $container->getParameter('kernel.debug');
$container->setParameter('es.cache', $config['cache']);
$container->setParameter('es.analysis', $config['analysis']);
$container->setParameter('es.managers', $config['managers']);
$definition = new Definition(
'ONGR\ElasticsearchBundle\Service\ManagerFactory',
[
new Reference('es.metadata_collector'),
new Reference('es.result_converter'),
$config['profiler'] ? new Reference('es.tracer') : null,
]
);
$definition->addMethodCall('setEventDispatcher', [new Reference('event_dispatcher')]);
$definition->addMethodCall(
'setStopwatch',
[
new Reference('debug.stopwatch', ContainerInterface::NULL_ON_INVALID_REFERENCE)
]
);
$definition->setPublic(true);
$container->setDefinition('es.manager_factory', $definition);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"configuration",
",",
"$",
"configs",
")",
";",
"$",
"loader",
"=",
"new",
"Loader",
"\\",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.yml'",
")",
";",
"if",
"(",
"Kernel",
"::",
"MAJOR_VERSION",
">=",
"4",
")",
"{",
"$",
"loader",
"->",
"load",
"(",
"'services4.yaml'",
")",
";",
"}",
"$",
"config",
"[",
"'cache'",
"]",
"=",
"isset",
"(",
"$",
"config",
"[",
"'cache'",
"]",
")",
"?",
"$",
"config",
"[",
"'cache'",
"]",
":",
"!",
"$",
"container",
"->",
"getParameter",
"(",
"'kernel.debug'",
")",
";",
"$",
"config",
"[",
"'profiler'",
"]",
"=",
"isset",
"(",
"$",
"config",
"[",
"'profiler'",
"]",
")",
"?",
"$",
"config",
"[",
"'profiler'",
"]",
":",
"$",
"container",
"->",
"getParameter",
"(",
"'kernel.debug'",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'es.cache'",
",",
"$",
"config",
"[",
"'cache'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'es.analysis'",
",",
"$",
"config",
"[",
"'analysis'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'es.managers'",
",",
"$",
"config",
"[",
"'managers'",
"]",
")",
";",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"'ONGR\\ElasticsearchBundle\\Service\\ManagerFactory'",
",",
"[",
"new",
"Reference",
"(",
"'es.metadata_collector'",
")",
",",
"new",
"Reference",
"(",
"'es.result_converter'",
")",
",",
"$",
"config",
"[",
"'profiler'",
"]",
"?",
"new",
"Reference",
"(",
"'es.tracer'",
")",
":",
"null",
",",
"]",
")",
";",
"$",
"definition",
"->",
"addMethodCall",
"(",
"'setEventDispatcher'",
",",
"[",
"new",
"Reference",
"(",
"'event_dispatcher'",
")",
"]",
")",
";",
"$",
"definition",
"->",
"addMethodCall",
"(",
"'setStopwatch'",
",",
"[",
"new",
"Reference",
"(",
"'debug.stopwatch'",
",",
"ContainerInterface",
"::",
"NULL_ON_INVALID_REFERENCE",
")",
"]",
")",
";",
"$",
"definition",
"->",
"setPublic",
"(",
"true",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"'es.manager_factory'",
",",
"$",
"definition",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/DependencyInjection/ONGRElasticsearchExtension.php#L32-L69 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.getRepository | public function getRepository($className)
{
if (!is_string($className)) {
throw new \InvalidArgumentException('Document class must be a string.');
}
$directory = null;
if (strpos($className, ':')) {
$bundle = explode(':', $className)[0];
if (isset($this->config['mappings'][$bundle]['document_dir'])) {
$directory = $this->config['mappings'][$bundle]['document_dir'];
}
}
$namespace = $this->getMetadataCollector()->getClassName($className, $directory);
if (isset($this->repositories[$namespace])) {
return $this->repositories[$namespace];
}
$repository = $this->createRepository($namespace);
$this->repositories[$namespace] = $repository;
return $repository;
} | php | public function getRepository($className)
{
if (!is_string($className)) {
throw new \InvalidArgumentException('Document class must be a string.');
}
$directory = null;
if (strpos($className, ':')) {
$bundle = explode(':', $className)[0];
if (isset($this->config['mappings'][$bundle]['document_dir'])) {
$directory = $this->config['mappings'][$bundle]['document_dir'];
}
}
$namespace = $this->getMetadataCollector()->getClassName($className, $directory);
if (isset($this->repositories[$namespace])) {
return $this->repositories[$namespace];
}
$repository = $this->createRepository($namespace);
$this->repositories[$namespace] = $repository;
return $repository;
} | [
"public",
"function",
"getRepository",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Document class must be a string.'",
")",
";",
"}",
"$",
"directory",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"className",
",",
"':'",
")",
")",
"{",
"$",
"bundle",
"=",
"explode",
"(",
"':'",
",",
"$",
"className",
")",
"[",
"0",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'mappings'",
"]",
"[",
"$",
"bundle",
"]",
"[",
"'document_dir'",
"]",
")",
")",
"{",
"$",
"directory",
"=",
"$",
"this",
"->",
"config",
"[",
"'mappings'",
"]",
"[",
"$",
"bundle",
"]",
"[",
"'document_dir'",
"]",
";",
"}",
"}",
"$",
"namespace",
"=",
"$",
"this",
"->",
"getMetadataCollector",
"(",
")",
"->",
"getClassName",
"(",
"$",
"className",
",",
"$",
"directory",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"repositories",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"repositories",
"[",
"$",
"namespace",
"]",
";",
"}",
"$",
"repository",
"=",
"$",
"this",
"->",
"createRepository",
"(",
"$",
"namespace",
")",
";",
"$",
"this",
"->",
"repositories",
"[",
"$",
"namespace",
"]",
"=",
"$",
"repository",
";",
"return",
"$",
"repository",
";",
"}"
] | Returns repository by document class.
@param string $className FQCN or string in Bundle:Document format
@return Repository | [
"Returns",
"repository",
"by",
"document",
"class",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L180-L206 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.search | public function search(array $types, array $query, array $queryStringParams = [])
{
$params = [];
$params['index'] = $this->getIndexName();
$resolvedTypes = [];
foreach ($types as $type) {
$resolvedTypes[] = $this->resolveTypeName($type);
}
if (!empty($resolvedTypes)) {
$params['type'] = implode(',', $resolvedTypes);
}
$params['body'] = $query;
if (!empty($queryStringParams)) {
$params = array_merge($queryStringParams, $params);
}
$this->stopwatch('start', 'search');
$result = $this->client->search($params);
$this->stopwatch('stop', 'search');
return $result;
} | php | public function search(array $types, array $query, array $queryStringParams = [])
{
$params = [];
$params['index'] = $this->getIndexName();
$resolvedTypes = [];
foreach ($types as $type) {
$resolvedTypes[] = $this->resolveTypeName($type);
}
if (!empty($resolvedTypes)) {
$params['type'] = implode(',', $resolvedTypes);
}
$params['body'] = $query;
if (!empty($queryStringParams)) {
$params = array_merge($queryStringParams, $params);
}
$this->stopwatch('start', 'search');
$result = $this->client->search($params);
$this->stopwatch('stop', 'search');
return $result;
} | [
"public",
"function",
"search",
"(",
"array",
"$",
"types",
",",
"array",
"$",
"query",
",",
"array",
"$",
"queryStringParams",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"params",
"[",
"'index'",
"]",
"=",
"$",
"this",
"->",
"getIndexName",
"(",
")",
";",
"$",
"resolvedTypes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"resolvedTypes",
"[",
"]",
"=",
"$",
"this",
"->",
"resolveTypeName",
"(",
"$",
"type",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"resolvedTypes",
")",
")",
"{",
"$",
"params",
"[",
"'type'",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"resolvedTypes",
")",
";",
"}",
"$",
"params",
"[",
"'body'",
"]",
"=",
"$",
"query",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryStringParams",
")",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"queryStringParams",
",",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"stopwatch",
"(",
"'start'",
",",
"'search'",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"search",
"(",
"$",
"params",
")",
";",
"$",
"this",
"->",
"stopwatch",
"(",
"'stop'",
",",
"'search'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Executes search query in the index.
@param array $types List of types to search in.
@param array $query Query to execute.
@param array $queryStringParams Query parameters.
@return array | [
"Executes",
"search",
"query",
"in",
"the",
"index",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L281-L306 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.msearch | public function msearch(array $body)
{
$result = $this->client->msearch(
[
'index' => $this->getIndexName(), // set default index
'body' => $body
]
);
return $result;
} | php | public function msearch(array $body)
{
$result = $this->client->msearch(
[
'index' => $this->getIndexName(), // set default index
'body' => $body
]
);
return $result;
} | [
"public",
"function",
"msearch",
"(",
"array",
"$",
"body",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"msearch",
"(",
"[",
"'index'",
"=>",
"$",
"this",
"->",
"getIndexName",
"(",
")",
",",
"// set default index",
"'body'",
"=>",
"$",
"body",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Execute search queries using multisearch api
$body - is array of requests described in elastic Multi Search API
@param $body
@return array | [
"Execute",
"search",
"queries",
"using",
"multisearch",
"api",
"$body",
"-",
"is",
"array",
"of",
"requests",
"described",
"in",
"elastic",
"Multi",
"Search",
"API"
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L315-L324 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.persist | public function persist($document)
{
$documentArray = $this->converter->convertToArray($document);
$type = $this->getMetadataCollector()->getDocumentType(get_class($document));
$this->bulk('index', $type, $documentArray);
} | php | public function persist($document)
{
$documentArray = $this->converter->convertToArray($document);
$type = $this->getMetadataCollector()->getDocumentType(get_class($document));
$this->bulk('index', $type, $documentArray);
} | [
"public",
"function",
"persist",
"(",
"$",
"document",
")",
"{",
"$",
"documentArray",
"=",
"$",
"this",
"->",
"converter",
"->",
"convertToArray",
"(",
"$",
"document",
")",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"getMetadataCollector",
"(",
")",
"->",
"getDocumentType",
"(",
"get_class",
"(",
"$",
"document",
")",
")",
";",
"$",
"this",
"->",
"bulk",
"(",
"'index'",
",",
"$",
"type",
",",
"$",
"documentArray",
")",
";",
"}"
] | Adds document to next flush.
@param object $document | [
"Adds",
"document",
"to",
"next",
"flush",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L331-L337 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.remove | public function remove($document)
{
$data = $this->converter->convertToArray($document, [], ['_id', '_routing']);
if (!isset($data['_id'])) {
throw new \LogicException(
'In order to use remove() method document class must have property with @Id annotation.'
);
}
$type = $this->getMetadataCollector()->getDocumentType(get_class($document));
$this->bulk('delete', $type, $data);
} | php | public function remove($document)
{
$data = $this->converter->convertToArray($document, [], ['_id', '_routing']);
if (!isset($data['_id'])) {
throw new \LogicException(
'In order to use remove() method document class must have property with @Id annotation.'
);
}
$type = $this->getMetadataCollector()->getDocumentType(get_class($document));
$this->bulk('delete', $type, $data);
} | [
"public",
"function",
"remove",
"(",
"$",
"document",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"converter",
"->",
"convertToArray",
"(",
"$",
"document",
",",
"[",
"]",
",",
"[",
"'_id'",
",",
"'_routing'",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'_id'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'In order to use remove() method document class must have property with @Id annotation.'",
")",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"getMetadataCollector",
"(",
")",
"->",
"getDocumentType",
"(",
"get_class",
"(",
"$",
"document",
")",
")",
";",
"$",
"this",
"->",
"bulk",
"(",
"'delete'",
",",
"$",
"type",
",",
"$",
"data",
")",
";",
"}"
] | Adds document for removal.
@param object $document | [
"Adds",
"document",
"for",
"removal",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L344-L357 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.flush | public function flush(array $params = [])
{
return $this->client->indices()->flush(array_merge(['index' => $this->getIndexName()], $params));
} | php | public function flush(array $params = [])
{
return $this->client->indices()->flush(array_merge(['index' => $this->getIndexName()], $params));
} | [
"public",
"function",
"flush",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"indices",
"(",
")",
"->",
"flush",
"(",
"array_merge",
"(",
"[",
"'index'",
"=>",
"$",
"this",
"->",
"getIndexName",
"(",
")",
"]",
",",
"$",
"params",
")",
")",
";",
"}"
] | Flushes elasticsearch index.
@param array $params
@return array | [
"Flushes",
"elasticsearch",
"index",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L366-L369 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.refresh | public function refresh(array $params = [])
{
return $this->client->indices()->refresh(array_merge(['index' => $this->getIndexName()], $params));
} | php | public function refresh(array $params = [])
{
return $this->client->indices()->refresh(array_merge(['index' => $this->getIndexName()], $params));
} | [
"public",
"function",
"refresh",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"indices",
"(",
")",
"->",
"refresh",
"(",
"array_merge",
"(",
"[",
"'index'",
"=>",
"$",
"this",
"->",
"getIndexName",
"(",
")",
"]",
",",
"$",
"params",
")",
")",
";",
"}"
] | Refreshes elasticsearch index.
@param array $params
@return array | [
"Refreshes",
"elasticsearch",
"index",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L378-L381 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.commit | public function commit(array $params = [])
{
if (!empty($this->bulkQueries)) {
$bulkQueries = array_merge($this->bulkQueries, $this->bulkParams);
$bulkQueries['index']['_index'] = $this->getIndexName();
$this->eventDispatcher->dispatch(
Events::PRE_COMMIT,
new CommitEvent($this->getCommitMode(), $bulkQueries)
);
$this->stopwatch('start', 'bulk');
$bulkResponse = $this->client->bulk($bulkQueries);
$this->stopwatch('stop', 'bulk');
if ($bulkResponse['errors']) {
throw new BulkWithErrorsException(
json_encode($bulkResponse),
0,
null,
$bulkResponse
);
}
$this->bulkQueries = [];
$this->bulkCount = 0;
$this->stopwatch('start', 'refresh');
switch ($this->getCommitMode()) {
case 'flush':
$this->flush($params);
break;
case 'refresh':
$this->refresh($params);
break;
}
$this->eventDispatcher->dispatch(
Events::POST_COMMIT,
new CommitEvent($this->getCommitMode(), $bulkResponse)
);
$this->stopwatch('stop', 'refresh');
return $bulkResponse;
}
return null;
} | php | public function commit(array $params = [])
{
if (!empty($this->bulkQueries)) {
$bulkQueries = array_merge($this->bulkQueries, $this->bulkParams);
$bulkQueries['index']['_index'] = $this->getIndexName();
$this->eventDispatcher->dispatch(
Events::PRE_COMMIT,
new CommitEvent($this->getCommitMode(), $bulkQueries)
);
$this->stopwatch('start', 'bulk');
$bulkResponse = $this->client->bulk($bulkQueries);
$this->stopwatch('stop', 'bulk');
if ($bulkResponse['errors']) {
throw new BulkWithErrorsException(
json_encode($bulkResponse),
0,
null,
$bulkResponse
);
}
$this->bulkQueries = [];
$this->bulkCount = 0;
$this->stopwatch('start', 'refresh');
switch ($this->getCommitMode()) {
case 'flush':
$this->flush($params);
break;
case 'refresh':
$this->refresh($params);
break;
}
$this->eventDispatcher->dispatch(
Events::POST_COMMIT,
new CommitEvent($this->getCommitMode(), $bulkResponse)
);
$this->stopwatch('stop', 'refresh');
return $bulkResponse;
}
return null;
} | [
"public",
"function",
"commit",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"bulkQueries",
")",
")",
"{",
"$",
"bulkQueries",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"bulkQueries",
",",
"$",
"this",
"->",
"bulkParams",
")",
";",
"$",
"bulkQueries",
"[",
"'index'",
"]",
"[",
"'_index'",
"]",
"=",
"$",
"this",
"->",
"getIndexName",
"(",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"Events",
"::",
"PRE_COMMIT",
",",
"new",
"CommitEvent",
"(",
"$",
"this",
"->",
"getCommitMode",
"(",
")",
",",
"$",
"bulkQueries",
")",
")",
";",
"$",
"this",
"->",
"stopwatch",
"(",
"'start'",
",",
"'bulk'",
")",
";",
"$",
"bulkResponse",
"=",
"$",
"this",
"->",
"client",
"->",
"bulk",
"(",
"$",
"bulkQueries",
")",
";",
"$",
"this",
"->",
"stopwatch",
"(",
"'stop'",
",",
"'bulk'",
")",
";",
"if",
"(",
"$",
"bulkResponse",
"[",
"'errors'",
"]",
")",
"{",
"throw",
"new",
"BulkWithErrorsException",
"(",
"json_encode",
"(",
"$",
"bulkResponse",
")",
",",
"0",
",",
"null",
",",
"$",
"bulkResponse",
")",
";",
"}",
"$",
"this",
"->",
"bulkQueries",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"bulkCount",
"=",
"0",
";",
"$",
"this",
"->",
"stopwatch",
"(",
"'start'",
",",
"'refresh'",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"getCommitMode",
"(",
")",
")",
"{",
"case",
"'flush'",
":",
"$",
"this",
"->",
"flush",
"(",
"$",
"params",
")",
";",
"break",
";",
"case",
"'refresh'",
":",
"$",
"this",
"->",
"refresh",
"(",
"$",
"params",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"Events",
"::",
"POST_COMMIT",
",",
"new",
"CommitEvent",
"(",
"$",
"this",
"->",
"getCommitMode",
"(",
")",
",",
"$",
"bulkResponse",
")",
")",
";",
"$",
"this",
"->",
"stopwatch",
"(",
"'stop'",
",",
"'refresh'",
")",
";",
"return",
"$",
"bulkResponse",
";",
"}",
"return",
"null",
";",
"}"
] | Inserts the current query container to the index, used for bulk queries execution.
@param array $params Parameters that will be passed to the flush or refresh queries.
@return null|array
@throws BulkWithErrorsException | [
"Inserts",
"the",
"current",
"query",
"container",
"to",
"the",
"index",
"used",
"for",
"bulk",
"queries",
"execution",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L392-L440 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.bulk | public function bulk($operation, $type, array $query)
{
if (!in_array($operation, ['index', 'create', 'update', 'delete'])) {
throw new \InvalidArgumentException('Wrong bulk operation selected');
}
$this->eventDispatcher->dispatch(
Events::BULK,
new BulkEvent($operation, $type, $query)
);
$this->bulkQueries['body'][] = [
$operation => array_filter(
[
'_type' => $type,
'_id' => isset($query['_id']) ? $query['_id'] : null,
'_ttl' => isset($query['_ttl']) ? $query['_ttl'] : null,
'_routing' => isset($query['_routing']) ? $query['_routing'] : null,
'_parent' => isset($query['_parent']) ? $query['_parent'] : null,
]
),
];
unset($query['_id'], $query['_ttl'], $query['_parent'], $query['_routing']);
switch ($operation) {
case 'index':
case 'create':
case 'update':
$this->bulkQueries['body'][] = $query;
break;
case 'delete':
// Body for delete operation is not needed to apply.
default:
// Do nothing.
break;
}
// We are using counter because there is to difficult to resolve this from bulkQueries array.
$this->bulkCount++;
$response = null;
if ($this->bulkCommitSize === $this->bulkCount) {
$response = $this->commit();
}
return $response;
} | php | public function bulk($operation, $type, array $query)
{
if (!in_array($operation, ['index', 'create', 'update', 'delete'])) {
throw new \InvalidArgumentException('Wrong bulk operation selected');
}
$this->eventDispatcher->dispatch(
Events::BULK,
new BulkEvent($operation, $type, $query)
);
$this->bulkQueries['body'][] = [
$operation => array_filter(
[
'_type' => $type,
'_id' => isset($query['_id']) ? $query['_id'] : null,
'_ttl' => isset($query['_ttl']) ? $query['_ttl'] : null,
'_routing' => isset($query['_routing']) ? $query['_routing'] : null,
'_parent' => isset($query['_parent']) ? $query['_parent'] : null,
]
),
];
unset($query['_id'], $query['_ttl'], $query['_parent'], $query['_routing']);
switch ($operation) {
case 'index':
case 'create':
case 'update':
$this->bulkQueries['body'][] = $query;
break;
case 'delete':
// Body for delete operation is not needed to apply.
default:
// Do nothing.
break;
}
// We are using counter because there is to difficult to resolve this from bulkQueries array.
$this->bulkCount++;
$response = null;
if ($this->bulkCommitSize === $this->bulkCount) {
$response = $this->commit();
}
return $response;
} | [
"public",
"function",
"bulk",
"(",
"$",
"operation",
",",
"$",
"type",
",",
"array",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"operation",
",",
"[",
"'index'",
",",
"'create'",
",",
"'update'",
",",
"'delete'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Wrong bulk operation selected'",
")",
";",
"}",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"Events",
"::",
"BULK",
",",
"new",
"BulkEvent",
"(",
"$",
"operation",
",",
"$",
"type",
",",
"$",
"query",
")",
")",
";",
"$",
"this",
"->",
"bulkQueries",
"[",
"'body'",
"]",
"[",
"]",
"=",
"[",
"$",
"operation",
"=>",
"array_filter",
"(",
"[",
"'_type'",
"=>",
"$",
"type",
",",
"'_id'",
"=>",
"isset",
"(",
"$",
"query",
"[",
"'_id'",
"]",
")",
"?",
"$",
"query",
"[",
"'_id'",
"]",
":",
"null",
",",
"'_ttl'",
"=>",
"isset",
"(",
"$",
"query",
"[",
"'_ttl'",
"]",
")",
"?",
"$",
"query",
"[",
"'_ttl'",
"]",
":",
"null",
",",
"'_routing'",
"=>",
"isset",
"(",
"$",
"query",
"[",
"'_routing'",
"]",
")",
"?",
"$",
"query",
"[",
"'_routing'",
"]",
":",
"null",
",",
"'_parent'",
"=>",
"isset",
"(",
"$",
"query",
"[",
"'_parent'",
"]",
")",
"?",
"$",
"query",
"[",
"'_parent'",
"]",
":",
"null",
",",
"]",
")",
",",
"]",
";",
"unset",
"(",
"$",
"query",
"[",
"'_id'",
"]",
",",
"$",
"query",
"[",
"'_ttl'",
"]",
",",
"$",
"query",
"[",
"'_parent'",
"]",
",",
"$",
"query",
"[",
"'_routing'",
"]",
")",
";",
"switch",
"(",
"$",
"operation",
")",
"{",
"case",
"'index'",
":",
"case",
"'create'",
":",
"case",
"'update'",
":",
"$",
"this",
"->",
"bulkQueries",
"[",
"'body'",
"]",
"[",
"]",
"=",
"$",
"query",
";",
"break",
";",
"case",
"'delete'",
":",
"// Body for delete operation is not needed to apply.",
"default",
":",
"// Do nothing.",
"break",
";",
"}",
"// We are using counter because there is to difficult to resolve this from bulkQueries array.",
"$",
"this",
"->",
"bulkCount",
"++",
";",
"$",
"response",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"bulkCommitSize",
"===",
"$",
"this",
"->",
"bulkCount",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"commit",
"(",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Adds query to bulk queries container.
@param string $operation One of: index, update, delete, create.
@param string|array $type Elasticsearch type name.
@param array $query DSL to execute.
@throws \InvalidArgumentException
@return null|array | [
"Adds",
"query",
"to",
"bulk",
"queries",
"container",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L453-L500 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.createIndex | public function createIndex($noMapping = false)
{
if ($noMapping) {
unset($this->indexSettings['body']['mappings']);
}
return $this->getClient()->indices()->create($this->indexSettings);
} | php | public function createIndex($noMapping = false)
{
if ($noMapping) {
unset($this->indexSettings['body']['mappings']);
}
return $this->getClient()->indices()->create($this->indexSettings);
} | [
"public",
"function",
"createIndex",
"(",
"$",
"noMapping",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"noMapping",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"indexSettings",
"[",
"'body'",
"]",
"[",
"'mappings'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"indices",
"(",
")",
"->",
"create",
"(",
"$",
"this",
"->",
"indexSettings",
")",
";",
"}"
] | Creates fresh elasticsearch index.
@param bool $noMapping Determines if mapping should be included.
@return array | [
"Creates",
"fresh",
"elasticsearch",
"index",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L522-L529 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.dropAndCreateIndex | public function dropAndCreateIndex($noMapping = false)
{
try {
if ($this->indexExists()) {
$this->dropIndex();
}
} catch (\Exception $e) {
// Do nothing, our target is to create new index.
}
return $this->createIndex($noMapping);
} | php | public function dropAndCreateIndex($noMapping = false)
{
try {
if ($this->indexExists()) {
$this->dropIndex();
}
} catch (\Exception $e) {
// Do nothing, our target is to create new index.
}
return $this->createIndex($noMapping);
} | [
"public",
"function",
"dropAndCreateIndex",
"(",
"$",
"noMapping",
"=",
"false",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"indexExists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"dropIndex",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Do nothing, our target is to create new index.",
"}",
"return",
"$",
"this",
"->",
"createIndex",
"(",
"$",
"noMapping",
")",
";",
"}"
] | Tries to drop and create fresh elasticsearch index.
@param bool $noMapping Determines if mapping should be included.
@return array | [
"Tries",
"to",
"drop",
"and",
"create",
"fresh",
"elasticsearch",
"index",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L546-L557 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.find | public function find($className, $id, $routing = null)
{
$type = $this->resolveTypeName($className);
$params = [
'index' => $this->getIndexName(),
'type' => $type,
'id' => $id,
];
if ($routing) {
$params['routing'] = $routing;
}
try {
$result = $this->getClient()->get($params);
} catch (Missing404Exception $e) {
return null;
}
return $this->getConverter()->convertToDocument($result, $this);
} | php | public function find($className, $id, $routing = null)
{
$type = $this->resolveTypeName($className);
$params = [
'index' => $this->getIndexName(),
'type' => $type,
'id' => $id,
];
if ($routing) {
$params['routing'] = $routing;
}
try {
$result = $this->getClient()->get($params);
} catch (Missing404Exception $e) {
return null;
}
return $this->getConverter()->convertToDocument($result, $this);
} | [
"public",
"function",
"find",
"(",
"$",
"className",
",",
"$",
"id",
",",
"$",
"routing",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"resolveTypeName",
"(",
"$",
"className",
")",
";",
"$",
"params",
"=",
"[",
"'index'",
"=>",
"$",
"this",
"->",
"getIndexName",
"(",
")",
",",
"'type'",
"=>",
"$",
"type",
",",
"'id'",
"=>",
"$",
"id",
",",
"]",
";",
"if",
"(",
"$",
"routing",
")",
"{",
"$",
"params",
"[",
"'routing'",
"]",
"=",
"$",
"routing",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"get",
"(",
"$",
"params",
")",
";",
"}",
"catch",
"(",
"Missing404Exception",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"getConverter",
"(",
")",
"->",
"convertToDocument",
"(",
"$",
"result",
",",
"$",
"this",
")",
";",
"}"
] | Returns a single document by ID. Returns NULL if document was not found.
@param string $className Document class name or Elasticsearch type name
@param string $id Document ID to find
@param string $routing Custom routing for the document
@return object | [
"Returns",
"a",
"single",
"document",
"by",
"ID",
".",
"Returns",
"NULL",
"if",
"document",
"was",
"not",
"found",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L626-L647 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.scroll | public function scroll(
$scrollId,
$scrollDuration = '5m'
) {
$results = $this->getClient()->scroll(['scroll_id' => $scrollId, 'scroll' => $scrollDuration]);
return $results;
} | php | public function scroll(
$scrollId,
$scrollDuration = '5m'
) {
$results = $this->getClient()->scroll(['scroll_id' => $scrollId, 'scroll' => $scrollDuration]);
return $results;
} | [
"public",
"function",
"scroll",
"(",
"$",
"scrollId",
",",
"$",
"scrollDuration",
"=",
"'5m'",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"scroll",
"(",
"[",
"'scroll_id'",
"=>",
"$",
"scrollId",
",",
"'scroll'",
"=>",
"$",
"scrollDuration",
"]",
")",
";",
"return",
"$",
"results",
";",
"}"
] | Fetches next set of results.
@param string $scrollId
@param string $scrollDuration
@return mixed
@throws \Exception | [
"Fetches",
"next",
"set",
"of",
"results",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L659-L666 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.getAliases | public function getAliases($params = [])
{
return $this->getClient()->indices()->getAliases(array_merge(['index' => $this->getIndexName()], $params));
} | php | public function getAliases($params = [])
{
return $this->getClient()->indices()->getAliases(array_merge(['index' => $this->getIndexName()], $params));
} | [
"public",
"function",
"getAliases",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"indices",
"(",
")",
"->",
"getAliases",
"(",
"array_merge",
"(",
"[",
"'index'",
"=>",
"$",
"this",
"->",
"getIndexName",
"(",
")",
"]",
",",
"$",
"params",
")",
")",
";",
"}"
] | Gets Elasticsearch aliases information.
@param $params
@return array | [
"Gets",
"Elasticsearch",
"aliases",
"information",
".",
"@param",
"$params"
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L694-L697 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.resolveTypeName | private function resolveTypeName($className)
{
if (strpos($className, ':') !== false || strpos($className, '\\') !== false) {
return $this->getMetadataCollector()->getDocumentType($className);
}
return $className;
} | php | private function resolveTypeName($className)
{
if (strpos($className, ':') !== false || strpos($className, '\\') !== false) {
return $this->getMetadataCollector()->getDocumentType($className);
}
return $className;
} | [
"private",
"function",
"resolveTypeName",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"className",
",",
"':'",
")",
"!==",
"false",
"||",
"strpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getMetadataCollector",
"(",
")",
"->",
"getDocumentType",
"(",
"$",
"className",
")",
";",
"}",
"return",
"$",
"className",
";",
"}"
] | Resolves type name by class name.
@param string $className
@return string | [
"Resolves",
"type",
"name",
"by",
"class",
"name",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L706-L713 |
ongr-io/ElasticsearchBundle | Service/Manager.php | Manager.stopwatch | private function stopwatch($action, $name)
{
if (isset($this->stopwatch)) {
$this->stopwatch->$action('ongr_es: '.$name, 'ongr_es');
}
} | php | private function stopwatch($action, $name)
{
if (isset($this->stopwatch)) {
$this->stopwatch->$action('ongr_es: '.$name, 'ongr_es');
}
} | [
"private",
"function",
"stopwatch",
"(",
"$",
"action",
",",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"stopwatch",
")",
")",
"{",
"$",
"this",
"->",
"stopwatch",
"->",
"$",
"action",
"(",
"'ongr_es: '",
".",
"$",
"name",
",",
"'ongr_es'",
")",
";",
"}",
"}"
] | Starts and stops an event in the stopwatch
@param string $action only 'start' and 'stop'
@param string $name name of the event | [
"Starts",
"and",
"stops",
"an",
"event",
"in",
"the",
"stopwatch"
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/Manager.php#L721-L726 |
ongr-io/ElasticsearchBundle | Service/ExportService.php | ExportService.exportIndex | public function exportIndex(
Manager $manager,
$filename,
$types,
$chunkSize,
OutputInterface $output,
$maxLinesInFile = 300000
) {
$search = new Search();
$search->addQuery(new MatchAllQuery());
$search->setSize($chunkSize);
$search->addSort(new FieldSort('_doc'));
$queryParameters = [
'_source' => true,
'scroll' => '10m',
];
$searchResults = $manager->search($types, $search->toArray(), $queryParameters);
$results = new RawIterator(
$searchResults,
$manager,
[
'duration' => $queryParameters['scroll'],
'_scroll_id' => $searchResults['_scroll_id'],
]
);
$progress = new ProgressBar($output, $results->count());
$progress->setRedrawFrequency(100);
$progress->start();
$counter = $fileCounter = 0;
$count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);
$date = date(\DateTime::ISO8601);
$metadata = [
'count' => $count,
'date' => $date,
];
$filename = str_replace('.json', '', $filename);
$writer = $this->getWriter($this->getFilePath($filename.'.json'), $metadata);
$file = [];
foreach ($results as $data) {
if ($counter >= $maxLinesInFile) {
$writer->finalize();
$writer = null;
$fileCounter++;
$count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);
$metadata = [
'count' => $count,
'date' => $date,
];
$writer = $this->getWriter($this->getFilePath($filename."_".$fileCounter.".json"), $metadata);
$counter = 0;
}
$doc = array_intersect_key($data, array_flip(['_id', '_type', '_source']));
$writer->push($doc);
$file[] = $doc;
$progress->advance();
$counter++;
}
$writer->finalize();
$progress->finish();
$output->writeln('');
} | php | public function exportIndex(
Manager $manager,
$filename,
$types,
$chunkSize,
OutputInterface $output,
$maxLinesInFile = 300000
) {
$search = new Search();
$search->addQuery(new MatchAllQuery());
$search->setSize($chunkSize);
$search->addSort(new FieldSort('_doc'));
$queryParameters = [
'_source' => true,
'scroll' => '10m',
];
$searchResults = $manager->search($types, $search->toArray(), $queryParameters);
$results = new RawIterator(
$searchResults,
$manager,
[
'duration' => $queryParameters['scroll'],
'_scroll_id' => $searchResults['_scroll_id'],
]
);
$progress = new ProgressBar($output, $results->count());
$progress->setRedrawFrequency(100);
$progress->start();
$counter = $fileCounter = 0;
$count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);
$date = date(\DateTime::ISO8601);
$metadata = [
'count' => $count,
'date' => $date,
];
$filename = str_replace('.json', '', $filename);
$writer = $this->getWriter($this->getFilePath($filename.'.json'), $metadata);
$file = [];
foreach ($results as $data) {
if ($counter >= $maxLinesInFile) {
$writer->finalize();
$writer = null;
$fileCounter++;
$count = $this->getFileCount($results->count(), $maxLinesInFile, $fileCounter);
$metadata = [
'count' => $count,
'date' => $date,
];
$writer = $this->getWriter($this->getFilePath($filename."_".$fileCounter.".json"), $metadata);
$counter = 0;
}
$doc = array_intersect_key($data, array_flip(['_id', '_type', '_source']));
$writer->push($doc);
$file[] = $doc;
$progress->advance();
$counter++;
}
$writer->finalize();
$progress->finish();
$output->writeln('');
} | [
"public",
"function",
"exportIndex",
"(",
"Manager",
"$",
"manager",
",",
"$",
"filename",
",",
"$",
"types",
",",
"$",
"chunkSize",
",",
"OutputInterface",
"$",
"output",
",",
"$",
"maxLinesInFile",
"=",
"300000",
")",
"{",
"$",
"search",
"=",
"new",
"Search",
"(",
")",
";",
"$",
"search",
"->",
"addQuery",
"(",
"new",
"MatchAllQuery",
"(",
")",
")",
";",
"$",
"search",
"->",
"setSize",
"(",
"$",
"chunkSize",
")",
";",
"$",
"search",
"->",
"addSort",
"(",
"new",
"FieldSort",
"(",
"'_doc'",
")",
")",
";",
"$",
"queryParameters",
"=",
"[",
"'_source'",
"=>",
"true",
",",
"'scroll'",
"=>",
"'10m'",
",",
"]",
";",
"$",
"searchResults",
"=",
"$",
"manager",
"->",
"search",
"(",
"$",
"types",
",",
"$",
"search",
"->",
"toArray",
"(",
")",
",",
"$",
"queryParameters",
")",
";",
"$",
"results",
"=",
"new",
"RawIterator",
"(",
"$",
"searchResults",
",",
"$",
"manager",
",",
"[",
"'duration'",
"=>",
"$",
"queryParameters",
"[",
"'scroll'",
"]",
",",
"'_scroll_id'",
"=>",
"$",
"searchResults",
"[",
"'_scroll_id'",
"]",
",",
"]",
")",
";",
"$",
"progress",
"=",
"new",
"ProgressBar",
"(",
"$",
"output",
",",
"$",
"results",
"->",
"count",
"(",
")",
")",
";",
"$",
"progress",
"->",
"setRedrawFrequency",
"(",
"100",
")",
";",
"$",
"progress",
"->",
"start",
"(",
")",
";",
"$",
"counter",
"=",
"$",
"fileCounter",
"=",
"0",
";",
"$",
"count",
"=",
"$",
"this",
"->",
"getFileCount",
"(",
"$",
"results",
"->",
"count",
"(",
")",
",",
"$",
"maxLinesInFile",
",",
"$",
"fileCounter",
")",
";",
"$",
"date",
"=",
"date",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
";",
"$",
"metadata",
"=",
"[",
"'count'",
"=>",
"$",
"count",
",",
"'date'",
"=>",
"$",
"date",
",",
"]",
";",
"$",
"filename",
"=",
"str_replace",
"(",
"'.json'",
",",
"''",
",",
"$",
"filename",
")",
";",
"$",
"writer",
"=",
"$",
"this",
"->",
"getWriter",
"(",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"filename",
".",
"'.json'",
")",
",",
"$",
"metadata",
")",
";",
"$",
"file",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"counter",
">=",
"$",
"maxLinesInFile",
")",
"{",
"$",
"writer",
"->",
"finalize",
"(",
")",
";",
"$",
"writer",
"=",
"null",
";",
"$",
"fileCounter",
"++",
";",
"$",
"count",
"=",
"$",
"this",
"->",
"getFileCount",
"(",
"$",
"results",
"->",
"count",
"(",
")",
",",
"$",
"maxLinesInFile",
",",
"$",
"fileCounter",
")",
";",
"$",
"metadata",
"=",
"[",
"'count'",
"=>",
"$",
"count",
",",
"'date'",
"=>",
"$",
"date",
",",
"]",
";",
"$",
"writer",
"=",
"$",
"this",
"->",
"getWriter",
"(",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"filename",
".",
"\"_\"",
".",
"$",
"fileCounter",
".",
"\".json\"",
")",
",",
"$",
"metadata",
")",
";",
"$",
"counter",
"=",
"0",
";",
"}",
"$",
"doc",
"=",
"array_intersect_key",
"(",
"$",
"data",
",",
"array_flip",
"(",
"[",
"'_id'",
",",
"'_type'",
",",
"'_source'",
"]",
")",
")",
";",
"$",
"writer",
"->",
"push",
"(",
"$",
"doc",
")",
";",
"$",
"file",
"[",
"]",
"=",
"$",
"doc",
";",
"$",
"progress",
"->",
"advance",
"(",
")",
";",
"$",
"counter",
"++",
";",
"}",
"$",
"writer",
"->",
"finalize",
"(",
")",
";",
"$",
"progress",
"->",
"finish",
"(",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}"
] | Exports es index to provided file.
@param Manager $manager
@param string $filename
@param array $types
@param int $chunkSize
@param int $maxLinesInFile
@param OutputInterface $output | [
"Exports",
"es",
"index",
"to",
"provided",
"file",
"."
] | train | https://github.com/ongr-io/ElasticsearchBundle/blob/c817dc53d3b93129e8575a740e11484c67f79a87/Service/ExportService.php#L39-L110 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.