id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
38,500 | findbrok/php-watson-api-bridge | src/Bridge.php | Bridge.request | public function request($method = 'GET', $uri = '', $options = [])
{
try {
// Make the request.
return $this->getClient()->request($method, $uri, $this->getRequestOptions($options));
} catch (ClientException $e) {
// We are using token auth and probably token expired.
if ($this->authMethod == 'token' && $e->getCode() == 401 && ! $this->isThrottledReached()) {
// Try refresh token.
$this->fetchToken(true);
// Try requesting again.
return $this->request($method, $uri, $options);
}
// Clear throttle for this request.
$this->clearThrottle();
// Call Failed Request.
$this->failedRequest($e->getResponse());
}
} | php | public function request($method = 'GET', $uri = '', $options = [])
{
try {
// Make the request.
return $this->getClient()->request($method, $uri, $this->getRequestOptions($options));
} catch (ClientException $e) {
// We are using token auth and probably token expired.
if ($this->authMethod == 'token' && $e->getCode() == 401 && ! $this->isThrottledReached()) {
// Try refresh token.
$this->fetchToken(true);
// Try requesting again.
return $this->request($method, $uri, $options);
}
// Clear throttle for this request.
$this->clearThrottle();
// Call Failed Request.
$this->failedRequest($e->getResponse());
}
} | [
"public",
"function",
"request",
"(",
"$",
"method",
"=",
"'GET'",
",",
"$",
"uri",
"=",
"''",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"// Make the request.",
"return",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"request",
"(",... | Make a Request to Watson with credentials Auth.
@param string $method
@param string $uri
@param array $options
@return \GuzzleHttp\Psr7\Response | [
"Make",
"a",
"Request",
"to",
"Watson",
"with",
"credentials",
"Auth",
"."
] | 468da14e6b9fd4fef4f58cd32dd6533b7013f5ba | https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L473-L492 |
38,501 | findbrok/php-watson-api-bridge | src/Bridge.php | Bridge.send | private function send($method, $uri, $data, $type = 'json')
{
// Make the Request to Watson.
$response = $this->request($method, $uri, [$type => $data]);
// Request Failed.
if ($response->getStatusCode() != 200) {
// Throw Watson Bridge Exception.
$this->failedRequest($response);
}
// We return response.
return $response;
} | php | private function send($method, $uri, $data, $type = 'json')
{
// Make the Request to Watson.
$response = $this->request($method, $uri, [$type => $data]);
// Request Failed.
if ($response->getStatusCode() != 200) {
// Throw Watson Bridge Exception.
$this->failedRequest($response);
}
// We return response.
return $response;
} | [
"private",
"function",
"send",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"data",
",",
"$",
"type",
"=",
"'json'",
")",
"{",
"// Make the Request to Watson.",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"uri",
... | Send a Request to Watson.
@param string $method
@param string $uri
@param mixed $data
@param string $type
@return \GuzzleHttp\Psr7\Response | [
"Send",
"a",
"Request",
"to",
"Watson",
"."
] | 468da14e6b9fd4fef4f58cd32dd6533b7013f5ba | https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L504-L516 |
38,502 | findbrok/php-watson-api-bridge | src/Token.php | Token.isExpired | public function isExpired()
{
return $this->hasPayLoad() && ($this->payLoad['created'] + $this->payLoad['expires_in']) < Carbon::now()
->format('U');
} | php | public function isExpired()
{
return $this->hasPayLoad() && ($this->payLoad['created'] + $this->payLoad['expires_in']) < Carbon::now()
->format('U');
} | [
"public",
"function",
"isExpired",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"hasPayLoad",
"(",
")",
"&&",
"(",
"$",
"this",
"->",
"payLoad",
"[",
"'created'",
"]",
"+",
"$",
"this",
"->",
"payLoad",
"[",
"'expires_in'",
"]",
")",
"<",
"Carbon",
":... | Check that token is expired.
@return bool | [
"Check",
"that",
"token",
"is",
"expired",
"."
] | 468da14e6b9fd4fef4f58cd32dd6533b7013f5ba | https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Token.php#L67-L71 |
38,503 | findbrok/php-watson-api-bridge | src/Token.php | Token.save | public function save()
{
// No payload to save.
if (! $this->hasPayLoad()) {
return false;
}
// Save the token.
return (bool) file_put_contents($this->getFilePath(), collect($this->payLoad)->toJson(), LOCK_EX);
} | php | public function save()
{
// No payload to save.
if (! $this->hasPayLoad()) {
return false;
}
// Save the token.
return (bool) file_put_contents($this->getFilePath(), collect($this->payLoad)->toJson(), LOCK_EX);
} | [
"public",
"function",
"save",
"(",
")",
"{",
"// No payload to save.",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPayLoad",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Save the token.",
"return",
"(",
"bool",
")",
"file_put_contents",
"(",
"$",
"this"... | Saves a token.
@return bool | [
"Saves",
"a",
"token",
"."
] | 468da14e6b9fd4fef4f58cd32dd6533b7013f5ba | https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Token.php#L98-L107 |
38,504 | findbrok/php-watson-api-bridge | src/Token.php | Token.updateToken | public function updateToken($token)
{
// Update Payload.
$this->payLoad = [
'token' => $token,
'expires_in' => 3600,
'created' => Carbon::now()->format('U'),
];
// Save token.
return $this->save();
} | php | public function updateToken($token)
{
// Update Payload.
$this->payLoad = [
'token' => $token,
'expires_in' => 3600,
'created' => Carbon::now()->format('U'),
];
// Save token.
return $this->save();
} | [
"public",
"function",
"updateToken",
"(",
"$",
"token",
")",
"{",
"// Update Payload.",
"$",
"this",
"->",
"payLoad",
"=",
"[",
"'token'",
"=>",
"$",
"token",
",",
"'expires_in'",
"=>",
"3600",
",",
"'created'",
"=>",
"Carbon",
"::",
"now",
"(",
")",
"->... | Update the token.
@param string $token
@return bool | [
"Update",
"the",
"token",
"."
] | 468da14e6b9fd4fef4f58cd32dd6533b7013f5ba | https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Token.php#L163-L174 |
38,505 | findbrok/php-watson-api-bridge | src/Support/BridgeStack.php | BridgeStack.mountBridge | public function mountBridge($name, $credential, $service = null, $authMethod = 'credentials')
{
// Creates the Bridge.
$bridge = $this->carpenter->constructBridge($credential, $service, $authMethod);
// Save it under a name.
$this->put($name, $bridge);
return $this;
} | php | public function mountBridge($name, $credential, $service = null, $authMethod = 'credentials')
{
// Creates the Bridge.
$bridge = $this->carpenter->constructBridge($credential, $service, $authMethod);
// Save it under a name.
$this->put($name, $bridge);
return $this;
} | [
"public",
"function",
"mountBridge",
"(",
"$",
"name",
",",
"$",
"credential",
",",
"$",
"service",
"=",
"null",
",",
"$",
"authMethod",
"=",
"'credentials'",
")",
"{",
"// Creates the Bridge.",
"$",
"bridge",
"=",
"$",
"this",
"->",
"carpenter",
"->",
"co... | Mounts a Bridge on the stack.
@param string $name
@param string $credential
@param string $service
@param string $authMethod
@return $this | [
"Mounts",
"a",
"Bridge",
"on",
"the",
"stack",
"."
] | 468da14e6b9fd4fef4f58cd32dd6533b7013f5ba | https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Support/BridgeStack.php#L41-L50 |
38,506 | findbrok/php-watson-api-bridge | src/Support/BridgeStack.php | BridgeStack.conjure | public function conjure($name)
{
// We must check if the Bridge does
// exists.
if (! $this->has($name)) {
throw new WatsonBridgeException('The Bridge with name "'.$name.'" does not exist.');
}
return $this->get($name);
} | php | public function conjure($name)
{
// We must check if the Bridge does
// exists.
if (! $this->has($name)) {
throw new WatsonBridgeException('The Bridge with name "'.$name.'" does not exist.');
}
return $this->get($name);
} | [
"public",
"function",
"conjure",
"(",
"$",
"name",
")",
"{",
"// We must check if the Bridge does",
"// exists.",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"WatsonBridgeException",
"(",
"'The Bridge with name \"'"... | Conjures a specific Bridge to use.
@param string $name
@throws WatsonBridgeException
@return Bridge | [
"Conjures",
"a",
"specific",
"Bridge",
"to",
"use",
"."
] | 468da14e6b9fd4fef4f58cd32dd6533b7013f5ba | https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Support/BridgeStack.php#L60-L69 |
38,507 | touki653/php-ftp-wrapper | lib/Touki/FTP/Deleter/RecursiveDirectoryDeleter.php | RecursiveDirectoryDeleter.deleteFiles | private function deleteFiles(Directory $path)
{
foreach ($this->manager->findFiles($path) as $file) {
$this->wrapper->delete($file->getRealpath());
}
} | php | private function deleteFiles(Directory $path)
{
foreach ($this->manager->findFiles($path) as $file) {
$this->wrapper->delete($file->getRealpath());
}
} | [
"private",
"function",
"deleteFiles",
"(",
"Directory",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"manager",
"->",
"findFiles",
"(",
"$",
"path",
")",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"wrapper",
"->",
"delete",
"(",
"$"... | Deletes files in a directory
@param string $path /remote/path/ | [
"Deletes",
"files",
"in",
"a",
"directory"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/Deleter/RecursiveDirectoryDeleter.php#L96-L101 |
38,508 | touki653/php-ftp-wrapper | lib/Touki/FTP/Deleter/RecursiveDirectoryDeleter.php | RecursiveDirectoryDeleter.deleteDirectories | private function deleteDirectories(Directory $path, array $options = array())
{
foreach ($this->manager->findDirectories($path) as $dir) {
$this->delete($dir, $options);
}
} | php | private function deleteDirectories(Directory $path, array $options = array())
{
foreach ($this->manager->findDirectories($path) as $dir) {
$this->delete($dir, $options);
}
} | [
"private",
"function",
"deleteDirectories",
"(",
"Directory",
"$",
"path",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"manager",
"->",
"findDirectories",
"(",
"$",
"path",
")",
"as",
"$",
"dir",
"... | Deletes directories in a directory
@param Directory $path /remote/path/
@param array $options Deleter options | [
"Deletes",
"directories",
"in",
"a",
"directory"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/Deleter/RecursiveDirectoryDeleter.php#L109-L114 |
38,509 | touki653/php-ftp-wrapper | lib/Touki/FTP/DeleterVoter.php | DeleterVoter.addVotable | public function addVotable(DeleterVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | php | public function addVotable(DeleterVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | [
"public",
"function",
"addVotable",
"(",
"DeleterVotableInterface",
"$",
"votable",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"votables",
",",
"$",
"votable",
")",
";",
"}",... | Adds a votable Deleter
@param DeleterVotableInterface $votable A votable Deleter
@param boolean $prepend Whether to prepend the votable | [
"Adds",
"a",
"votable",
"Deleter"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/DeleterVoter.php#L39-L46 |
38,510 | touki653/php-ftp-wrapper | lib/Touki/FTP/DeleterVoter.php | DeleterVoter.addDefaultFTPDeleters | public function addDefaultFTPDeleters(FTPWrapper $wrapper, FTPFilesystemManager $manager)
{
$this->addVotable(new FTPDeleter\RecursiveDirectoryDeleter($wrapper, $manager));
$this->addVotable(new FTPDeleter\FileDeleter($wrapper, $manager));
} | php | public function addDefaultFTPDeleters(FTPWrapper $wrapper, FTPFilesystemManager $manager)
{
$this->addVotable(new FTPDeleter\RecursiveDirectoryDeleter($wrapper, $manager));
$this->addVotable(new FTPDeleter\FileDeleter($wrapper, $manager));
} | [
"public",
"function",
"addDefaultFTPDeleters",
"(",
"FTPWrapper",
"$",
"wrapper",
",",
"FTPFilesystemManager",
"$",
"manager",
")",
"{",
"$",
"this",
"->",
"addVotable",
"(",
"new",
"FTPDeleter",
"\\",
"RecursiveDirectoryDeleter",
"(",
"$",
"wrapper",
",",
"$",
... | Adds the default deleters
@param FTPWrapper $wrapper The FTPWrapper instance
@param FTPFilesystemManager $manager The Filesystem manager | [
"Adds",
"the",
"default",
"deleters"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/DeleterVoter.php#L54-L58 |
38,511 | touki653/php-ftp-wrapper | lib/Touki/FTP/Connection/Connection.php | Connection.open | public function open()
{
if ($this->isConnected()) {
throw new ConnectionEstablishedException;
}
$stream = $this->doConnect();
if (false === $stream) {
throw new ConnectionException(sprintf("Could not connect to server %s:%s", $this->getHost(), $this->getPort()));
}
if (!@ftp_login($stream, $this->getUsername(), $this->getPassword())) {
throw new ConnectionException(sprintf(
"Could not login using combination of username (%s) and password (%s)",
$this->getUsername(),
preg_replace("/./", "*", $this->getPassword())
));
}
if (true === $this->passive) {
if (false === ftp_pasv($stream, true)) {
throw new ConnectionException("Cold not turn on passive mode");
}
}
$this->connected = true;
$this->stream = $stream;
return true;
} | php | public function open()
{
if ($this->isConnected()) {
throw new ConnectionEstablishedException;
}
$stream = $this->doConnect();
if (false === $stream) {
throw new ConnectionException(sprintf("Could not connect to server %s:%s", $this->getHost(), $this->getPort()));
}
if (!@ftp_login($stream, $this->getUsername(), $this->getPassword())) {
throw new ConnectionException(sprintf(
"Could not login using combination of username (%s) and password (%s)",
$this->getUsername(),
preg_replace("/./", "*", $this->getPassword())
));
}
if (true === $this->passive) {
if (false === ftp_pasv($stream, true)) {
throw new ConnectionException("Cold not turn on passive mode");
}
}
$this->connected = true;
$this->stream = $stream;
return true;
} | [
"public",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isConnected",
"(",
")",
")",
"{",
"throw",
"new",
"ConnectionEstablishedException",
";",
"}",
"$",
"stream",
"=",
"$",
"this",
"->",
"doConnect",
"(",
")",
";",
"if",
"(",
"f... | Opens the connection
@return boolean TRUE when connection suceeded
@throws ConnectionEstablishedException When connection is already running
@throws ConnectionException When connection to server failed
@throws ConnectionException When loging-in to server failed | [
"Opens",
"the",
"connection"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/Connection/Connection.php#L105-L135 |
38,512 | touki653/php-ftp-wrapper | lib/Touki/FTP/UploaderVoter.php | UploaderVoter.addVotable | public function addVotable(UploaderVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | php | public function addVotable(UploaderVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | [
"public",
"function",
"addVotable",
"(",
"UploaderVotableInterface",
"$",
"votable",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"votables",
",",
"$",
"votable",
")",
";",
"}"... | Adds a votable uploader
@param UploaderVotableInterface $votable A votable uploader
@param boolean $prepend Whether to prepend the votable | [
"Adds",
"a",
"votable",
"uploader"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/UploaderVoter.php#L38-L45 |
38,513 | touki653/php-ftp-wrapper | lib/Touki/FTP/UploaderVoter.php | UploaderVoter.addDefaultFTPUploaders | public function addDefaultFTPUploaders(FTPWrapper $wrapper)
{
$this->addVotable(new FTPUploader\FileUploader($wrapper));
$this->addVotable(new FTPUploader\ResourceUploader($wrapper));
$this->addVotable(new FTPUploader\NbFileUploader($wrapper));
$this->addVotable(new FTPUploader\NbResourceUploader($wrapper));
} | php | public function addDefaultFTPUploaders(FTPWrapper $wrapper)
{
$this->addVotable(new FTPUploader\FileUploader($wrapper));
$this->addVotable(new FTPUploader\ResourceUploader($wrapper));
$this->addVotable(new FTPUploader\NbFileUploader($wrapper));
$this->addVotable(new FTPUploader\NbResourceUploader($wrapper));
} | [
"public",
"function",
"addDefaultFTPUploaders",
"(",
"FTPWrapper",
"$",
"wrapper",
")",
"{",
"$",
"this",
"->",
"addVotable",
"(",
"new",
"FTPUploader",
"\\",
"FileUploader",
"(",
"$",
"wrapper",
")",
")",
";",
"$",
"this",
"->",
"addVotable",
"(",
"new",
... | Adds the default uploaders
@param FTPWrapper $wrapper An FTP Wrapper | [
"Adds",
"the",
"default",
"uploaders"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/UploaderVoter.php#L52-L58 |
38,514 | touki653/php-ftp-wrapper | lib/Touki/FTP/DownloaderVoter.php | DownloaderVoter.addVotable | public function addVotable(DownloaderVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | php | public function addVotable(DownloaderVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | [
"public",
"function",
"addVotable",
"(",
"DownloaderVotableInterface",
"$",
"votable",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"votables",
",",
"$",
"votable",
")",
";",
"... | Adds a votable downloader
@param DownloaderVotableInterface $votable A votable downloader
@param boolean $prepend Whether to prepend the votable | [
"Adds",
"a",
"votable",
"downloader"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/DownloaderVoter.php#L38-L45 |
38,515 | touki653/php-ftp-wrapper | lib/Touki/FTP/DownloaderVoter.php | DownloaderVoter.addDefaultFTPDownloaders | public function addDefaultFTPDownloaders(FTPWrapper $wrapper)
{
$this->addVotable(new FTPDownloader\FileDownloader($wrapper));
$this->addVotable(new FTPDownloader\ResourceDownloader($wrapper));
$this->addVotable(new FTPDownloader\NbFileDownloader($wrapper));
$this->addVotable(new FTPDownloader\NbResourceDownloader($wrapper));
} | php | public function addDefaultFTPDownloaders(FTPWrapper $wrapper)
{
$this->addVotable(new FTPDownloader\FileDownloader($wrapper));
$this->addVotable(new FTPDownloader\ResourceDownloader($wrapper));
$this->addVotable(new FTPDownloader\NbFileDownloader($wrapper));
$this->addVotable(new FTPDownloader\NbResourceDownloader($wrapper));
} | [
"public",
"function",
"addDefaultFTPDownloaders",
"(",
"FTPWrapper",
"$",
"wrapper",
")",
"{",
"$",
"this",
"->",
"addVotable",
"(",
"new",
"FTPDownloader",
"\\",
"FileDownloader",
"(",
"$",
"wrapper",
")",
")",
";",
"$",
"this",
"->",
"addVotable",
"(",
"ne... | Adds the default downloaders
@param FTPWrapper $wrapper An FTP Wrapper | [
"Adds",
"the",
"default",
"downloaders"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/DownloaderVoter.php#L52-L58 |
38,516 | touki653/php-ftp-wrapper | lib/Touki/FTP/Manager/FTPFilesystemManager.php | FTPFilesystemManager.findFilesystemByName | public function findFilesystemByName($name, Directory $inDirectory = null)
{
$name = '/'.ltrim($name, '/');
$directory = dirname($name);
$directory = str_replace('\\', '/', $directory); // Issue #7
if ($inDirectory) {
$name = sprintf("/%s", ltrim($inDirectory->getRealpath().$name, '/'));
$directory = $inDirectory;
}
return $this->findOneBy($directory, function ($item) use ($name) {
return $name == $item->getRealpath();
});
} | php | public function findFilesystemByName($name, Directory $inDirectory = null)
{
$name = '/'.ltrim($name, '/');
$directory = dirname($name);
$directory = str_replace('\\', '/', $directory); // Issue #7
if ($inDirectory) {
$name = sprintf("/%s", ltrim($inDirectory->getRealpath().$name, '/'));
$directory = $inDirectory;
}
return $this->findOneBy($directory, function ($item) use ($name) {
return $name == $item->getRealpath();
});
} | [
"public",
"function",
"findFilesystemByName",
"(",
"$",
"name",
",",
"Directory",
"$",
"inDirectory",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"'/'",
".",
"ltrim",
"(",
"$",
"name",
",",
"'/'",
")",
";",
"$",
"directory",
"=",
"dirname",
"(",
"$",
"n... | Finds a filesystem by its name
@param string $name Filesystem name
@param Directory|null $inDirectory Directory to fetch in
@return Filesystem | [
"Finds",
"a",
"filesystem",
"by",
"its",
"name"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/Manager/FTPFilesystemManager.php#L183-L197 |
38,517 | touki653/php-ftp-wrapper | lib/Touki/FTP/Manager/FTPFilesystemManager.php | FTPFilesystemManager.getCwd | public function getCwd()
{
$path = $this->wrapper->pwd();
if ('/' === $path) {
return new Directory('/');
}
return $this->findDirectoryByName($path);
} | php | public function getCwd()
{
$path = $this->wrapper->pwd();
if ('/' === $path) {
return new Directory('/');
}
return $this->findDirectoryByName($path);
} | [
"public",
"function",
"getCwd",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"wrapper",
"->",
"pwd",
"(",
")",
";",
"if",
"(",
"'/'",
"===",
"$",
"path",
")",
"{",
"return",
"new",
"Directory",
"(",
"'/'",
")",
";",
"}",
"return",
"$",
"... | Returns the current working directory
@return Directory Current directory | [
"Returns",
"the",
"current",
"working",
"directory"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/Manager/FTPFilesystemManager.php#L281-L290 |
38,518 | touki653/php-ftp-wrapper | lib/Touki/FTP/PermissionsFactory.php | PermissionsFactory.build | public function build($input)
{
if (strlen($input) != 3) {
throw new \InvalidArgumentException(sprintf("%s is not a valid permission input", $input));
}
$perms = 0;
if ('r' === substr($input, 0, 1)) {
$perms |= Permissions::READABLE;
}
if ('w' === substr($input, 1, 1)) {
$perms |= Permissions::WRITABLE;
}
if ('x' === substr($input, 2, 1)) {
$perms |= Permissions::EXECUTABLE;
}
$permissions = new Permissions;
$permissions->setFlags($perms);
return $permissions;
} | php | public function build($input)
{
if (strlen($input) != 3) {
throw new \InvalidArgumentException(sprintf("%s is not a valid permission input", $input));
}
$perms = 0;
if ('r' === substr($input, 0, 1)) {
$perms |= Permissions::READABLE;
}
if ('w' === substr($input, 1, 1)) {
$perms |= Permissions::WRITABLE;
}
if ('x' === substr($input, 2, 1)) {
$perms |= Permissions::EXECUTABLE;
}
$permissions = new Permissions;
$permissions->setFlags($perms);
return $permissions;
} | [
"public",
"function",
"build",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"input",
")",
"!=",
"3",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"%s is not a valid permission input\"",
",",
"$",
"input",
... | Builds a Permissions object
@param string $input Permissions string
@return Permissions | [
"Builds",
"a",
"Permissions",
"object"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/PermissionsFactory.php#L34-L58 |
38,519 | touki653/php-ftp-wrapper | lib/Touki/FTP/CreatorVoter.php | CreatorVoter.addVotable | public function addVotable(CreatorVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | php | public function addVotable(CreatorVotableInterface $votable, $prepend = false)
{
if ($prepend) {
array_unshift($this->votables, $votable);
} else {
$this->votables[] = $votable;
}
} | [
"public",
"function",
"addVotable",
"(",
"CreatorVotableInterface",
"$",
"votable",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"votables",
",",
"$",
"votable",
")",
";",
"}",... | Adds a votable Creator
@param CreatorVotableInterface $votable A votable Creator
@param boolean $prepend Whether to prepend the votable | [
"Adds",
"a",
"votable",
"Creator"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/CreatorVoter.php#L39-L46 |
38,520 | touki653/php-ftp-wrapper | lib/Touki/FTP/CreatorVoter.php | CreatorVoter.addDefaultFTPCreators | public function addDefaultFTPCreators(FTPWrapper $wrapper, FTPFilesystemManager $manager)
{
$this->addVotable(new FTPCreator\RecursiveDirectoryCreator($wrapper, $manager));
} | php | public function addDefaultFTPCreators(FTPWrapper $wrapper, FTPFilesystemManager $manager)
{
$this->addVotable(new FTPCreator\RecursiveDirectoryCreator($wrapper, $manager));
} | [
"public",
"function",
"addDefaultFTPCreators",
"(",
"FTPWrapper",
"$",
"wrapper",
",",
"FTPFilesystemManager",
"$",
"manager",
")",
"{",
"$",
"this",
"->",
"addVotable",
"(",
"new",
"FTPCreator",
"\\",
"RecursiveDirectoryCreator",
"(",
"$",
"wrapper",
",",
"$",
... | Adds the default creators
@param FTPWrapper $wrapper The FTPWrapper instance
@param FTPFilesystemManager $manager The Filesystem manager | [
"Adds",
"the",
"default",
"creators"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/CreatorVoter.php#L54-L57 |
38,521 | touki653/php-ftp-wrapper | lib/Touki/FTP/FTPFactory.php | FTPFactory.build | public function build(ConnectionInterface $connection)
{
if (!$connection->isConnected()) {
$connection->open();
}
if (null === $this->wrapper) {
$this->wrapper = new FTPWrapper($connection);
}
if (null === $this->manager) {
if (null === $this->fsFactory) {
$this->fsFactory = new FilesystemFactory(new PermissionsFactory);
}
$this->manager = new FTPFilesystemManager($this->wrapper, $this->fsFactory);
}
if (null === $this->dlVoter) {
$this->dlVoter = new DownloaderVoter;
$this->dlVoter->addDefaultFTPDownloaders($this->wrapper);
}
if (null === $this->ulVoter) {
$this->ulVoter = new UploaderVoter;
$this->ulVoter->addDefaultFTPUploaders($this->wrapper);
}
if (null === $this->crVoter) {
$this->crVoter = new CreatorVoter;
$this->crVoter->addDefaultFTPCreators($this->wrapper, $this->manager);
}
if (null === $this->deVoter) {
$this->deVoter = new DeleterVoter;
$this->deVoter->addDefaultFTPDeleters($this->wrapper, $this->manager);
}
return new FTP($this->manager, $this->dlVoter, $this->ulVoter, $this->crVoter, $this->deVoter);
} | php | public function build(ConnectionInterface $connection)
{
if (!$connection->isConnected()) {
$connection->open();
}
if (null === $this->wrapper) {
$this->wrapper = new FTPWrapper($connection);
}
if (null === $this->manager) {
if (null === $this->fsFactory) {
$this->fsFactory = new FilesystemFactory(new PermissionsFactory);
}
$this->manager = new FTPFilesystemManager($this->wrapper, $this->fsFactory);
}
if (null === $this->dlVoter) {
$this->dlVoter = new DownloaderVoter;
$this->dlVoter->addDefaultFTPDownloaders($this->wrapper);
}
if (null === $this->ulVoter) {
$this->ulVoter = new UploaderVoter;
$this->ulVoter->addDefaultFTPUploaders($this->wrapper);
}
if (null === $this->crVoter) {
$this->crVoter = new CreatorVoter;
$this->crVoter->addDefaultFTPCreators($this->wrapper, $this->manager);
}
if (null === $this->deVoter) {
$this->deVoter = new DeleterVoter;
$this->deVoter->addDefaultFTPDeleters($this->wrapper, $this->manager);
}
return new FTP($this->manager, $this->dlVoter, $this->ulVoter, $this->crVoter, $this->deVoter);
} | [
"public",
"function",
"build",
"(",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"if",
"(",
"!",
"$",
"connection",
"->",
"isConnected",
"(",
")",
")",
"{",
"$",
"connection",
"->",
"open",
"(",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"t... | Creates an FTP instance
@return FTP An FTP instance | [
"Creates",
"an",
"FTP",
"instance"
] | 318595fb8b1bff215b4af092c3faae83a532b822 | https://github.com/touki653/php-ftp-wrapper/blob/318595fb8b1bff215b4af092c3faae83a532b822/lib/Touki/FTP/FTPFactory.php#L168-L207 |
38,522 | borodulin/yii2-oauth2-server | src/request/AccessTokenExtractor.php | AccessTokenExtractor.extract | public function extract()
{
$headerToken = null;
foreach ($this->_request->getHeaders()->get('Authorization', [], false) as $authHeader) {
if (preg_match('/^Bearer\\s+(.*?)$/', $authHeader, $matches)) {
$headerToken = $matches[1];
break;
}
}
$postToken = $this->_request->post('access_token');
$getToken = $this->_request->get('access_token');
// Check that exactly one method was used
$methodsCount = isset($headerToken) + isset($postToken) + isset($getToken);
if ($methodsCount > 1) {
throw new Exception(Yii::t('conquer/oauth2', 'Only one method may be used to authenticate at a time (Auth header, POST or GET).'));
} elseif ($methodsCount === 0) {
throw new Exception(Yii::t('conquer/oauth2', 'The access token was not found.'));
}
// HEADER: Get the access token from the header
if ($headerToken) {
return $headerToken;
}
// POST: Get the token from POST data
if ($postToken) {
if (!$this->_request->isPost) {
throw new Exception(Yii::t('conquer/oauth2', 'When putting the token in the body, the method must be POST.'));
}
// IETF specifies content-type. NB: Not all webservers populate this _SERVER variable
if (strpos($this->_request->contentType, 'application/x-www-form-urlencoded') !== 0) {
throw new Exception(Yii::t('conquer/oauth2', 'The content type for POST requests must be "application/x-www-form-urlencoded".'));
}
return $postToken;
}
return $getToken;
} | php | public function extract()
{
$headerToken = null;
foreach ($this->_request->getHeaders()->get('Authorization', [], false) as $authHeader) {
if (preg_match('/^Bearer\\s+(.*?)$/', $authHeader, $matches)) {
$headerToken = $matches[1];
break;
}
}
$postToken = $this->_request->post('access_token');
$getToken = $this->_request->get('access_token');
// Check that exactly one method was used
$methodsCount = isset($headerToken) + isset($postToken) + isset($getToken);
if ($methodsCount > 1) {
throw new Exception(Yii::t('conquer/oauth2', 'Only one method may be used to authenticate at a time (Auth header, POST or GET).'));
} elseif ($methodsCount === 0) {
throw new Exception(Yii::t('conquer/oauth2', 'The access token was not found.'));
}
// HEADER: Get the access token from the header
if ($headerToken) {
return $headerToken;
}
// POST: Get the token from POST data
if ($postToken) {
if (!$this->_request->isPost) {
throw new Exception(Yii::t('conquer/oauth2', 'When putting the token in the body, the method must be POST.'));
}
// IETF specifies content-type. NB: Not all webservers populate this _SERVER variable
if (strpos($this->_request->contentType, 'application/x-www-form-urlencoded') !== 0) {
throw new Exception(Yii::t('conquer/oauth2', 'The content type for POST requests must be "application/x-www-form-urlencoded".'));
}
return $postToken;
}
return $getToken;
} | [
"public",
"function",
"extract",
"(",
")",
"{",
"$",
"headerToken",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"_request",
"->",
"getHeaders",
"(",
")",
"->",
"get",
"(",
"'Authorization'",
",",
"[",
"]",
",",
"false",
")",
"as",
"$",
"auth... | Extracts access_token from web request
@return string
@throws Exception | [
"Extracts",
"access_token",
"from",
"web",
"request"
] | 6fab7c342677934bc0a85341979b95717480ae91 | https://github.com/borodulin/yii2-oauth2-server/blob/6fab7c342677934bc0a85341979b95717480ae91/src/request/AccessTokenExtractor.php#L34-L72 |
38,523 | borodulin/yii2-oauth2-server | src/AuthorizeFilter.php | AuthorizeFilter.finishAuthorization | public function finishAuthorization()
{
/** @var Authorization $responseType */
$responseType = $this->getResponseType();
if (Yii::$app->user->isGuest) {
$responseType->errorRedirect(Yii::t('conquer/oauth2', 'The User denied access to your application.'), Exception::ACCESS_DENIED);
}
$parts = $responseType->getResponseData();
$redirectUri = http_build_url($responseType->redirect_uri, $parts, HTTP_URL_JOIN_QUERY | HTTP_URL_STRIP_FRAGMENT);
if (isset($parts['fragment'])) {
$redirectUri .= '#' . $parts['fragment'];
}
Yii::$app->response->redirect($redirectUri);
} | php | public function finishAuthorization()
{
/** @var Authorization $responseType */
$responseType = $this->getResponseType();
if (Yii::$app->user->isGuest) {
$responseType->errorRedirect(Yii::t('conquer/oauth2', 'The User denied access to your application.'), Exception::ACCESS_DENIED);
}
$parts = $responseType->getResponseData();
$redirectUri = http_build_url($responseType->redirect_uri, $parts, HTTP_URL_JOIN_QUERY | HTTP_URL_STRIP_FRAGMENT);
if (isset($parts['fragment'])) {
$redirectUri .= '#' . $parts['fragment'];
}
Yii::$app->response->redirect($redirectUri);
} | [
"public",
"function",
"finishAuthorization",
"(",
")",
"{",
"/** @var Authorization $responseType */",
"$",
"responseType",
"=",
"$",
"this",
"->",
"getResponseType",
"(",
")",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"isGuest",
")",
"{",
... | Finish oauth authorization.
Builds redirect uri and performs redirect.
If user is not logged on, redirect contains the Access Denied Error | [
"Finish",
"oauth",
"authorization",
".",
"Builds",
"redirect",
"uri",
"and",
"performs",
"redirect",
".",
"If",
"user",
"is",
"not",
"logged",
"on",
"redirect",
"contains",
"the",
"Access",
"Denied",
"Error"
] | 6fab7c342677934bc0a85341979b95717480ae91 | https://github.com/borodulin/yii2-oauth2-server/blob/6fab7c342677934bc0a85341979b95717480ae91/src/AuthorizeFilter.php#L110-L126 |
38,524 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/PermissionsController.php | PermissionsController.index | public function index()
{
$permissions = $this->permissions->all();
return View::make(Config::get('cpanel::views.permissions_index'))
->with('permissions', $permissions);
} | php | public function index()
{
$permissions = $this->permissions->all();
return View::make(Config::get('cpanel::views.permissions_index'))
->with('permissions', $permissions);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"permissions",
"=",
"$",
"this",
"->",
"permissions",
"->",
"all",
"(",
")",
";",
"return",
"View",
"::",
"make",
"(",
"Config",
"::",
"get",
"(",
"'cpanel::views.permissions_index'",
")",
")",
"->",
"wi... | Display all the permissions
@author Steve Montambeault
@link http://stevemo.ca
@return \Illuminate\View\View | [
"Display",
"all",
"the",
"permissions"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/PermissionsController.php#L38-L44 |
38,525 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/PermissionsController.php | PermissionsController.edit | public function edit($id)
{
$permission = $this->permissions->find($id);
if ( $permission )
{
return View::make( Config::get('cpanel::views.permissions_edit') )
->with('permission', $permission);
}
else
{
return Redirect::route('cpanel.permissions.index')
->with('error', Lang::get('cpanel::permissions.model_not_found'));
}
} | php | public function edit($id)
{
$permission = $this->permissions->find($id);
if ( $permission )
{
return View::make( Config::get('cpanel::views.permissions_edit') )
->with('permission', $permission);
}
else
{
return Redirect::route('cpanel.permissions.index')
->with('error', Lang::get('cpanel::permissions.model_not_found'));
}
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
")",
"{",
"$",
"permission",
"=",
"$",
"this",
"->",
"permissions",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"permission",
")",
"{",
"return",
"View",
"::",
"make",
"(",
"Config",
"::",
... | Display the edit permission form
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@return \Illuminate\Http\RedirectResponse|\Illuminate\View\View | [
"Display",
"the",
"edit",
"permission",
"form"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/PermissionsController.php#L69-L83 |
38,526 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/PermissionsController.php | PermissionsController.store | public function store()
{
$inputs = Input::all();
if ( $this->form->create($inputs) )
{
return Redirect::route('cpanel.permissions.index')
->with('success', Lang::get('cpanel::permissions.create_success'));
}
return Redirect::back()
->withInput()
->withErrors($this->form->getErrors());
} | php | public function store()
{
$inputs = Input::all();
if ( $this->form->create($inputs) )
{
return Redirect::route('cpanel.permissions.index')
->with('success', Lang::get('cpanel::permissions.create_success'));
}
return Redirect::back()
->withInput()
->withErrors($this->form->getErrors());
} | [
"public",
"function",
"store",
"(",
")",
"{",
"$",
"inputs",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"form",
"->",
"create",
"(",
"$",
"inputs",
")",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'cpanel.permi... | Save new permissions into the database
@author Steve Montambeault
@link http://stevemo.ca
@return \Illuminate\Http\RedirectResponse | [
"Save",
"new",
"permissions",
"into",
"the",
"database"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/PermissionsController.php#L94-L107 |
38,527 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/PermissionsController.php | PermissionsController.update | public function update($id)
{
$inputs = Input::all();
$inputs['id'] = $id;
try
{
if ( $this->form->update($inputs) )
{
return Redirect::route('cpanel.permissions.index')
->with('success', Lang::get('cpanel::permissions.update_success'));
}
return Redirect::back()
->withInput()
->withErrors($this->form->getErrors());
}
catch ( PermissionNotFoundException $e )
{
return Redirect::route('cpanel.permissions.index')
->with('error', Lang::get('cpanel::permissions.model_not_found'));
}
} | php | public function update($id)
{
$inputs = Input::all();
$inputs['id'] = $id;
try
{
if ( $this->form->update($inputs) )
{
return Redirect::route('cpanel.permissions.index')
->with('success', Lang::get('cpanel::permissions.update_success'));
}
return Redirect::back()
->withInput()
->withErrors($this->form->getErrors());
}
catch ( PermissionNotFoundException $e )
{
return Redirect::route('cpanel.permissions.index')
->with('error', Lang::get('cpanel::permissions.model_not_found'));
}
} | [
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"$",
"inputs",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"inputs",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"form",
"->",
"update",
"(",
"$... | Process the edit form
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@return \Illuminate\Http\RedirectResponse | [
"Process",
"the",
"edit",
"form"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/PermissionsController.php#L119-L141 |
38,528 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/PermissionsController.php | PermissionsController.destroy | public function destroy($id)
{
if ( $this->permissions->delete($id) )
{
return Redirect::route('cpanel.permissions.index')
->with('success', Lang::get('cpanel::permissions.delete_success'));
}
else
{
return Redirect::route('cpanel.permissions.index')
->with('error', Lang::get('cpanel::permissions.model_not_found'));
}
} | php | public function destroy($id)
{
if ( $this->permissions->delete($id) )
{
return Redirect::route('cpanel.permissions.index')
->with('success', Lang::get('cpanel::permissions.delete_success'));
}
else
{
return Redirect::route('cpanel.permissions.index')
->with('error', Lang::get('cpanel::permissions.model_not_found'));
}
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"->",
"delete",
"(",
"$",
"id",
")",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'cpanel.permissions.index'",
")",
"->",
"with",
"(",
"'suc... | Delete a permission module
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@return \Illuminate\Http\RedirectResponse | [
"Delete",
"a",
"permission",
"module"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/PermissionsController.php#L153-L165 |
38,529 | stevemo/cpanel | src/Stevemo/Cpanel/Services/Validation/AbstractValidator.php | AbstractValidator.passes | public function passes()
{
$validator = $this->validator->make($this->data, $this->rules, $this->messages);
if( $validator->fails() )
{
$this->errors = $validator->messages();
return false;
}
return true;
} | php | public function passes()
{
$validator = $this->validator->make($this->data, $this->rules, $this->messages);
if( $validator->fails() )
{
$this->errors = $validator->messages();
return false;
}
return true;
} | [
"public",
"function",
"passes",
"(",
")",
"{",
"$",
"validator",
"=",
"$",
"this",
"->",
"validator",
"->",
"make",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"rules",
",",
"$",
"this",
"->",
"messages",
")",
";",
"if",
"(",
"$",
"va... | Test if validation passes
@author Steve Montambeault
@link http://stevemo.ca
@return bool | [
"Test",
"if",
"validation",
"passes"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Services/Validation/AbstractValidator.php#L80-L91 |
38,530 | nwtn/php-respimg | src/Respimg.php | Respimg.optimize | public static function optimize($path, $svgo = 0, $image_optim = 0, $picopt = 0, $imageOptim = 0) {
// make sure the path is real
if (!file_exists($path)) {
return false;
}
$is_dir = is_dir($path);
if (!$is_dir) {
$dir = escapeshellarg(substr($path, 0, strrpos($path, '/')));
$file = escapeshellarg(substr($path, strrpos($path, '/') + 1));
}
$path = escapeshellarg($path);
// make sure we got some ints up in here
$svgo = (int) $svgo;
$image_optim = (int) $image_optim;
$picopt = (int) $picopt;
$imageOptim = (int) $imageOptim;
// create some vars to store output
$output = array();
$return_var = 0;
// if we’re using image_optim, we need to create the YAML config file
if ($image_optim > 0) {
$yml = tempnam('/tmp', 'yml');
file_put_contents($yml, "verbose: true\njpegtran:\n progressive: false\noptipng:\n level: 7\n interlace: false\npngcrush:\n fix: true\n brute: true\npngquant:\n speed: 11\n");
}
// do the svgo optimizations
for ($i = 0; $i < $svgo; $i++) {
if ($is_dir) {
$command = escapeshellcmd('svgo -f ' . $path . ' --disable removeUnknownsAndDefaults');
} else {
$command = escapeshellcmd('svgo -i ' . $path . ' --disable removeUnknownsAndDefaults');
}
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
// do the image_optim optimizations
for ($i = 0; $i < $image_optim; $i++) {
$command = escapeshellcmd('image_optim -r ' . $path . ' --config-paths ' . $yml);
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
// do the picopt optimizations
for ($i = 0; $i < $picopt; $i++) {
$command = escapeshellcmd('picopt -r ' . $path);
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
// do the ImageOptim optimizations
// ImageOptim can’t handle the path with single quotes, so we have to strip them
// ImageOptim-CLI has an issue where it only works with a directory, not a single file
for ($i = 0; $i < $imageOptim; $i++) {
if ($is_dir) {
$command = escapeshellcmd('imageoptim -d ' . $path . ' -q');
} else {
$command = escapeshellcmd('find ' . $dir . ' -name ' . $file) . ' | imageoptim';
}
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
return $output;
} | php | public static function optimize($path, $svgo = 0, $image_optim = 0, $picopt = 0, $imageOptim = 0) {
// make sure the path is real
if (!file_exists($path)) {
return false;
}
$is_dir = is_dir($path);
if (!$is_dir) {
$dir = escapeshellarg(substr($path, 0, strrpos($path, '/')));
$file = escapeshellarg(substr($path, strrpos($path, '/') + 1));
}
$path = escapeshellarg($path);
// make sure we got some ints up in here
$svgo = (int) $svgo;
$image_optim = (int) $image_optim;
$picopt = (int) $picopt;
$imageOptim = (int) $imageOptim;
// create some vars to store output
$output = array();
$return_var = 0;
// if we’re using image_optim, we need to create the YAML config file
if ($image_optim > 0) {
$yml = tempnam('/tmp', 'yml');
file_put_contents($yml, "verbose: true\njpegtran:\n progressive: false\noptipng:\n level: 7\n interlace: false\npngcrush:\n fix: true\n brute: true\npngquant:\n speed: 11\n");
}
// do the svgo optimizations
for ($i = 0; $i < $svgo; $i++) {
if ($is_dir) {
$command = escapeshellcmd('svgo -f ' . $path . ' --disable removeUnknownsAndDefaults');
} else {
$command = escapeshellcmd('svgo -i ' . $path . ' --disable removeUnknownsAndDefaults');
}
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
// do the image_optim optimizations
for ($i = 0; $i < $image_optim; $i++) {
$command = escapeshellcmd('image_optim -r ' . $path . ' --config-paths ' . $yml);
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
// do the picopt optimizations
for ($i = 0; $i < $picopt; $i++) {
$command = escapeshellcmd('picopt -r ' . $path);
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
// do the ImageOptim optimizations
// ImageOptim can’t handle the path with single quotes, so we have to strip them
// ImageOptim-CLI has an issue where it only works with a directory, not a single file
for ($i = 0; $i < $imageOptim; $i++) {
if ($is_dir) {
$command = escapeshellcmd('imageoptim -d ' . $path . ' -q');
} else {
$command = escapeshellcmd('find ' . $dir . ' -name ' . $file) . ' | imageoptim';
}
exec($command, $output, $return_var);
if ($return_var != 0) {
return false;
}
}
return $output;
} | [
"public",
"static",
"function",
"optimize",
"(",
"$",
"path",
",",
"$",
"svgo",
"=",
"0",
",",
"$",
"image_optim",
"=",
"0",
",",
"$",
"picopt",
"=",
"0",
",",
"$",
"imageOptim",
"=",
"0",
")",
"{",
"// make sure the path is real",
"if",
"(",
"!",
"f... | Optimizes the image without reducing quality.
This function calls up to four external programs, which must be installed and available in the $PATH:
* SVGO
* image_optim
* picopt
* ImageOptim
Note that these are executed using PHP’s `exec` command, so there may be security implications.
@access public
@param string $path The path to the file or directory that should be optimized.
@param integer $svgo The number of times to optimize using SVGO.
@param integer $image_optim The number of times to optimize using image_optim.
@param integer $picopt The number of times to optimize using picopt.
@param integer $imageOptim The number of times to optimize using ImageOptim. | [
"Optimizes",
"the",
"image",
"without",
"reducing",
"quality",
"."
] | 9bb067726b479ff362202529f4c98b53a53a04c1 | https://github.com/nwtn/php-respimg/blob/9bb067726b479ff362202529f4c98b53a53a04c1/src/Respimg.php#L62-L143 |
38,531 | nwtn/php-respimg | src/Respimg.php | Respimg.rasterize | public static function rasterize($file, $dest, $columns, $rows) {
// check the input
if (!file_exists($file)) {
return false;
}
if (!file_exists($dest) || !is_dir($dest)) {
return false;
}
// figure out the output width and height
$svgTmp = new Respimg($file);
$width = (double) $svgTmp->getImageWidth();
$height = (double) $svgTmp->getImageHeight();
$new_width = $columns;
$new_height = $rows;
$x_factor = $columns / $width;
$y_factor = $rows / $height;
if ($rows < 1) {
$new_height = round($x_factor * $height);
} elseif ($columns < 1) {
$new_width = round($y_factor * $width);
}
// get the svg data
$svgdata = file_get_contents($file);
// figure out some path stuff
$dest = rtrim($dest, '/');
$filename = substr($file, strrpos($file, '/') + 1);
$filename_base = substr($filename, 0, strrpos($filename, '.'));
// setup the request
$client = Client::getInstance();
$serviceContainer = ServiceContainer::getInstance();
$procedureLoaderFactory = $serviceContainer->get('procedure_loader_factory');
$procedureLoader = $procedureLoaderFactory->createProcedureLoader(__DIR__);
$client->getProcedureLoader()->addLoader($procedureLoader);
$request = new RespimgCaptureRequest();
$request->setType('svg2png');
$request->setMethod('GET');
$request->setSVG(base64_encode($svgdata));
$request->setViewportSize($new_width, $new_height);
$request->setRasterFile($dest . '/' . $filename_base . '-w' . $new_width . '.png');
$request->setWidth($new_width);
$request->setHeight($new_height);
$response = $client->getMessageFactory()->createResponse();
// send + return
$client->send($request, $response);
return true;
} | php | public static function rasterize($file, $dest, $columns, $rows) {
// check the input
if (!file_exists($file)) {
return false;
}
if (!file_exists($dest) || !is_dir($dest)) {
return false;
}
// figure out the output width and height
$svgTmp = new Respimg($file);
$width = (double) $svgTmp->getImageWidth();
$height = (double) $svgTmp->getImageHeight();
$new_width = $columns;
$new_height = $rows;
$x_factor = $columns / $width;
$y_factor = $rows / $height;
if ($rows < 1) {
$new_height = round($x_factor * $height);
} elseif ($columns < 1) {
$new_width = round($y_factor * $width);
}
// get the svg data
$svgdata = file_get_contents($file);
// figure out some path stuff
$dest = rtrim($dest, '/');
$filename = substr($file, strrpos($file, '/') + 1);
$filename_base = substr($filename, 0, strrpos($filename, '.'));
// setup the request
$client = Client::getInstance();
$serviceContainer = ServiceContainer::getInstance();
$procedureLoaderFactory = $serviceContainer->get('procedure_loader_factory');
$procedureLoader = $procedureLoaderFactory->createProcedureLoader(__DIR__);
$client->getProcedureLoader()->addLoader($procedureLoader);
$request = new RespimgCaptureRequest();
$request->setType('svg2png');
$request->setMethod('GET');
$request->setSVG(base64_encode($svgdata));
$request->setViewportSize($new_width, $new_height);
$request->setRasterFile($dest . '/' . $filename_base . '-w' . $new_width . '.png');
$request->setWidth($new_width);
$request->setHeight($new_height);
$response = $client->getMessageFactory()->createResponse();
// send + return
$client->send($request, $response);
return true;
} | [
"public",
"static",
"function",
"rasterize",
"(",
"$",
"file",
",",
"$",
"dest",
",",
"$",
"columns",
",",
"$",
"rows",
")",
"{",
"// check the input",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",... | Rasterizes an SVG image to a PNG.
Uses phantomjs to save the SVG as a PNG image at the specified size.
@access public
@param string $file The path to the file that should be rasterized.
@param string $dest The path to the directory where the output PNG should be saved.
@param integer $columns The number of columns in the output image. 0 = maintain aspect ratio based on $rows.
@param integer $rows The number of rows in the output image. 0 = maintain aspect ratio based on $columns. | [
"Rasterizes",
"an",
"SVG",
"image",
"to",
"a",
"PNG",
"."
] | 9bb067726b479ff362202529f4c98b53a53a04c1 | https://github.com/nwtn/php-respimg/blob/9bb067726b479ff362202529f4c98b53a53a04c1/src/Respimg.php#L159-L216 |
38,532 | nwtn/php-respimg | src/Respimg.php | Respimg.smartResize | public function smartResize($columns, $rows, $optim = false) {
$this->setOption('filter:support', '2.0');
$this->thumbnailImage($columns, $rows, false, false, \Imagick::FILTER_TRIANGLE);
if ($optim) {
$this->unsharpMaskImage(0.25, 0.08, 8.3, 0.045);
} else {
$this->unsharpMaskImage(0.25, 0.25, 8, 0.065);
}
$this->posterizeImage(136, false);
$this->setImageCompressionQuality(82);
$this->setOption('jpeg:fancy-upsampling', 'off');
$this->setOption('png:compression-filter', '5');
$this->setOption('png:compression-level', '9');
$this->setOption('png:compression-strategy', '1');
$this->setOption('png:exclude-chunk', 'all');
$this->setInterlaceScheme(\Imagick::INTERLACE_NO);
$this->setColorspace(\Imagick::COLORSPACE_SRGB);
if (!$optim) {
$this->stripImage();
}
} | php | public function smartResize($columns, $rows, $optim = false) {
$this->setOption('filter:support', '2.0');
$this->thumbnailImage($columns, $rows, false, false, \Imagick::FILTER_TRIANGLE);
if ($optim) {
$this->unsharpMaskImage(0.25, 0.08, 8.3, 0.045);
} else {
$this->unsharpMaskImage(0.25, 0.25, 8, 0.065);
}
$this->posterizeImage(136, false);
$this->setImageCompressionQuality(82);
$this->setOption('jpeg:fancy-upsampling', 'off');
$this->setOption('png:compression-filter', '5');
$this->setOption('png:compression-level', '9');
$this->setOption('png:compression-strategy', '1');
$this->setOption('png:exclude-chunk', 'all');
$this->setInterlaceScheme(\Imagick::INTERLACE_NO);
$this->setColorspace(\Imagick::COLORSPACE_SRGB);
if (!$optim) {
$this->stripImage();
}
} | [
"public",
"function",
"smartResize",
"(",
"$",
"columns",
",",
"$",
"rows",
",",
"$",
"optim",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"'filter:support'",
",",
"'2.0'",
")",
";",
"$",
"this",
"->",
"thumbnailImage",
"(",
"$",
"colu... | Resizes the image using smart defaults for high quality and low file size.
This function is basically equivalent to:
$optim == true: `mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB INPUT_PATH`
$optim == false: `mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2.0 -thumbnail OUTPUT_WIDTH -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip INPUT_PATH`
@access public
@param integer $columns The number of columns in the output image. 0 = maintain aspect ratio based on $rows.
@param integer $rows The number of rows in the output image. 0 = maintain aspect ratio based on $columns.
@param bool $optim Whether you intend to perform optimization on the resulting image. Note that setting this to `true` doesn’t actually perform any optimization. | [
"Resizes",
"the",
"image",
"using",
"smart",
"defaults",
"for",
"high",
"quality",
"and",
"low",
"file",
"size",
"."
] | 9bb067726b479ff362202529f4c98b53a53a04c1 | https://github.com/nwtn/php-respimg/blob/9bb067726b479ff362202529f4c98b53a53a04c1/src/Respimg.php#L235-L257 |
38,533 | stevemo/cpanel | src/Stevemo/Cpanel/Permission/Repo/PermissionRepository.php | PermissionRepository.create | public function create(array $data)
{
$perm = $this->model->create(array(
'name' => $data['name'],
'permissions' => $data['permissions']
));
if ( ! $perm )
{
return false;
}
else
{
$this->event->fire('permissions.create', array($perm));
return $perm;
}
} | php | public function create(array $data)
{
$perm = $this->model->create(array(
'name' => $data['name'],
'permissions' => $data['permissions']
));
if ( ! $perm )
{
return false;
}
else
{
$this->event->fire('permissions.create', array($perm));
return $perm;
}
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"perm",
"=",
"$",
"this",
"->",
"model",
"->",
"create",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"data",
"[",
"'name'",
"]",
",",
"'permissions'",
"=>",
"$",
"data",
"[",
"'p... | Put into storage a new permission
@author Steve Montambeault
@link http://stevemo.ca
@param array $data
@return bool|\Illuminate\Database\Eloquent\Model|\StdClass|static | [
"Put",
"into",
"storage",
"a",
"new",
"permission"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Permission/Repo/PermissionRepository.php#L61-L77 |
38,534 | stevemo/cpanel | src/Stevemo/Cpanel/Permission/Repo/PermissionRepository.php | PermissionRepository.delete | public function delete($id)
{
try
{
$perm = $this->model->findOrFail($id);
$oldData = $perm;
$perm->delete();
$this->event->fire('permissions.delete', array($oldData));
return true;
}
catch ( ModelNotFoundException $e)
{
return false;
}
} | php | public function delete($id)
{
try
{
$perm = $this->model->findOrFail($id);
$oldData = $perm;
$perm->delete();
$this->event->fire('permissions.delete', array($oldData));
return true;
}
catch ( ModelNotFoundException $e)
{
return false;
}
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"perm",
"=",
"$",
"this",
"->",
"model",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"oldData",
"=",
"$",
"perm",
";",
"$",
"perm",
"->",
"delete",
"(",
")",
";",... | Delete a permission from storage
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@return bool | [
"Delete",
"a",
"permission",
"from",
"storage"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Permission/Repo/PermissionRepository.php#L89-L104 |
38,535 | stevemo/cpanel | src/Stevemo/Cpanel/Permission/Repo/PermissionRepository.php | PermissionRepository.update | public function update(array $data)
{
$perm = $this->findOrFail($data['id']);
$perm->name = $data['name'];
$perm->permissions = $data['permissions'];
$perm->save();
$this->event->fire('permissions.update',array($perm));
return true;
} | php | public function update(array $data)
{
$perm = $this->findOrFail($data['id']);
$perm->name = $data['name'];
$perm->permissions = $data['permissions'];
$perm->save();
$this->event->fire('permissions.update',array($perm));
return true;
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"perm",
"=",
"$",
"this",
"->",
"findOrFail",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"$",
"perm",
"->",
"name",
"=",
"$",
"data",
"[",
"'name'",
"]",
";",
"$",
"pe... | Update a permission into storage
@author Steve Montambeault
@link http://stevemo.ca
@param array $data
@return bool | [
"Update",
"a",
"permission",
"into",
"storage"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Permission/Repo/PermissionRepository.php#L184-L195 |
38,536 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersPermissionsController.php | UsersPermissionsController.index | public function index($userId)
{
try
{
$user = $this->users->findById($userId);
$userPermissions = $user->getPermissions();
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
return View::make(Config::get('cpanel::views.users_permission'))
->with('user',$user)
->with('userPermissions',$userPermissions)
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions);
}
catch ( UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', $e->getMessage());
}
} | php | public function index($userId)
{
try
{
$user = $this->users->findById($userId);
$userPermissions = $user->getPermissions();
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
return View::make(Config::get('cpanel::views.users_permission'))
->with('user',$user)
->with('userPermissions',$userPermissions)
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions);
}
catch ( UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', $e->getMessage());
}
} | [
"public",
"function",
"index",
"(",
"$",
"userId",
")",
"{",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"users",
"->",
"findById",
"(",
"$",
"userId",
")",
";",
"$",
"userPermissions",
"=",
"$",
"user",
"->",
"getPermissions",
"(",
")",
";",
... | Display the user permissins
@author Steve Montambeault
@link http://stevemo.ca
@param int $userId
@return Response | [
"Display",
"the",
"user",
"permissins"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersPermissionsController.php#L40-L60 |
38,537 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersPermissionsController.php | UsersPermissionsController.update | public function update($userId)
{
try
{
$permissions = Input::get('permissions', array());
$this->users->updatePermissions($userId,$permissions);
return Redirect::route('cpanel.users.index')
->with('success', Lang::get('cpanel::users.permissions_update_success'));
}
catch ( UserNotFoundException $e)
{
return Redirect::route('cpanel.users.permissions')
->with('error', $e->getMessage());
}
} | php | public function update($userId)
{
try
{
$permissions = Input::get('permissions', array());
$this->users->updatePermissions($userId,$permissions);
return Redirect::route('cpanel.users.index')
->with('success', Lang::get('cpanel::users.permissions_update_success'));
}
catch ( UserNotFoundException $e)
{
return Redirect::route('cpanel.users.permissions')
->with('error', $e->getMessage());
}
} | [
"public",
"function",
"update",
"(",
"$",
"userId",
")",
"{",
"try",
"{",
"$",
"permissions",
"=",
"Input",
"::",
"get",
"(",
"'permissions'",
",",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"users",
"->",
"updatePermissions",
"(",
"$",
"userId",
... | Update user permissions
@author Steve Montambeault
@link http://stevemo.ca
@param int $userId
@return Response | [
"Update",
"user",
"permissions"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersPermissionsController.php#L71-L87 |
38,538 | jkoudys/immutable.php | src/Iterator/ConcatIterator.php | ConcatIterator.getIteratorByIndex | protected function getIteratorByIndex($index = 0)
{
$runningCount = 0;
foreach ($this->getArrayIterator() as $innerIt) {
$count = count($innerIt);
if ($index < $runningCount + $count) {
return [$innerIt, $index - $runningCount];
}
$runningCount += $count;
}
return null;
} | php | protected function getIteratorByIndex($index = 0)
{
$runningCount = 0;
foreach ($this->getArrayIterator() as $innerIt) {
$count = count($innerIt);
if ($index < $runningCount + $count) {
return [$innerIt, $index - $runningCount];
}
$runningCount += $count;
}
return null;
} | [
"protected",
"function",
"getIteratorByIndex",
"(",
"$",
"index",
"=",
"0",
")",
"{",
"$",
"runningCount",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getArrayIterator",
"(",
")",
"as",
"$",
"innerIt",
")",
"{",
"$",
"count",
"=",
"count",
"(",
... | Find which of the inner iterators an index corresponds to
@param int $index
@return [ArrayAccess, int] The iterator and interior index | [
"Find",
"which",
"of",
"the",
"inner",
"iterators",
"an",
"index",
"corresponds",
"to"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Iterator/ConcatIterator.php#L114-L126 |
38,539 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/PasswordController.php | PasswordController.postForgot | public function postForgot()
{
try
{
$email = Input::get('email');
$this->passForm->forgot($email);
return View::make(Config::get('cpanel::views.password_send'))
->with('email', $email);
}
catch (UserNotFoundException $e)
{
return Redirect::back()
->with('password_error', $e->getMessage());
}
} | php | public function postForgot()
{
try
{
$email = Input::get('email');
$this->passForm->forgot($email);
return View::make(Config::get('cpanel::views.password_send'))
->with('email', $email);
}
catch (UserNotFoundException $e)
{
return Redirect::back()
->with('password_error', $e->getMessage());
}
} | [
"public",
"function",
"postForgot",
"(",
")",
"{",
"try",
"{",
"$",
"email",
"=",
"Input",
"::",
"get",
"(",
"'email'",
")",
";",
"$",
"this",
"->",
"passForm",
"->",
"forgot",
"(",
"$",
"email",
")",
";",
"return",
"View",
"::",
"make",
"(",
"Conf... | Find the user and send a email with the reset code
@author Steve Montambeault
@link http://stevemo.ca
@return \Illuminate\Http\RedirectResponse|\Illuminate\View\View | [
"Find",
"the",
"user",
"and",
"send",
"a",
"email",
"with",
"the",
"reset",
"code"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/PasswordController.php#L51-L65 |
38,540 | stevemo/cpanel | src/Stevemo/Cpanel/Permission/Form/PermissionForm.php | PermissionForm.create | public function create(array $data)
{
if ( $this->validator->with($data)->passes() )
{
$data['permissions'] = explode(',', $data['permissions']);
$this->permission->create($data);
return true;
}
else
{
return false;
}
} | php | public function create(array $data)
{
if ( $this->validator->with($data)->passes() )
{
$data['permissions'] = explode(',', $data['permissions']);
$this->permission->create($data);
return true;
}
else
{
return false;
}
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validator",
"->",
"with",
"(",
"$",
"data",
")",
"->",
"passes",
"(",
")",
")",
"{",
"$",
"data",
"[",
"'permissions'",
"]",
"=",
"explode",
"(",
... | Create a new set of permissions
@author Steve Montambeault
@link http://stevemo.ca
@param array $data
@return \StdClass | [
"Create",
"a",
"new",
"set",
"of",
"permissions"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Permission/Form/PermissionForm.php#L38-L50 |
38,541 | stevemo/cpanel | src/Stevemo/Cpanel/Permission/Form/PermissionForm.php | PermissionForm.update | public function update(array $data)
{
if ( $this->validator->with($data)->validForUpdate() )
{
$data['permissions'] = explode(',', $data['permissions']);
$this->permission->update($data);
return true;
}
else
{
return false;
}
} | php | public function update(array $data)
{
if ( $this->validator->with($data)->validForUpdate() )
{
$data['permissions'] = explode(',', $data['permissions']);
$this->permission->update($data);
return true;
}
else
{
return false;
}
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validator",
"->",
"with",
"(",
"$",
"data",
")",
"->",
"validForUpdate",
"(",
")",
")",
"{",
"$",
"data",
"[",
"'permissions'",
"]",
"=",
"explode",
... | Update a current set of permissions
@author Steve Montambeault
@link http://stevemo.ca
@param array $data
@return \StdClass | [
"Update",
"a",
"current",
"set",
"of",
"permissions"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Permission/Form/PermissionForm.php#L62-L74 |
38,542 | stevemo/cpanel | src/Stevemo/Cpanel/User/Repo/UserRepository.php | UserRepository.deactivate | public function deactivate($id)
{
$user = $this->findById($id);
$user->activated = 0;
$user->activated_at = null;
$user->save();
$this->event->fire('users.deactivate',array($user));
return true;
} | php | public function deactivate($id)
{
$user = $this->findById($id);
$user->activated = 0;
$user->activated_at = null;
$user->save();
$this->event->fire('users.deactivate',array($user));
return true;
} | [
"public",
"function",
"deactivate",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"findById",
"(",
"$",
"id",
")",
";",
"$",
"user",
"->",
"activated",
"=",
"0",
";",
"$",
"user",
"->",
"activated_at",
"=",
"null",
";",
"$",
"use... | De activate a user
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@return bool | [
"De",
"activate",
"a",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Repo/UserRepository.php#L120-L128 |
38,543 | stevemo/cpanel | src/Stevemo/Cpanel/User/Repo/UserRepository.php | UserRepository.delete | public function delete($id)
{
$user = $this->findById($id);
$eventData = $user;
$user->delete();
$this->event->fire('users.delete', array($eventData));
} | php | public function delete($id)
{
$user = $this->findById($id);
$eventData = $user;
$user->delete();
$this->event->fire('users.delete', array($eventData));
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"findById",
"(",
"$",
"id",
")",
";",
"$",
"eventData",
"=",
"$",
"user",
";",
"$",
"user",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"event"... | Delete the user
@author Steve Montambeault
@link http://stevemo.ca
@param int $id
@return void | [
"Delete",
"the",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Repo/UserRepository.php#L140-L146 |
38,544 | stevemo/cpanel | src/Stevemo/Cpanel/User/Repo/UserRepository.php | UserRepository.findByLogin | public function findByLogin($login)
{
try
{
return $this->sentry->findUserByLogin($login);
}
catch (SentryUserNotFoundException $e)
{
throw new UserNotFoundException($e->getMessage());
}
} | php | public function findByLogin($login)
{
try
{
return $this->sentry->findUserByLogin($login);
}
catch (SentryUserNotFoundException $e)
{
throw new UserNotFoundException($e->getMessage());
}
} | [
"public",
"function",
"findByLogin",
"(",
"$",
"login",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"sentry",
"->",
"findUserByLogin",
"(",
"$",
"login",
")",
";",
"}",
"catch",
"(",
"SentryUserNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new... | Find a given user by the login attribute
@author Steve Montambeault
@link http://stevemo.ca
@param $login
@throws UserNotFoundException
@return \Cartalyst\Sentry\Users\UserInterface | [
"Find",
"a",
"given",
"user",
"by",
"the",
"login",
"attribute"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Repo/UserRepository.php#L196-L206 |
38,545 | stevemo/cpanel | src/Stevemo/Cpanel/User/Repo/UserRepository.php | UserRepository.getUserThrottle | public function getUserThrottle($id)
{
try
{
return $this->sentry->findThrottlerByUserId($id);
}
catch (SentryUserNotFoundException $e)
{
throw new UserNotFoundException($e->getMessage());
}
} | php | public function getUserThrottle($id)
{
try
{
return $this->sentry->findThrottlerByUserId($id);
}
catch (SentryUserNotFoundException $e)
{
throw new UserNotFoundException($e->getMessage());
}
} | [
"public",
"function",
"getUserThrottle",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"sentry",
"->",
"findThrottlerByUserId",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"SentryUserNotFoundException",
"$",
"e",
")",
"{",
"throw",
... | Get the throttle provider for a given user
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@throws UserNotFoundException
@return \Cartalyst\Sentry\Throttling\ThrottleInterface | [
"Get",
"the",
"throttle",
"provider",
"for",
"a",
"given",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Repo/UserRepository.php#L248-L258 |
38,546 | stevemo/cpanel | src/Stevemo/Cpanel/User/Repo/UserRepository.php | UserRepository.updatePermissions | public function updatePermissions($id, array $permissions)
{
$user = $this->findById($id);
$user->permissions = $permissions;
$user->save();
$this->event->fire('users.permissions.update',array($user));
return $user;
} | php | public function updatePermissions($id, array $permissions)
{
$user = $this->findById($id);
$user->permissions = $permissions;
$user->save();
$this->event->fire('users.permissions.update',array($user));
return $user;
} | [
"public",
"function",
"updatePermissions",
"(",
"$",
"id",
",",
"array",
"$",
"permissions",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"findById",
"(",
"$",
"id",
")",
";",
"$",
"user",
"->",
"permissions",
"=",
"$",
"permissions",
";",
"$",
"us... | Update permissions for a given user
@author Steve Montambeault
@link http://stevemo.ca
@param int $id
@param array $permissions
@return \Cartalyst\Sentry\Users\UserInterface | [
"Update",
"permissions",
"for",
"a",
"given",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Repo/UserRepository.php#L371-L378 |
38,547 | stevemo/cpanel | src/Stevemo/Cpanel/User/Repo/UserRepository.php | UserRepository.storeUser | protected function storeUser(array $credentials, $activate = false)
{
$cred = array(
'first_name' => $credentials['first_name'],
'last_name' => $credentials['last_name'],
'email' => $credentials['email'],
'password' => $credentials['password'],
);
if ( array_key_exists('permissions',$credentials) )
{
$cred['permissions'] = $credentials['permissions'];
}
$user = $this->sentry->register($cred,$activate);
if ( array_key_exists('groups',$credentials) )
{
$this->syncGroups($credentials['groups'], $user);
}
return $user;
} | php | protected function storeUser(array $credentials, $activate = false)
{
$cred = array(
'first_name' => $credentials['first_name'],
'last_name' => $credentials['last_name'],
'email' => $credentials['email'],
'password' => $credentials['password'],
);
if ( array_key_exists('permissions',$credentials) )
{
$cred['permissions'] = $credentials['permissions'];
}
$user = $this->sentry->register($cred,$activate);
if ( array_key_exists('groups',$credentials) )
{
$this->syncGroups($credentials['groups'], $user);
}
return $user;
} | [
"protected",
"function",
"storeUser",
"(",
"array",
"$",
"credentials",
",",
"$",
"activate",
"=",
"false",
")",
"{",
"$",
"cred",
"=",
"array",
"(",
"'first_name'",
"=>",
"$",
"credentials",
"[",
"'first_name'",
"]",
",",
"'last_name'",
"=>",
"$",
"creden... | Create user into storage
@author Steve Montambeault
@link http://stevemo.ca
@param array $credentials
@param bool $activate
@return \Cartalyst\Sentry\Users\UserInterface | [
"Create",
"user",
"into",
"storage"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Repo/UserRepository.php#L412-L434 |
38,548 | stevemo/cpanel | src/Stevemo/Cpanel/User/Repo/UserRepository.php | UserRepository.syncGroups | protected function syncGroups(array $groups, UserInterface $user)
{
$user->groups()->detach();
$user->groups()->sync($groups);
} | php | protected function syncGroups(array $groups, UserInterface $user)
{
$user->groups()->detach();
$user->groups()->sync($groups);
} | [
"protected",
"function",
"syncGroups",
"(",
"array",
"$",
"groups",
",",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"user",
"->",
"groups",
"(",
")",
"->",
"detach",
"(",
")",
";",
"$",
"user",
"->",
"groups",
"(",
")",
"->",
"sync",
"(",
"$",
"g... | Add groups to a user
@author Steve Montambeault
@link http://stevemo.ca
@param array $groups
@param \Cartalyst\Sentry\Users\UserInterface $user | [
"Add",
"groups",
"to",
"a",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Repo/UserRepository.php#L445-L449 |
38,549 | stevemo/cpanel | src/Stevemo/Cpanel/Permission/Repo/Permission.php | Permission.getRules | public function getRules()
{
$perm = $this->permissions;
$data = array();
foreach ($perm as $val)
{
list($prefix,$data[]) = explode('.', $val);
}
return implode(',',$data);
} | php | public function getRules()
{
$perm = $this->permissions;
$data = array();
foreach ($perm as $val)
{
list($prefix,$data[]) = explode('.', $val);
}
return implode(',',$data);
} | [
"public",
"function",
"getRules",
"(",
")",
"{",
"$",
"perm",
"=",
"$",
"this",
"->",
"permissions",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"perm",
"as",
"$",
"val",
")",
"{",
"list",
"(",
"$",
"prefix",
",",
"$",
"... | convert permissions into a comma separated string and remove the prefix
@author Steve Montambeault
@link http://stevemo.ca
@return string | [
"convert",
"permissions",
"into",
"a",
"comma",
"separated",
"string",
"and",
"remove",
"the",
"prefix"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Permission/Repo/Permission.php#L69-L80 |
38,550 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.map | public function map(callable $cb)
{
$count = count($this);
$sfa = new SplFixedArray($count);
for ($i = 0; $i < $count; $i++) {
$sfa[$i] = $cb($this->sfa[$i], $i, $this);
}
return new static($sfa);
} | php | public function map(callable $cb)
{
$count = count($this);
$sfa = new SplFixedArray($count);
for ($i = 0; $i < $count; $i++) {
$sfa[$i] = $cb($this->sfa[$i], $i, $this);
}
return new static($sfa);
} | [
"public",
"function",
"map",
"(",
"callable",
"$",
"cb",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
")",
";",
"$",
"sfa",
"=",
"new",
"SplFixedArray",
"(",
"$",
"count",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<... | Map elements to a new ImmArray via a callback
@param callable $cb Function to map new data
@return static | [
"Map",
"elements",
"to",
"a",
"new",
"ImmArray",
"via",
"a",
"callback"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L50-L58 |
38,551 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.walk | public function walk(callable $cb)
{
foreach ($this as $i => $el) {
$cb($el, $i, $this);
}
return $this;
} | php | public function walk(callable $cb)
{
foreach ($this as $i => $el) {
$cb($el, $i, $this);
}
return $this;
} | [
"public",
"function",
"walk",
"(",
"callable",
"$",
"cb",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"i",
"=>",
"$",
"el",
")",
"{",
"$",
"cb",
"(",
"$",
"el",
",",
"$",
"i",
",",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";... | forEach, or "walk" the data
Exists primarily to provide a consistent interface, though it's seldom
any better than a simple php foreach. Mainly useful for chaining.
Named walk for historic reasons - forEach is reserved in PHP
@param callable $cb Function to call on each element
@return static | [
"forEach",
"or",
"walk",
"the",
"data",
"Exists",
"primarily",
"to",
"provide",
"a",
"consistent",
"interface",
"though",
"it",
"s",
"seldom",
"any",
"better",
"than",
"a",
"simple",
"php",
"foreach",
".",
"Mainly",
"useful",
"for",
"chaining",
".",
"Named",... | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L69-L75 |
38,552 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.filter | public function filter(callable $cb)
{
$count = count($this->sfa);
$sfa = new SplFixedArray($count);
$newCount = 0;
foreach ($this->sfa as $el) {
if ($cb($el)) {
$sfa[$newCount++] = $el;
}
}
$sfa->setSize($newCount);
return new static($sfa);
} | php | public function filter(callable $cb)
{
$count = count($this->sfa);
$sfa = new SplFixedArray($count);
$newCount = 0;
foreach ($this->sfa as $el) {
if ($cb($el)) {
$sfa[$newCount++] = $el;
}
}
$sfa->setSize($newCount);
return new static($sfa);
} | [
"public",
"function",
"filter",
"(",
"callable",
"$",
"cb",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"sfa",
")",
";",
"$",
"sfa",
"=",
"new",
"SplFixedArray",
"(",
"$",
"count",
")",
";",
"$",
"newCount",
"=",
"0",
";",
"fore... | Filter out elements
@param callable $cb Function to filter out on false
@return static | [
"Filter",
"out",
"elements"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L83-L97 |
38,553 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.reduce | public function reduce(callable $cb, $initial = null)
{
foreach ($this->sfa as $i => $el) {
$initial = $cb($initial, $el, $i, $this);
}
return $initial;
} | php | public function reduce(callable $cb, $initial = null)
{
foreach ($this->sfa as $i => $el) {
$initial = $cb($initial, $el, $i, $this);
}
return $initial;
} | [
"public",
"function",
"reduce",
"(",
"callable",
"$",
"cb",
",",
"$",
"initial",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sfa",
"as",
"$",
"i",
"=>",
"$",
"el",
")",
"{",
"$",
"initial",
"=",
"$",
"cb",
"(",
"$",
"initial",
",... | Reduce to a single value
@param callable $cb Callback(
mixed $previous, mixed $current[, mixed $index, mixed $immArray]
):mixed Callback to run reducing function
@param mixed $initial Initial value for first argument | [
"Reduce",
"to",
"a",
"single",
"value"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L107-L113 |
38,554 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.join | public function join($token = ',', $secondToken = null)
{
$ret = '';
if ($secondToken) {
foreach ($this as $el) {
$ret .= $token . $el . $secondToken;
}
} else {
$this->rewind();
while ($this->valid()) {
$ret .= (string) $this->current();
$this->next();
if ($this->valid()) {
$ret .= $token;
}
}
}
return $ret;
} | php | public function join($token = ',', $secondToken = null)
{
$ret = '';
if ($secondToken) {
foreach ($this as $el) {
$ret .= $token . $el . $secondToken;
}
} else {
$this->rewind();
while ($this->valid()) {
$ret .= (string) $this->current();
$this->next();
if ($this->valid()) {
$ret .= $token;
}
}
}
return $ret;
} | [
"public",
"function",
"join",
"(",
"$",
"token",
"=",
"','",
",",
"$",
"secondToken",
"=",
"null",
")",
"{",
"$",
"ret",
"=",
"''",
";",
"if",
"(",
"$",
"secondToken",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"el",
")",
"{",
"$",
"ret"... | Join a set of strings together.
@param string $token Main token to put between elements
@param string $secondToken If set, $token on left $secondToken on right
@return string | [
"Join",
"a",
"set",
"of",
"strings",
"together",
"."
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L122-L140 |
38,555 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.slice | public function slice($begin = 0, $end = null)
{
$it = new SliceIterator($this->sfa, $begin, $end);
return new static($it);
} | php | public function slice($begin = 0, $end = null)
{
$it = new SliceIterator($this->sfa, $begin, $end);
return new static($it);
} | [
"public",
"function",
"slice",
"(",
"$",
"begin",
"=",
"0",
",",
"$",
"end",
"=",
"null",
")",
"{",
"$",
"it",
"=",
"new",
"SliceIterator",
"(",
"$",
"this",
"->",
"sfa",
",",
"$",
"begin",
",",
"$",
"end",
")",
";",
"return",
"new",
"static",
... | Take a slice of the array
@param int $begin Start index of slice
@param int $end End index of slice
@return static | [
"Take",
"a",
"slice",
"of",
"the",
"array"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L149-L153 |
38,556 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.concat | public function concat()
{
$args = func_get_args();
array_unshift($args, $this->sfa);
// Concat this iterator, and variadic args
$class = new ReflectionClass('Qaribou\Iterator\ConcatIterator');
$concatIt = $class->newInstanceArgs($args);
// Create as new immutable's iterator
return new static($concatIt);
} | php | public function concat()
{
$args = func_get_args();
array_unshift($args, $this->sfa);
// Concat this iterator, and variadic args
$class = new ReflectionClass('Qaribou\Iterator\ConcatIterator');
$concatIt = $class->newInstanceArgs($args);
// Create as new immutable's iterator
return new static($concatIt);
} | [
"public",
"function",
"concat",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"this",
"->",
"sfa",
")",
";",
"// Concat this iterator, and variadic args",
"$",
"class",
"=",
"new",
"ReflectionCl... | Concat to the end of this array
@param Traversable,...
@return static | [
"Concat",
"to",
"the",
"end",
"of",
"this",
"array"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L161-L172 |
38,557 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.find | public function find(callable $cb)
{
foreach ($this->sfa as $i => $el) {
if ($cb($el, $i, $this)) return $el;
}
} | php | public function find(callable $cb)
{
foreach ($this->sfa as $i => $el) {
if ($cb($el, $i, $this)) return $el;
}
} | [
"public",
"function",
"find",
"(",
"callable",
"$",
"cb",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sfa",
"as",
"$",
"i",
"=>",
"$",
"el",
")",
"{",
"if",
"(",
"$",
"cb",
"(",
"$",
"el",
",",
"$",
"i",
",",
"$",
"this",
")",
")",
"retur... | Find a single element
@param callable $cb The test to run on each element
@return mixed The element we found | [
"Find",
"a",
"single",
"element"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L180-L185 |
38,558 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.sort | public function sort(callable $cb = null)
{
if ($cb) {
// Custom searches can be easier on memory, but run absurdly slow
// pre PHP7
if (PHP_MAJOR_VERSION < 7) {
return $this->arraySort($cb);
}
return $this->mergeSort($cb);
}
return $this->arraySort();
} | php | public function sort(callable $cb = null)
{
if ($cb) {
// Custom searches can be easier on memory, but run absurdly slow
// pre PHP7
if (PHP_MAJOR_VERSION < 7) {
return $this->arraySort($cb);
}
return $this->mergeSort($cb);
}
return $this->arraySort();
} | [
"public",
"function",
"sort",
"(",
"callable",
"$",
"cb",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cb",
")",
"{",
"// Custom searches can be easier on memory, but run absurdly slow",
"// pre PHP7",
"if",
"(",
"PHP_MAJOR_VERSION",
"<",
"7",
")",
"{",
"return",
"$"... | Return a new sorted ImmArray
@param callable $cb The sort callback
@return static | [
"Return",
"a",
"new",
"sorted",
"ImmArray"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L193-L204 |
38,559 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.sortHeap | public function sortHeap(SplHeap $heap)
{
foreach ($this as $item) {
$heap->insert($item);
}
return static::fromItems($heap);
} | php | public function sortHeap(SplHeap $heap)
{
foreach ($this as $item) {
$heap->insert($item);
}
return static::fromItems($heap);
} | [
"public",
"function",
"sortHeap",
"(",
"SplHeap",
"$",
"heap",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"item",
")",
"{",
"$",
"heap",
"->",
"insert",
"(",
"$",
"item",
")",
";",
"}",
"return",
"static",
"::",
"fromItems",
"(",
"$",
"heap"... | Sort a new ImmArray by filtering through a heap.
Tends to run much faster than array or merge sorts, since you're only
sorting the pointers, and the sort function is running in a highly
optimized space.
@param SplHeap $heap The heap to run for sorting
@return static | [
"Sort",
"a",
"new",
"ImmArray",
"by",
"filtering",
"through",
"a",
"heap",
".",
"Tends",
"to",
"run",
"much",
"faster",
"than",
"array",
"or",
"merge",
"sorts",
"since",
"you",
"re",
"only",
"sorting",
"the",
"pointers",
"and",
"the",
"sort",
"function",
... | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L215-L221 |
38,560 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.fromItems | public static function fromItems(Traversable $arr, callable $cb = null)
{
// We can only do it this way if we can count it
if ($arr instanceof Countable) {
$sfa = new SplFixedArray(count($arr));
foreach ($arr as $i => $el) {
// Apply a mapping function if available
if ($cb) $sfa[$i] = $cb($el, $i);
else $sfa[$i] = $el;
}
return new static($sfa);
}
// If we can't count it, it's simplest to iterate into an array first
$asArray = iterator_to_array($arr);
if ($cb) {
return static::fromArray(array_map($cb, $asArray, array_keys($asArray)));
}
return static::fromArray($asArray);
} | php | public static function fromItems(Traversable $arr, callable $cb = null)
{
// We can only do it this way if we can count it
if ($arr instanceof Countable) {
$sfa = new SplFixedArray(count($arr));
foreach ($arr as $i => $el) {
// Apply a mapping function if available
if ($cb) $sfa[$i] = $cb($el, $i);
else $sfa[$i] = $el;
}
return new static($sfa);
}
// If we can't count it, it's simplest to iterate into an array first
$asArray = iterator_to_array($arr);
if ($cb) {
return static::fromArray(array_map($cb, $asArray, array_keys($asArray)));
}
return static::fromArray($asArray);
} | [
"public",
"static",
"function",
"fromItems",
"(",
"Traversable",
"$",
"arr",
",",
"callable",
"$",
"cb",
"=",
"null",
")",
"{",
"// We can only do it this way if we can count it",
"if",
"(",
"$",
"arr",
"instanceof",
"Countable",
")",
"{",
"$",
"sfa",
"=",
"ne... | Factory for building ImmArrays from any traversable
@return static | [
"Factory",
"for",
"building",
"ImmArrays",
"from",
"any",
"traversable"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L228-L248 |
38,561 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.mergeSort | protected function mergeSort(callable $cb)
{
$count = count($this);
$sfa = $this->sfa;
$result = new SplFixedArray($count);
for ($k = 1; $k < $count; $k = $k << 1) {
for ($left = 0; ($left + $k) < $count; $left += $k << 1) {
$right = $left + $k;
$rend = min($right + $k, $count);
$m = $left;
$i = $left;
$j = $right;
while ($i < $right && $j < $rend) {
if ($cb($sfa[$i], $sfa[$j]) <= 0) {
$result[$m] = $sfa[$i];
$i++;
} else {
$result[$m] = $sfa[$j];
$j++;
}
$m++;
}
while ($i < $right) {
$result[$m] = $sfa[$i];
$i++;
$m++;
}
while ($j < $rend) {
$result[$m] = $sfa[$j];
$j++;
$m++;
}
for ($m = $left; $m < $rend; $m++) {
$sfa[$m] = $result[$m];
}
}
}
return new static($sfa);
} | php | protected function mergeSort(callable $cb)
{
$count = count($this);
$sfa = $this->sfa;
$result = new SplFixedArray($count);
for ($k = 1; $k < $count; $k = $k << 1) {
for ($left = 0; ($left + $k) < $count; $left += $k << 1) {
$right = $left + $k;
$rend = min($right + $k, $count);
$m = $left;
$i = $left;
$j = $right;
while ($i < $right && $j < $rend) {
if ($cb($sfa[$i], $sfa[$j]) <= 0) {
$result[$m] = $sfa[$i];
$i++;
} else {
$result[$m] = $sfa[$j];
$j++;
}
$m++;
}
while ($i < $right) {
$result[$m] = $sfa[$i];
$i++;
$m++;
}
while ($j < $rend) {
$result[$m] = $sfa[$j];
$j++;
$m++;
}
for ($m = $left; $m < $rend; $m++) {
$sfa[$m] = $result[$m];
}
}
}
return new static($sfa);
} | [
"protected",
"function",
"mergeSort",
"(",
"callable",
"$",
"cb",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
")",
";",
"$",
"sfa",
"=",
"$",
"this",
"->",
"sfa",
";",
"$",
"result",
"=",
"new",
"SplFixedArray",
"(",
"$",
"count",
")",
... | Perform a bottom-up, non-recursive, in-place mergesort.
Efficient for very-large objects, and written without recursion
since PHP isn't well optimized for large recursion stacks.
@param callable $cb The callback for comparison
@return static | [
"Perform",
"a",
"bottom",
"-",
"up",
"non",
"-",
"recursive",
"in",
"-",
"place",
"mergesort",
".",
"Efficient",
"for",
"very",
"-",
"large",
"objects",
"and",
"written",
"without",
"recursion",
"since",
"PHP",
"isn",
"t",
"well",
"optimized",
"for",
"larg... | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L340-L379 |
38,562 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.quickSort | protected function quickSort(callable $cb)
{
$sfa = new SplFixedArray(count($this));
// Create an auxiliary stack
$stack = new SplStack();
// initialize top of stack
// push initial values of l and h to stack
$stack->push([0, count($sfa) - 1]);
$first = true;
// Keep popping from stack while is not empty
while (!$stack->isEmpty()) {
// Pop h and l
list($lo, $hi) = $stack->pop();
if ($first) {
// Start our partition iterator on the original data
$partition = new LimitIterator($this->sfa, $lo, $hi - $lo);
} else {
$partition = new LimitIterator($sfa, $lo, $hi - $lo);
}
$ii = $partition->getInnerIterator();
// Set pivot element at its correct position in sorted array
$x = $ii[$hi];
$i = ($lo - 1);
foreach ($partition as $j => $el) {
if ($cb($ii[$j], $x) <= 0) {
// Bump up the index of the last low hit, and swap
$i++;
$temp = $sfa[$i];
$sfa[$i] = $el;
$sfa[$j] = $temp;
} elseif ($first) {
$sfa[$j] = $el;
}
}
$sfa[$hi] = $x;
// Set the pivot element
$pivot = $i + 1;
// Swap the last hi with the second-last hi
$sfa[$hi] = $sfa[$pivot];
$sfa[$pivot] = $x;
// If there are elements on left side of pivot, then push left
// side to stack
if ($pivot - 1 > $lo) {
$stack->push([$lo, $pivot - 1]);
}
// If there are elements on right side of pivot, then push right
// side to stack
if ($pivot + 1 < $hi) {
$stack->push([$pivot + 1, $hi]);
}
}
return new static($sfa);
} | php | protected function quickSort(callable $cb)
{
$sfa = new SplFixedArray(count($this));
// Create an auxiliary stack
$stack = new SplStack();
// initialize top of stack
// push initial values of l and h to stack
$stack->push([0, count($sfa) - 1]);
$first = true;
// Keep popping from stack while is not empty
while (!$stack->isEmpty()) {
// Pop h and l
list($lo, $hi) = $stack->pop();
if ($first) {
// Start our partition iterator on the original data
$partition = new LimitIterator($this->sfa, $lo, $hi - $lo);
} else {
$partition = new LimitIterator($sfa, $lo, $hi - $lo);
}
$ii = $partition->getInnerIterator();
// Set pivot element at its correct position in sorted array
$x = $ii[$hi];
$i = ($lo - 1);
foreach ($partition as $j => $el) {
if ($cb($ii[$j], $x) <= 0) {
// Bump up the index of the last low hit, and swap
$i++;
$temp = $sfa[$i];
$sfa[$i] = $el;
$sfa[$j] = $temp;
} elseif ($first) {
$sfa[$j] = $el;
}
}
$sfa[$hi] = $x;
// Set the pivot element
$pivot = $i + 1;
// Swap the last hi with the second-last hi
$sfa[$hi] = $sfa[$pivot];
$sfa[$pivot] = $x;
// If there are elements on left side of pivot, then push left
// side to stack
if ($pivot - 1 > $lo) {
$stack->push([$lo, $pivot - 1]);
}
// If there are elements on right side of pivot, then push right
// side to stack
if ($pivot + 1 < $hi) {
$stack->push([$pivot + 1, $hi]);
}
}
return new static($sfa);
} | [
"protected",
"function",
"quickSort",
"(",
"callable",
"$",
"cb",
")",
"{",
"$",
"sfa",
"=",
"new",
"SplFixedArray",
"(",
"count",
"(",
"$",
"this",
")",
")",
";",
"// Create an auxiliary stack",
"$",
"stack",
"=",
"new",
"SplStack",
"(",
")",
";",
"// i... | A classic quickSort - great for inplace sorting a big fixed array
@param callable $cb The callback for comparison
@return static | [
"A",
"classic",
"quickSort",
"-",
"great",
"for",
"inplace",
"sorting",
"a",
"big",
"fixed",
"array"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L387-L449 |
38,563 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.heapSort | protected function heapSort(callable $cb)
{
$h = new CallbackHeap($cb);
foreach ($this as $el) {
$h->insert($el);
}
return static::fromItems($h);
} | php | protected function heapSort(callable $cb)
{
$h = new CallbackHeap($cb);
foreach ($this as $el) {
$h->insert($el);
}
return static::fromItems($h);
} | [
"protected",
"function",
"heapSort",
"(",
"callable",
"$",
"cb",
")",
"{",
"$",
"h",
"=",
"new",
"CallbackHeap",
"(",
"$",
"cb",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"el",
")",
"{",
"$",
"h",
"->",
"insert",
"(",
"$",
"el",
")",
";... | Sort by applying a CallbackHeap and building a new heap
Can be efficient for sorting large stored objects.
@param callable $cb The comparison callback
@return static | [
"Sort",
"by",
"applying",
"a",
"CallbackHeap",
"and",
"building",
"a",
"new",
"heap",
"Can",
"be",
"efficient",
"for",
"sorting",
"large",
"stored",
"objects",
"."
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L458-L466 |
38,564 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.arraySort | protected function arraySort(callable $cb = null)
{
$ar = $this->toArray();
if ($cb) {
usort($ar, $cb);
} else {
sort($ar);
}
return static::fromArray($ar);
} | php | protected function arraySort(callable $cb = null)
{
$ar = $this->toArray();
if ($cb) {
usort($ar, $cb);
} else {
sort($ar);
}
return static::fromArray($ar);
} | [
"protected",
"function",
"arraySort",
"(",
"callable",
"$",
"cb",
"=",
"null",
")",
"{",
"$",
"ar",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"$",
"cb",
")",
"{",
"usort",
"(",
"$",
"ar",
",",
"$",
"cb",
")",
";",
"}",
"els... | Fallback behaviour to use the builtin array sort functions
@param callable $cb The callback for comparison
@return static | [
"Fallback",
"behaviour",
"to",
"use",
"the",
"builtin",
"array",
"sort",
"functions"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L474-L483 |
38,565 | jkoudys/immutable.php | src/Collection/ImmArray.php | ImmArray.unique | public function unique()
{
$count = count($this->sfa);
$unique = new SplFixedArray($count);
$newCount = 0;
$lastUnique = null;
foreach ($this->sfa as $el) {
for($i = $newCount; $i >= 0; $i--) {
// going from back to forward to find sequence of duplicates faster
if ($unique[$i] === $el) {
continue 2;
}
}
$unique[$newCount++] = $el;
}
$unique->setSize($newCount);
return new static($unique);
} | php | public function unique()
{
$count = count($this->sfa);
$unique = new SplFixedArray($count);
$newCount = 0;
$lastUnique = null;
foreach ($this->sfa as $el) {
for($i = $newCount; $i >= 0; $i--) {
// going from back to forward to find sequence of duplicates faster
if ($unique[$i] === $el) {
continue 2;
}
}
$unique[$newCount++] = $el;
}
$unique->setSize($newCount);
return new static($unique);
} | [
"public",
"function",
"unique",
"(",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"sfa",
")",
";",
"$",
"unique",
"=",
"new",
"SplFixedArray",
"(",
"$",
"count",
")",
";",
"$",
"newCount",
"=",
"0",
";",
"$",
"lastUnique",
"=",
"... | Filter out non-unique elements
@return static | [
"Filter",
"out",
"non",
"-",
"unique",
"elements"
] | 5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e | https://github.com/jkoudys/immutable.php/blob/5a605a5bf3e2da3ce8ff55bc2790ca9c25ce4c1e/src/Collection/ImmArray.php#L504-L523 |
38,566 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/GroupsController.php | GroupsController.index | public function index()
{
$groups = $this->groups->findAll();
return View::make(Config::get('cpanel::views.groups_index'), compact('groups'));
} | php | public function index()
{
$groups = $this->groups->findAll();
return View::make(Config::get('cpanel::views.groups_index'), compact('groups'));
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"groups",
"->",
"findAll",
"(",
")",
";",
"return",
"View",
"::",
"make",
"(",
"Config",
"::",
"get",
"(",
"'cpanel::views.groups_index'",
")",
",",
"compact",
"(",
"'... | Display all the groups
@author Steve Montambeault
@link http://stevemo.ca
@return \Illuminate\View\View | [
"Display",
"all",
"the",
"groups"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/GroupsController.php#L51-L55 |
38,567 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/GroupsController.php | GroupsController.create | public function create()
{
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
$groupPermissions = array();
return View::make(Config::get('cpanel::views.groups_create'))
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions)
->with('groupPermissions',$groupPermissions);
} | php | public function create()
{
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
$groupPermissions = array();
return View::make(Config::get('cpanel::views.groups_create'))
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions)
->with('groupPermissions',$groupPermissions);
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"genericPermissions",
"=",
"$",
"this",
"->",
"permissions",
"->",
"generic",
"(",
")",
";",
"$",
"modulePermissions",
"=",
"$",
"this",
"->",
"permissions",
"->",
"module",
"(",
")",
";",
"$",
"groupPe... | Display create a new group form
@author Steve Montambeault
@link http://stevemo.ca
@return \Illuminate\View\View | [
"Display",
"create",
"a",
"new",
"group",
"form"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/GroupsController.php#L65-L75 |
38,568 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersController.php | UsersController.index | public function index()
{
$users = $this->users->findAll();
return View::make(Config::get('cpanel::views.users_index'))
->with('users',$users);
} | php | public function index()
{
$users = $this->users->findAll();
return View::make(Config::get('cpanel::views.users_index'))
->with('users',$users);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"users",
"=",
"$",
"this",
"->",
"users",
"->",
"findAll",
"(",
")",
";",
"return",
"View",
"::",
"make",
"(",
"Config",
"::",
"get",
"(",
"'cpanel::views.users_index'",
")",
")",
"->",
"with",
"(",
... | Show all the users
@author Steve Montambeault
@link http://stevemo.ca
@return \Illuminate\View\View | [
"Show",
"all",
"the",
"users"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersController.php#L59-L64 |
38,569 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersController.php | UsersController.show | public function show($id)
{
try
{
$throttle = $this->users->getUserThrottle($id);
$user = $throttle->getUser();
$permissions = $user->getMergedPermissions();
return View::make(Config::get('cpanel::views.users_show'))
->with('user',$user)
->with('groups',$user->getGroups())
->with('permissions',$permissions)
->with('throttle',$throttle);
}
catch ( UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', $e->getMessage());
}
} | php | public function show($id)
{
try
{
$throttle = $this->users->getUserThrottle($id);
$user = $throttle->getUser();
$permissions = $user->getMergedPermissions();
return View::make(Config::get('cpanel::views.users_show'))
->with('user',$user)
->with('groups',$user->getGroups())
->with('permissions',$permissions)
->with('throttle',$throttle);
}
catch ( UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', $e->getMessage());
}
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"throttle",
"=",
"$",
"this",
"->",
"users",
"->",
"getUserThrottle",
"(",
"$",
"id",
")",
";",
"$",
"user",
"=",
"$",
"throttle",
"->",
"getUser",
"(",
")",
";",
"$",
"perm... | Show a user profile
@author Steve Montambeault
@link http://stevemo.ca
@param int $id
@return Response | [
"Show",
"a",
"user",
"profile"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersController.php#L75-L94 |
38,570 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersController.php | UsersController.create | public function create()
{
$user = $this->users->getEmptyUser();
$userPermissions = array();
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
//Get Groups
$groups = $this->groups->findAll();
return View::make(Config::get('cpanel::views.users_create'))
->with('user',$user)
->with('userPermissions',$userPermissions)
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions)
->with('groups',$groups);
} | php | public function create()
{
$user = $this->users->getEmptyUser();
$userPermissions = array();
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
//Get Groups
$groups = $this->groups->findAll();
return View::make(Config::get('cpanel::views.users_create'))
->with('user',$user)
->with('userPermissions',$userPermissions)
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions)
->with('groups',$groups);
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"users",
"->",
"getEmptyUser",
"(",
")",
";",
"$",
"userPermissions",
"=",
"array",
"(",
")",
";",
"$",
"genericPermissions",
"=",
"$",
"this",
"->",
"permissions",
"->... | Display add user form
@author Steve Montambeault
@link http://stevemo.ca
@return \Illuminate\View\View | [
"Display",
"add",
"user",
"form"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersController.php#L104-L122 |
38,571 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersController.php | UsersController.edit | public function edit($id)
{
try
{
$user = $this->users->findById($id);
$groups = $this->groups->findAll();
$userPermissions = $user->getPermissions();
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
//get only the group id the user belong to
$userGroupsId = array_pluck($user->getGroups()->toArray(), 'id');
return View::make(Config::get('cpanel::views.users_edit'))
->with('user',$user)
->with('groups',$groups)
->with('userGroupsId',$userGroupsId)
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions)
->with('userPermissions',$userPermissions);
}
catch (UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error',$e->getMessage());
}
} | php | public function edit($id)
{
try
{
$user = $this->users->findById($id);
$groups = $this->groups->findAll();
$userPermissions = $user->getPermissions();
$genericPermissions = $this->permissions->generic();
$modulePermissions = $this->permissions->module();
//get only the group id the user belong to
$userGroupsId = array_pluck($user->getGroups()->toArray(), 'id');
return View::make(Config::get('cpanel::views.users_edit'))
->with('user',$user)
->with('groups',$groups)
->with('userGroupsId',$userGroupsId)
->with('genericPermissions',$genericPermissions)
->with('modulePermissions',$modulePermissions)
->with('userPermissions',$userPermissions);
}
catch (UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error',$e->getMessage());
}
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"users",
"->",
"findById",
"(",
"$",
"id",
")",
";",
"$",
"groups",
"=",
"$",
"this",
"->",
"groups",
"->",
"findAll",
"(",
")",
";",
"$",
... | Display the user edit form
@author Steve Montambeault
@link http://stevemo.ca
@param int $id
@return \Illuminate\Http\RedirectResponse | [
"Display",
"the",
"user",
"edit",
"form"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersController.php#L134-L161 |
38,572 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersController.php | UsersController.putDeactivate | public function putDeactivate($id)
{
try
{
$this->users->deactivate($id);
return Redirect::route('cpanel.users.index')
->with('success',Lang::get('cpanel::users.deactivation_success'));
}
catch (UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error',$e->getMessage());
}
} | php | public function putDeactivate($id)
{
try
{
$this->users->deactivate($id);
return Redirect::route('cpanel.users.index')
->with('success',Lang::get('cpanel::users.deactivation_success'));
}
catch (UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error',$e->getMessage());
}
} | [
"public",
"function",
"putDeactivate",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"users",
"->",
"deactivate",
"(",
"$",
"id",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'cpanel.users.index'",
")",
"->",
"with",
"(",
"'success'",
... | deactivate a user
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@return \Illuminate\Http\RedirectResponse | [
"deactivate",
"a",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersController.php#L266-L279 |
38,573 | stevemo/cpanel | src/migrations/2013_06_16_144920_create_permissions_table.php | CreatePermissionsTable.seed | public function seed()
{
DB::table('permissions')->insert(array(
array(
'name' => 'Admin',
'permissions' => json_encode(array('cpanel.view')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
),
array(
'name' => 'Users',
'permissions' => json_encode(array('users.view','users.create','users.update','users.delete')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
),
array(
'name' => 'Groups',
'permissions' => json_encode(array('groups.view','groups.create','groups.update','groups.delete')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
),
array(
'name' => 'Permissions',
'permissions' => json_encode(array('permissions.view','permissions.create','permissions.update','permissions.delete')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
)
));
} | php | public function seed()
{
DB::table('permissions')->insert(array(
array(
'name' => 'Admin',
'permissions' => json_encode(array('cpanel.view')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
),
array(
'name' => 'Users',
'permissions' => json_encode(array('users.view','users.create','users.update','users.delete')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
),
array(
'name' => 'Groups',
'permissions' => json_encode(array('groups.view','groups.create','groups.update','groups.delete')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
),
array(
'name' => 'Permissions',
'permissions' => json_encode(array('permissions.view','permissions.create','permissions.update','permissions.delete')),
'created_at' => new \DateTime,
'updated_at' => new \DateTime
)
));
} | [
"public",
"function",
"seed",
"(",
")",
"{",
"DB",
"::",
"table",
"(",
"'permissions'",
")",
"->",
"insert",
"(",
"array",
"(",
"array",
"(",
"'name'",
"=>",
"'Admin'",
",",
"'permissions'",
"=>",
"json_encode",
"(",
"array",
"(",
"'cpanel.view'",
")",
"... | Create default Permissions
@author Steve Montambeault
@link http://stevemo.ca
@return void | [
"Create",
"default",
"Permissions"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/migrations/2013_06_16_144920_create_permissions_table.php#L44-L74 |
38,574 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersThrottlingController.php | UsersThrottlingController.getStatus | public function getStatus($id)
{
try
{
$throttle = $this->users->getUserThrottle($id);
$user = $throttle->getUser();
return View::make(Config::get('cpanel::views.throttle_status'))
->with('user',$user)
->with('throttle',$throttle);
}
catch (UserNotFoundException $e)
{
return Redirect::route('admin.users.index')->with('error', $e->getMessage());
}
} | php | public function getStatus($id)
{
try
{
$throttle = $this->users->getUserThrottle($id);
$user = $throttle->getUser();
return View::make(Config::get('cpanel::views.throttle_status'))
->with('user',$user)
->with('throttle',$throttle);
}
catch (UserNotFoundException $e)
{
return Redirect::route('admin.users.index')->with('error', $e->getMessage());
}
} | [
"public",
"function",
"getStatus",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"throttle",
"=",
"$",
"this",
"->",
"users",
"->",
"getUserThrottle",
"(",
"$",
"id",
")",
";",
"$",
"user",
"=",
"$",
"throttle",
"->",
"getUser",
"(",
")",
";",
"return... | Show the user Throttling status
@author Steve Montambeault
@link http://stevemo.ca
@param int $id
@return \Illuminate\Http\RedirectResponse|\Illuminate\View\View | [
"Show",
"the",
"user",
"Throttling",
"status"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersThrottlingController.php#L33-L47 |
38,575 | stevemo/cpanel | src/Stevemo/Cpanel/Controllers/UsersThrottlingController.php | UsersThrottlingController.putStatus | public function putStatus($id, $action)
{
try
{
$this->users->updateThrottleStatus($id,$action);
return Redirect::route('cpanel.users.index')
->with('success', Lang::get('cpanel::throttle.success',array('action' => $action)));
}
catch (UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', $e->getMessage());
}
catch (\BadMethodCallException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', "This method is not suported [{$action}]");
}
} | php | public function putStatus($id, $action)
{
try
{
$this->users->updateThrottleStatus($id,$action);
return Redirect::route('cpanel.users.index')
->with('success', Lang::get('cpanel::throttle.success',array('action' => $action)));
}
catch (UserNotFoundException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', $e->getMessage());
}
catch (\BadMethodCallException $e)
{
return Redirect::route('cpanel.users.index')
->with('error', "This method is not suported [{$action}]");
}
} | [
"public",
"function",
"putStatus",
"(",
"$",
"id",
",",
"$",
"action",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"users",
"->",
"updateThrottleStatus",
"(",
"$",
"id",
",",
"$",
"action",
")",
";",
"return",
"Redirect",
"::",
"route",
"(",
"'cpanel.user... | Update the throttle status for a given user
@author Steve Montambeault
@link http://stevemo.ca
@param $id
@param $action
@return \Illuminate\Http\RedirectResponse | [
"Update",
"the",
"throttle",
"status",
"for",
"a",
"given",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/Controllers/UsersThrottlingController.php#L60-L79 |
38,576 | stevemo/cpanel | src/Stevemo/Cpanel/User/UserMailer.php | UserMailer.sendReset | public function sendReset(UserInterface $user)
{
$view = Config::get('cpanel::views.email_password_forgot');
$code = $user->getResetPasswordCode();
Mail::queue($view, compact('code'), function($message) use ($user)
{
$message->to($user->email)->subject('Account Password Reset');
});
} | php | public function sendReset(UserInterface $user)
{
$view = Config::get('cpanel::views.email_password_forgot');
$code = $user->getResetPasswordCode();
Mail::queue($view, compact('code'), function($message) use ($user)
{
$message->to($user->email)->subject('Account Password Reset');
});
} | [
"public",
"function",
"sendReset",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"view",
"=",
"Config",
"::",
"get",
"(",
"'cpanel::views.email_password_forgot'",
")",
";",
"$",
"code",
"=",
"$",
"user",
"->",
"getResetPasswordCode",
"(",
")",
";",
"Mail... | Send a email to a given user with a link to reset is password
@author Steve Montambeault
@link http://stevemo.ca
@param UserInterface $user
@return void | [
"Send",
"a",
"email",
"to",
"a",
"given",
"user",
"with",
"a",
"link",
"to",
"reset",
"is",
"password"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/UserMailer.php#L18-L27 |
38,577 | stevemo/cpanel | src/Stevemo/Cpanel/CpanelServiceProvider.php | CpanelServiceProvider.registerPermission | public function registerPermission()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\Permission\Repo\PermissionInterface', function($app)
{
return new PermissionRepository(new Permission, $app['events'], $app['config']);
});
$app->bind('Stevemo\Cpanel\Permission\Form\PermissionFormInterface', function($app)
{
return new PermissionForm(
new PermissionValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\Permission\Repo\PermissionInterface')
);
});
} | php | public function registerPermission()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\Permission\Repo\PermissionInterface', function($app)
{
return new PermissionRepository(new Permission, $app['events'], $app['config']);
});
$app->bind('Stevemo\Cpanel\Permission\Form\PermissionFormInterface', function($app)
{
return new PermissionForm(
new PermissionValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\Permission\Repo\PermissionInterface')
);
});
} | [
"public",
"function",
"registerPermission",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"$",
"app",
"->",
"bind",
"(",
"'Stevemo\\Cpanel\\Permission\\Repo\\PermissionInterface'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
... | Register Permission module component
@author Steve Montambeault
@link http://stevemo.ca | [
"Register",
"Permission",
"module",
"component"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/CpanelServiceProvider.php#L86-L102 |
38,578 | stevemo/cpanel | src/Stevemo/Cpanel/CpanelServiceProvider.php | CpanelServiceProvider.registerGroup | public function registerGroup()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\Group\Repo\CpanelGroupInterface', function($app)
{
return new GroupRepository($app['sentry'], $app['events']);
});
$app->bind('Stevemo\Cpanel\Group\Form\GroupFormInterface', function($app)
{
return new GroupForm(
new GroupValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\Group\Repo\CpanelGroupInterface')
);
});
} | php | public function registerGroup()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\Group\Repo\CpanelGroupInterface', function($app)
{
return new GroupRepository($app['sentry'], $app['events']);
});
$app->bind('Stevemo\Cpanel\Group\Form\GroupFormInterface', function($app)
{
return new GroupForm(
new GroupValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\Group\Repo\CpanelGroupInterface')
);
});
} | [
"public",
"function",
"registerGroup",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"$",
"app",
"->",
"bind",
"(",
"'Stevemo\\Cpanel\\Group\\Repo\\CpanelGroupInterface'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"GroupRe... | Register Group binding
@author Steve Montambeault
@link http://stevemo.ca | [
"Register",
"Group",
"binding"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/CpanelServiceProvider.php#L111-L127 |
38,579 | stevemo/cpanel | src/Stevemo/Cpanel/CpanelServiceProvider.php | CpanelServiceProvider.registerUser | public function registerUser()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\User\Repo\CpanelUserInterface', function($app)
{
return new UserRepository($app['sentry'], $app['events']);
});
$app->bind('Stevemo\Cpanel\User\Form\UserFormInterface', function($app)
{
return new UserForm(
new UserValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\User\Repo\CpanelUserInterface')
);
});
} | php | public function registerUser()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\User\Repo\CpanelUserInterface', function($app)
{
return new UserRepository($app['sentry'], $app['events']);
});
$app->bind('Stevemo\Cpanel\User\Form\UserFormInterface', function($app)
{
return new UserForm(
new UserValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\User\Repo\CpanelUserInterface')
);
});
} | [
"public",
"function",
"registerUser",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"$",
"app",
"->",
"bind",
"(",
"'Stevemo\\Cpanel\\User\\Repo\\CpanelUserInterface'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"UserReposi... | Register User binding
@author Steve Montambeault
@link http://stevemo.ca | [
"Register",
"User",
"binding"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/CpanelServiceProvider.php#L136-L152 |
38,580 | stevemo/cpanel | src/Stevemo/Cpanel/CpanelServiceProvider.php | CpanelServiceProvider.registerPassword | public function registerPassword()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\User\Form\PasswordFormInterface', function($app)
{
return new PasswordForm(
new PasswordValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\User\Repo\CpanelUserInterface'),
$app->make('Stevemo\Cpanel\User\UserMailerInterface')
);
});
$app->bind('Stevemo\Cpanel\User\UserMailerInterface', function($app)
{
return new UserMailer();
});
} | php | public function registerPassword()
{
$app = $this->app;
$app->bind('Stevemo\Cpanel\User\Form\PasswordFormInterface', function($app)
{
return new PasswordForm(
new PasswordValidator($app['validator'], new MessageBag),
$app->make('Stevemo\Cpanel\User\Repo\CpanelUserInterface'),
$app->make('Stevemo\Cpanel\User\UserMailerInterface')
);
});
$app->bind('Stevemo\Cpanel\User\UserMailerInterface', function($app)
{
return new UserMailer();
});
} | [
"public",
"function",
"registerPassword",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"$",
"app",
"->",
"bind",
"(",
"'Stevemo\\Cpanel\\User\\Form\\PasswordFormInterface'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Pass... | Register bindings for the password reset
@author Steve Montambeault
@link http://stevemo.ca | [
"Register",
"bindings",
"for",
"the",
"password",
"reset"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/CpanelServiceProvider.php#L161-L178 |
38,581 | stevemo/cpanel | src/Stevemo/Cpanel/User/Form/UserForm.php | UserForm.create | public function create(array $data)
{
try
{
if ( $this->validator->with($data)->passes() )
{
$this->users->create($data,$data['activate']);
return true;
}
}
catch (LoginRequiredException $e)
{
$this->validator->add('LoginRequiredException',$e->getMessage());
}
catch (PasswordRequiredException $e)
{
$this->validator->add('PasswordRequiredException',$e->getMessage());
}
catch (UserExistsException $e)
{
$this->validator->add('UserExistsException',$e->getMessage());
}
return false;
} | php | public function create(array $data)
{
try
{
if ( $this->validator->with($data)->passes() )
{
$this->users->create($data,$data['activate']);
return true;
}
}
catch (LoginRequiredException $e)
{
$this->validator->add('LoginRequiredException',$e->getMessage());
}
catch (PasswordRequiredException $e)
{
$this->validator->add('PasswordRequiredException',$e->getMessage());
}
catch (UserExistsException $e)
{
$this->validator->add('UserExistsException',$e->getMessage());
}
return false;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"data",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"validator",
"->",
"with",
"(",
"$",
"data",
")",
"->",
"passes",
"(",
")",
")",
"{",
"$",
"this",
"->",
"users",
"->",
"create",
"(",
... | Validate and create the user
@author Steve Montambeault
@link http://stevemo.ca
@param array $data
@return \StdClass | [
"Validate",
"and",
"create",
"the",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Form/UserForm.php#L46-L70 |
38,582 | stevemo/cpanel | src/Stevemo/Cpanel/User/Form/UserForm.php | UserForm.update | public function update(array $data)
{
try
{
if ( $this->validator->with($data)->validForUpdate() )
{
$this->users->update($data['id'], $this->validator->getData());
return true;
}
}
catch (LoginRequiredException $e)
{
$this->validator->add('LoginRequiredException',$e->getMessage());
}
catch (PasswordRequiredException $e)
{
$this->validator->add('PasswordRequiredException',$e->getMessage());
}
catch (UserExistsException $e)
{
$this->validator->add('UserExistsException',$e->getMessage());
}
return false;
} | php | public function update(array $data)
{
try
{
if ( $this->validator->with($data)->validForUpdate() )
{
$this->users->update($data['id'], $this->validator->getData());
return true;
}
}
catch (LoginRequiredException $e)
{
$this->validator->add('LoginRequiredException',$e->getMessage());
}
catch (PasswordRequiredException $e)
{
$this->validator->add('PasswordRequiredException',$e->getMessage());
}
catch (UserExistsException $e)
{
$this->validator->add('UserExistsException',$e->getMessage());
}
return false;
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"data",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"validator",
"->",
"with",
"(",
"$",
"data",
")",
"->",
"validForUpdate",
"(",
")",
")",
"{",
"$",
"this",
"->",
"users",
"->",
"update",... | Validate and update a existing user
@author Steve Montambeault
@link http://stevemo.ca
@param array $data
@return bool | [
"Validate",
"and",
"update",
"a",
"existing",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Form/UserForm.php#L119-L143 |
38,583 | stevemo/cpanel | src/Stevemo/Cpanel/User/Form/UserForm.php | UserForm.login | public function login(array $credentials, $remember)
{
try
{
$this->users->authenticate($credentials,$remember);
return true;
}
catch (LoginRequiredException $e)
{
$this->validator->add('LoginRequiredException', $e->getMessage());
}
catch (PasswordRequiredException $e)
{
$this->validator->add('PasswordRequiredException', $e->getMessage());
}
catch (WrongPasswordException $e)
{
$this->validator->add('WrongPasswordException', $e->getMessage());
}
catch (UserNotActivatedException $e)
{
$this->validator->add('UserNotActivatedException', $e->getMessage());
}
catch (UserNotFoundException $e)
{
$this->validator->add('UserNotFoundException', $e->getMessage());
}
catch (UserSuspendedException $e)
{
$this->validator->add('UserSuspendedException', $e->getMessage());
}
catch (UserBannedException $e)
{
$this->validator->add('UserBannedException', $e->getMessage());
}
return false;
} | php | public function login(array $credentials, $remember)
{
try
{
$this->users->authenticate($credentials,$remember);
return true;
}
catch (LoginRequiredException $e)
{
$this->validator->add('LoginRequiredException', $e->getMessage());
}
catch (PasswordRequiredException $e)
{
$this->validator->add('PasswordRequiredException', $e->getMessage());
}
catch (WrongPasswordException $e)
{
$this->validator->add('WrongPasswordException', $e->getMessage());
}
catch (UserNotActivatedException $e)
{
$this->validator->add('UserNotActivatedException', $e->getMessage());
}
catch (UserNotFoundException $e)
{
$this->validator->add('UserNotFoundException', $e->getMessage());
}
catch (UserSuspendedException $e)
{
$this->validator->add('UserSuspendedException', $e->getMessage());
}
catch (UserBannedException $e)
{
$this->validator->add('UserBannedException', $e->getMessage());
}
return false;
} | [
"public",
"function",
"login",
"(",
"array",
"$",
"credentials",
",",
"$",
"remember",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"users",
"->",
"authenticate",
"(",
"$",
"credentials",
",",
"$",
"remember",
")",
";",
"return",
"true",
";",
"}",
"catch",... | Validate and log in a user
@author Steve Montambeault
@link http://stevemo.ca
@param array $credentials
@param bool $remember
@return bool | [
"Validate",
"and",
"log",
"in",
"a",
"user"
] | f6435f64af5a3aa3d74c5d14f8d7e765303acb8b | https://github.com/stevemo/cpanel/blob/f6435f64af5a3aa3d74c5d14f8d7e765303acb8b/src/Stevemo/Cpanel/User/Form/UserForm.php#L156-L193 |
38,584 | php-cache/cache-bundle | src/Command/CacheFlushCommand.php | CacheFlushCommand.clearCacheForBuiltInType | private function clearCacheForBuiltInType($type)
{
if (!$this->getContainer()->hasParameter(sprintf('cache.%s', $type))) {
return true;
}
$config = $this->getContainer()->getParameter(sprintf('cache.%s', $type));
if ($type === 'doctrine') {
$result = true;
$result = $result && $this->clearTypedCacheFromService($type, $config['metadata']['service_id']);
$result = $result && $this->clearTypedCacheFromService($type, $config['result']['service_id']);
$result = $result && $this->clearTypedCacheFromService($type, $config['query']['service_id']);
return $result;
} else {
return $this->clearTypedCacheFromService($type, $config['service_id']);
}
} | php | private function clearCacheForBuiltInType($type)
{
if (!$this->getContainer()->hasParameter(sprintf('cache.%s', $type))) {
return true;
}
$config = $this->getContainer()->getParameter(sprintf('cache.%s', $type));
if ($type === 'doctrine') {
$result = true;
$result = $result && $this->clearTypedCacheFromService($type, $config['metadata']['service_id']);
$result = $result && $this->clearTypedCacheFromService($type, $config['result']['service_id']);
$result = $result && $this->clearTypedCacheFromService($type, $config['query']['service_id']);
return $result;
} else {
return $this->clearTypedCacheFromService($type, $config['service_id']);
}
} | [
"private",
"function",
"clearCacheForBuiltInType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"hasParameter",
"(",
"sprintf",
"(",
"'cache.%s'",
",",
"$",
"type",
")",
")",
")",
"{",
"return",
"true",
... | Clear the cache for a type.
@param string $type
@return bool | [
"Clear",
"the",
"cache",
"for",
"a",
"type",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/Command/CacheFlushCommand.php#L95-L113 |
38,585 | php-cache/cache-bundle | src/DataCollector/CacheDataCollector.php | CacheDataCollector.cloneData | private function cloneData($var)
{
if (method_exists($this, 'cloneVar')) {
// Symfony 3.2 or higher
return $this->cloneVar($var);
}
if (null === $this->cloner) {
$this->cloner = new VarCloner();
$this->cloner->setMaxItems(-1);
$this->cloner->addCasters($this->getCloneCasters());
}
return $this->cloner->cloneVar($var);
} | php | private function cloneData($var)
{
if (method_exists($this, 'cloneVar')) {
// Symfony 3.2 or higher
return $this->cloneVar($var);
}
if (null === $this->cloner) {
$this->cloner = new VarCloner();
$this->cloner->setMaxItems(-1);
$this->cloner->addCasters($this->getCloneCasters());
}
return $this->cloner->cloneVar($var);
} | [
"private",
"function",
"cloneData",
"(",
"$",
"var",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'cloneVar'",
")",
")",
"{",
"// Symfony 3.2 or higher",
"return",
"$",
"this",
"->",
"cloneVar",
"(",
"$",
"var",
")",
";",
"}",
"if",
"(... | To be compatible with many versions of Symfony.
@param $var | [
"To",
"be",
"compatible",
"with",
"many",
"versions",
"of",
"Symfony",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DataCollector/CacheDataCollector.php#L86-L100 |
38,586 | php-cache/cache-bundle | src/DependencyInjection/CacheExtension.php | CacheExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
// Make sure config values are in the parameters
foreach (['router', 'session', 'doctrine', 'logging', 'annotation', 'serializer', 'validation'] as $section) {
if ($config[$section]['enabled']) {
$container->setParameter('cache.'.$section, $config[$section]);
}
}
if ($config['doctrine']['enabled']) {
$this->verifyDoctrineBridgeExists('doctrine');
}
$this->registerServices($container, $config);
// Add toolbar and data collector if we are debugging
if (!isset($config['data_collector']['enabled'])) {
$config['data_collector']['enabled'] = $container->getParameter('kernel.debug');
}
if ($config['data_collector']['enabled']) {
$loader->load('data-collector.yml');
}
// Get a list of the psr-6 services we are using.
$serviceIds = [];
$this->findServiceIds($config, $serviceIds);
$container->setParameter('cache.provider_service_ids', $serviceIds);
$container->register(CacheFlushCommand::class, CacheFlushCommand::class)
->addTag('console.command', ['command' => 'cache:flush']);
} | php | public function load(array $configs, ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
// Make sure config values are in the parameters
foreach (['router', 'session', 'doctrine', 'logging', 'annotation', 'serializer', 'validation'] as $section) {
if ($config[$section]['enabled']) {
$container->setParameter('cache.'.$section, $config[$section]);
}
}
if ($config['doctrine']['enabled']) {
$this->verifyDoctrineBridgeExists('doctrine');
}
$this->registerServices($container, $config);
// Add toolbar and data collector if we are debugging
if (!isset($config['data_collector']['enabled'])) {
$config['data_collector']['enabled'] = $container->getParameter('kernel.debug');
}
if ($config['data_collector']['enabled']) {
$loader->load('data-collector.yml');
}
// Get a list of the psr-6 services we are using.
$serviceIds = [];
$this->findServiceIds($config, $serviceIds);
$container->setParameter('cache.provider_service_ids', $serviceIds);
$container->register(CacheFlushCommand::class, CacheFlushCommand::class)
->addTag('console.command', ['command' => 'cache:flush']);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"new",
"Configuration",
"(",
")",
",",
"$",
"configs",
")",
";",
"$",
"lo... | Loads the configs for Cache and puts data into the container.
@param array $configs Array of configs
@param ContainerBuilder $container Container Object | [
"Loads",
"the",
"configs",
"for",
"Cache",
"and",
"puts",
"data",
"into",
"the",
"container",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DependencyInjection/CacheExtension.php#L41-L76 |
38,587 | php-cache/cache-bundle | src/DependencyInjection/CacheExtension.php | CacheExtension.findServiceIds | protected function findServiceIds(array $config, array &$serviceIds)
{
foreach ($config as $name => $value) {
if (is_array($value)) {
$this->findServiceIds($value, $serviceIds);
} elseif ($name === 'service_id') {
$serviceIds[] = $value;
}
}
} | php | protected function findServiceIds(array $config, array &$serviceIds)
{
foreach ($config as $name => $value) {
if (is_array($value)) {
$this->findServiceIds($value, $serviceIds);
} elseif ($name === 'service_id') {
$serviceIds[] = $value;
}
}
} | [
"protected",
"function",
"findServiceIds",
"(",
"array",
"$",
"config",
",",
"array",
"&",
"$",
"serviceIds",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")"... | Find service ids that we configured. These services should be tagged so we can use them in the debug toolbar.
@param array $config
@param array $serviceIds | [
"Find",
"service",
"ids",
"that",
"we",
"configured",
".",
"These",
"services",
"should",
"be",
"tagged",
"so",
"we",
"can",
"use",
"them",
"in",
"the",
"debug",
"toolbar",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DependencyInjection/CacheExtension.php#L84-L93 |
38,588 | php-cache/cache-bundle | src/DependencyInjection/CacheExtension.php | CacheExtension.registerServices | private function registerServices(ContainerBuilder $container, $config)
{
if ($config['annotation']['enabled']) {
$this->verifyDoctrineBridgeExists('annotation');
$container->register('cache.service.annotation', DoctrineCacheBridge::class)
->setFactory([DoctrineBridgeFactory::class, 'get'])
->addArgument(new Reference($config['annotation']['service_id']))
->addArgument($config['annotation'])
->addArgument(['annotation']);
}
if ($config['serializer']['enabled']) {
$this->verifyDoctrineBridgeExists('serializer');
$container->register('cache.service.serializer', DoctrineCacheBridge::class)
->setFactory([DoctrineBridgeFactory::class, 'get'])
->addArgument(new Reference($config['serializer']['service_id']))
->addArgument($config['serializer'])
->addArgument(['serializer']);
}
if ($config['validation']['enabled']) {
$container->register('cache.service.validation', SymfonyValidatorBridge::class)
->setFactory([ValidationFactory::class, 'get'])
->addArgument(new Reference($config['validation']['service_id']))
->addArgument($config['validation']);
}
if ($config['session']['enabled']) {
$container->register('cache.service.session', Psr6SessionHandler::class)
->setFactory([SessionHandlerFactory::class, 'get'])
->addArgument(new Reference($config['session']['service_id']))
->addArgument($config['session']);
}
if ($config['router']['enabled']) {
$container->register('cache.service.router', CachingRouter::class)
->setFactory([RouterFactory::class, 'get'])
->setDecoratedService('router', null, 10)
->addArgument(new Reference($config['router']['service_id']))
->addArgument(new Reference('cache.service.router.inner'))
->addArgument($config['router']);
}
} | php | private function registerServices(ContainerBuilder $container, $config)
{
if ($config['annotation']['enabled']) {
$this->verifyDoctrineBridgeExists('annotation');
$container->register('cache.service.annotation', DoctrineCacheBridge::class)
->setFactory([DoctrineBridgeFactory::class, 'get'])
->addArgument(new Reference($config['annotation']['service_id']))
->addArgument($config['annotation'])
->addArgument(['annotation']);
}
if ($config['serializer']['enabled']) {
$this->verifyDoctrineBridgeExists('serializer');
$container->register('cache.service.serializer', DoctrineCacheBridge::class)
->setFactory([DoctrineBridgeFactory::class, 'get'])
->addArgument(new Reference($config['serializer']['service_id']))
->addArgument($config['serializer'])
->addArgument(['serializer']);
}
if ($config['validation']['enabled']) {
$container->register('cache.service.validation', SymfonyValidatorBridge::class)
->setFactory([ValidationFactory::class, 'get'])
->addArgument(new Reference($config['validation']['service_id']))
->addArgument($config['validation']);
}
if ($config['session']['enabled']) {
$container->register('cache.service.session', Psr6SessionHandler::class)
->setFactory([SessionHandlerFactory::class, 'get'])
->addArgument(new Reference($config['session']['service_id']))
->addArgument($config['session']);
}
if ($config['router']['enabled']) {
$container->register('cache.service.router', CachingRouter::class)
->setFactory([RouterFactory::class, 'get'])
->setDecoratedService('router', null, 10)
->addArgument(new Reference($config['router']['service_id']))
->addArgument(new Reference('cache.service.router.inner'))
->addArgument($config['router']);
}
} | [
"private",
"function",
"registerServices",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"[",
"'annotation'",
"]",
"[",
"'enabled'",
"]",
")",
"{",
"$",
"this",
"->",
"verifyDoctrineBridgeExists",
"(",
"'a... | Register services. All service ids will start witn "cache.service.".
@param ContainerBuilder $container
@param $config
@throws \Exception | [
"Register",
"services",
".",
"All",
"service",
"ids",
"will",
"start",
"witn",
"cache",
".",
"service",
".",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DependencyInjection/CacheExtension.php#L130-L172 |
38,589 | php-cache/cache-bundle | src/DataCollector/ProxyFactory.php | ProxyFactory.createProxy | public function createProxy($class, &$proxyFile = null)
{
$proxyClass = $this->getProxyClass($class);
$class = '\\'.rtrim($class, '\\');
$proxyFile = $this->proxyDirectory.'/'.$proxyClass.'.php';
if (class_exists($proxyClass)) {
return $proxyClass;
}
if (file_exists($proxyFile)) {
require $proxyFile;
return $proxyClass;
}
$content = file_get_contents(dirname(__DIR__).'/Resources/proxy/template.php');
$content = str_replace('__TPL_CLASS__', $proxyClass, $content);
$content = str_replace('__TPL_EXTENDS__', $class, $content);
$this->checkProxyDirectory();
file_put_contents($proxyFile, $content);
require $proxyFile;
return $proxyClass;
} | php | public function createProxy($class, &$proxyFile = null)
{
$proxyClass = $this->getProxyClass($class);
$class = '\\'.rtrim($class, '\\');
$proxyFile = $this->proxyDirectory.'/'.$proxyClass.'.php';
if (class_exists($proxyClass)) {
return $proxyClass;
}
if (file_exists($proxyFile)) {
require $proxyFile;
return $proxyClass;
}
$content = file_get_contents(dirname(__DIR__).'/Resources/proxy/template.php');
$content = str_replace('__TPL_CLASS__', $proxyClass, $content);
$content = str_replace('__TPL_EXTENDS__', $class, $content);
$this->checkProxyDirectory();
file_put_contents($proxyFile, $content);
require $proxyFile;
return $proxyClass;
} | [
"public",
"function",
"createProxy",
"(",
"$",
"class",
",",
"&",
"$",
"proxyFile",
"=",
"null",
")",
"{",
"$",
"proxyClass",
"=",
"$",
"this",
"->",
"getProxyClass",
"(",
"$",
"class",
")",
";",
"$",
"class",
"=",
"'\\\\'",
".",
"rtrim",
"(",
"$",
... | Create a proxy that handles data collecting better.
@param string $class
@param string &$proxyFile where we store the proxy class
@return string the name of a much much better class | [
"Create",
"a",
"proxy",
"that",
"handles",
"data",
"collecting",
"better",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DataCollector/ProxyFactory.php#L42-L67 |
38,590 | php-cache/cache-bundle | src/DependencyInjection/Configuration.php | Configuration.normalizeEnabled | private function normalizeEnabled(NodeDefinition $node)
{
$node->beforeNormalization()
->always()
->then(
function ($v) {
if (is_string($v['enabled'])) {
$v['enabled'] = $v['enabled'] === 'true';
}
if (is_int($v['enabled'])) {
$v['enabled'] = $v['enabled'] === 1;
}
return $v;
}
)
->end();
return $this;
} | php | private function normalizeEnabled(NodeDefinition $node)
{
$node->beforeNormalization()
->always()
->then(
function ($v) {
if (is_string($v['enabled'])) {
$v['enabled'] = $v['enabled'] === 'true';
}
if (is_int($v['enabled'])) {
$v['enabled'] = $v['enabled'] === 1;
}
return $v;
}
)
->end();
return $this;
} | [
"private",
"function",
"normalizeEnabled",
"(",
"NodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"beforeNormalization",
"(",
")",
"->",
"always",
"(",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"is_string",
"(",
... | Normalizes the enabled field to be truthy.
@param NodeDefinition $node
@return Configuration | [
"Normalizes",
"the",
"enabled",
"field",
"to",
"be",
"truthy",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DependencyInjection/Configuration.php#L57-L76 |
38,591 | php-cache/cache-bundle | src/DependencyInjection/Configuration.php | Configuration.addSessionSupportSection | private function addSessionSupportSection()
{
$tree = new TreeBuilder();
$node = $tree->root('session');
$node
->canBeEnabled()
->addDefaultsIfNotSet()
->children()
->scalarNode('service_id')->isRequired()->end()
->booleanNode('use_tagging')->defaultTrue()->end()
->scalarNode('prefix')->defaultValue('session_')->end()
->scalarNode('ttl')->end()
->end();
$this->normalizeEnabled($node);
return $node;
} | php | private function addSessionSupportSection()
{
$tree = new TreeBuilder();
$node = $tree->root('session');
$node
->canBeEnabled()
->addDefaultsIfNotSet()
->children()
->scalarNode('service_id')->isRequired()->end()
->booleanNode('use_tagging')->defaultTrue()->end()
->scalarNode('prefix')->defaultValue('session_')->end()
->scalarNode('ttl')->end()
->end();
$this->normalizeEnabled($node);
return $node;
} | [
"private",
"function",
"addSessionSupportSection",
"(",
")",
"{",
"$",
"tree",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"tree",
"->",
"root",
"(",
"'session'",
")",
";",
"$",
"node",
"->",
"canBeEnabled",
"(",
")",
"->",
"addDef... | Configure the "cache.session" section.
@return ArrayNodeDefinition | [
"Configure",
"the",
"cache",
".",
"session",
"section",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DependencyInjection/Configuration.php#L83-L101 |
38,592 | php-cache/cache-bundle | src/DependencyInjection/Configuration.php | Configuration.addDoctrineSection | private function addDoctrineSection()
{
$tree = new TreeBuilder();
$node = $tree->root('doctrine');
$node
->canBeEnabled()
->addDefaultsIfNotSet()
->children()
->booleanNode('use_tagging')
->defaultTrue()
->end()
->end();
$this->normalizeEnabled($node);
$types = ['metadata', 'result', 'query'];
foreach ($types as $type) {
$node->children()
->arrayNode($type)
->canBeUnset()
->children()
->scalarNode('service_id')->isRequired()->end()
->arrayNode('entity_managers')
->defaultValue([])
->beforeNormalization()
->ifString()
->then(
function ($v) {
return (array) $v;
}
)
->end()
->prototype('scalar')->end()
->end()
->arrayNode('document_managers')
->defaultValue([])
->beforeNormalization()
->ifString()
->then(
function ($v) {
return (array) $v;
}
)
->end()
->prototype('scalar')->end()
->end()
->end()
->end();
}
return $node;
} | php | private function addDoctrineSection()
{
$tree = new TreeBuilder();
$node = $tree->root('doctrine');
$node
->canBeEnabled()
->addDefaultsIfNotSet()
->children()
->booleanNode('use_tagging')
->defaultTrue()
->end()
->end();
$this->normalizeEnabled($node);
$types = ['metadata', 'result', 'query'];
foreach ($types as $type) {
$node->children()
->arrayNode($type)
->canBeUnset()
->children()
->scalarNode('service_id')->isRequired()->end()
->arrayNode('entity_managers')
->defaultValue([])
->beforeNormalization()
->ifString()
->then(
function ($v) {
return (array) $v;
}
)
->end()
->prototype('scalar')->end()
->end()
->arrayNode('document_managers')
->defaultValue([])
->beforeNormalization()
->ifString()
->then(
function ($v) {
return (array) $v;
}
)
->end()
->prototype('scalar')->end()
->end()
->end()
->end();
}
return $node;
} | [
"private",
"function",
"addDoctrineSection",
"(",
")",
"{",
"$",
"tree",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"tree",
"->",
"root",
"(",
"'doctrine'",
")",
";",
"$",
"node",
"->",
"canBeEnabled",
"(",
")",
"->",
"addDefaults... | Configure the "cache.doctrine" section.
@return ArrayNodeDefinition | [
"Configure",
"the",
"cache",
".",
"doctrine",
"section",
"."
] | 3d53cb571e16a116ae1e9a0a43bd6b46884b1123 | https://github.com/php-cache/cache-bundle/blob/3d53cb571e16a116ae1e9a0a43bd6b46884b1123/src/DependencyInjection/Configuration.php#L201-L253 |
38,593 | OzanKurt/Repoist | src/Commands/MakeCriterionCommand.php | MakeCriterionCommand.createCriterion | protected function createCriterion()
{
$content = $this->fileManager->get(
__DIR__.'/../stubs/Eloquent/Criteria/Example.php'
);
$criterion = $this->argument('criterion');
$replacements = [
'%namespaces.repositories%' => $this->config('namespaces.repositories'),
'%criterion%' => $criterion,
];
$content = str_replace(array_keys($replacements), array_values($replacements), $content);
$fileName = $criterion;
$fileDirectory = app()->basePath().'/app/'.$this->config('paths.repositories').'Criteria';
$filePath = $fileDirectory.'/'.$fileName.'.php';
if (!$this->fileManager->exists($fileDirectory)) {
$this->fileManager->makeDirectory($fileDirectory, 0755, true);
}
if ($this->laravel->runningInConsole() && $this->fileManager->exists($filePath)) {
$response = $this->ask("The criterion [{$fileName}] already exists. Do you want to overwrite it?", 'Yes');
if (!$this->isResponsePositive($response)) {
$this->line("The criterion [{$fileName}] will not be overwritten.");
return;
}
$this->fileManager->put($filePath, $content);
} else {
$this->fileManager->put($filePath, $content);
}
$this->line("The criterion [{$fileName}] has been created.");
} | php | protected function createCriterion()
{
$content = $this->fileManager->get(
__DIR__.'/../stubs/Eloquent/Criteria/Example.php'
);
$criterion = $this->argument('criterion');
$replacements = [
'%namespaces.repositories%' => $this->config('namespaces.repositories'),
'%criterion%' => $criterion,
];
$content = str_replace(array_keys($replacements), array_values($replacements), $content);
$fileName = $criterion;
$fileDirectory = app()->basePath().'/app/'.$this->config('paths.repositories').'Criteria';
$filePath = $fileDirectory.'/'.$fileName.'.php';
if (!$this->fileManager->exists($fileDirectory)) {
$this->fileManager->makeDirectory($fileDirectory, 0755, true);
}
if ($this->laravel->runningInConsole() && $this->fileManager->exists($filePath)) {
$response = $this->ask("The criterion [{$fileName}] already exists. Do you want to overwrite it?", 'Yes');
if (!$this->isResponsePositive($response)) {
$this->line("The criterion [{$fileName}] will not be overwritten.");
return;
}
$this->fileManager->put($filePath, $content);
} else {
$this->fileManager->put($filePath, $content);
}
$this->line("The criterion [{$fileName}] has been created.");
} | [
"protected",
"function",
"createCriterion",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"fileManager",
"->",
"get",
"(",
"__DIR__",
".",
"'/../stubs/Eloquent/Criteria/Example.php'",
")",
";",
"$",
"criterion",
"=",
"$",
"this",
"->",
"argument",
"("... | Create a new criterion | [
"Create",
"a",
"new",
"criterion"
] | c85430596ed4723191279e0489ca904187c1be08 | https://github.com/OzanKurt/Repoist/blob/c85430596ed4723191279e0489ca904187c1be08/src/Commands/MakeCriterionCommand.php#L44-L81 |
38,594 | OzanKurt/Repoist | src/Commands/MakeRepositoryCommand.php | MakeRepositoryCommand.createContract | protected function createContract()
{
$content = $this->fileManager->get($this->stubs['contract']);
$replacements = [
'%namespaces.contracts%' => $this->appNamespace.$this->config('namespaces.contracts'),
'%modelName%' => $this->modelName,
];
$content = str_replace(array_keys($replacements), array_values($replacements), $content);
$fileName = $this->modelName.'Repository';
$fileDirectory = app()->basePath().'/app/'.$this->config('paths.contracts');
$filePath = $fileDirectory.$fileName.'.php';
if (!$this->fileManager->exists($fileDirectory)) {
$this->fileManager->makeDirectory($fileDirectory, 0755, true);
}
if ($this->laravel->runningInConsole() && $this->fileManager->exists($filePath)) {
$response = $this->ask("The contract [{$fileName}] already exists. Do you want to overwrite it?", 'Yes');
if (!$this->isResponsePositive($response)) {
$this->line("The contract [{$fileName}] will not be overwritten.");
return;
}
$this->fileManager->put($filePath, $content);
} else {
$this->fileManager->put($filePath, $content);
}
$this->line("The contract [{$fileName}] has been created.");
return [$this->config('namespaces.contracts').'\\'.$fileName, $fileName];
} | php | protected function createContract()
{
$content = $this->fileManager->get($this->stubs['contract']);
$replacements = [
'%namespaces.contracts%' => $this->appNamespace.$this->config('namespaces.contracts'),
'%modelName%' => $this->modelName,
];
$content = str_replace(array_keys($replacements), array_values($replacements), $content);
$fileName = $this->modelName.'Repository';
$fileDirectory = app()->basePath().'/app/'.$this->config('paths.contracts');
$filePath = $fileDirectory.$fileName.'.php';
if (!$this->fileManager->exists($fileDirectory)) {
$this->fileManager->makeDirectory($fileDirectory, 0755, true);
}
if ($this->laravel->runningInConsole() && $this->fileManager->exists($filePath)) {
$response = $this->ask("The contract [{$fileName}] already exists. Do you want to overwrite it?", 'Yes');
if (!$this->isResponsePositive($response)) {
$this->line("The contract [{$fileName}] will not be overwritten.");
return;
}
$this->fileManager->put($filePath, $content);
} else {
$this->fileManager->put($filePath, $content);
}
$this->line("The contract [{$fileName}] has been created.");
return [$this->config('namespaces.contracts').'\\'.$fileName, $fileName];
} | [
"protected",
"function",
"createContract",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"fileManager",
"->",
"get",
"(",
"$",
"this",
"->",
"stubs",
"[",
"'contract'",
"]",
")",
";",
"$",
"replacements",
"=",
"[",
"'%namespaces.contracts%'",
"=>"... | Create a new contract | [
"Create",
"a",
"new",
"contract"
] | c85430596ed4723191279e0489ca904187c1be08 | https://github.com/OzanKurt/Repoist/blob/c85430596ed4723191279e0489ca904187c1be08/src/Commands/MakeRepositoryCommand.php#L76-L111 |
38,595 | OzanKurt/Repoist | src/Commands/MakeRepositoryCommand.php | MakeRepositoryCommand.checkModel | protected function checkModel()
{
$model = $this->appNamespace.$this->argument('model');
$this->model = str_replace('/', '\\', $model);
if (!$this->isLumen() && $this->laravel->runningInConsole()) {
if (!class_exists($this->model)) {
$response = $this->ask("Model [{$this->model}] does not exist. Would you like to create it?", 'Yes');
if ($this->isResponsePositive($response)) {
Artisan::call('make:model', [
'name' => $this->model,
]);
$this->line("Model [{$this->model}] has been successfully created.");
} else {
$this->line("Model [{$this->model}] is not being created.");
}
}
}
$modelParts = explode('\\', $this->model);
$this->modelName = array_pop($modelParts);
} | php | protected function checkModel()
{
$model = $this->appNamespace.$this->argument('model');
$this->model = str_replace('/', '\\', $model);
if (!$this->isLumen() && $this->laravel->runningInConsole()) {
if (!class_exists($this->model)) {
$response = $this->ask("Model [{$this->model}] does not exist. Would you like to create it?", 'Yes');
if ($this->isResponsePositive($response)) {
Artisan::call('make:model', [
'name' => $this->model,
]);
$this->line("Model [{$this->model}] has been successfully created.");
} else {
$this->line("Model [{$this->model}] is not being created.");
}
}
}
$modelParts = explode('\\', $this->model);
$this->modelName = array_pop($modelParts);
} | [
"protected",
"function",
"checkModel",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"appNamespace",
".",
"$",
"this",
"->",
"argument",
"(",
"'model'",
")",
";",
"$",
"this",
"->",
"model",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
... | Check the models existance, create if wanted. | [
"Check",
"the",
"models",
"existance",
"create",
"if",
"wanted",
"."
] | c85430596ed4723191279e0489ca904187c1be08 | https://github.com/OzanKurt/Repoist/blob/c85430596ed4723191279e0489ca904187c1be08/src/Commands/MakeRepositoryCommand.php#L156-L181 |
38,596 | addwiki/mediawiki-api-base | src/MediawikiApi.php | MediawikiApi.newFromPage | public static function newFromPage( $url ) {
// Set up HTTP client and HTML document.
$tempClient = new Client( [ 'headers' => [ 'User-Agent' => 'addwiki-mediawiki-client' ] ] );
$pageHtml = $tempClient->get( $url )->getBody();
$pageDoc = new DOMDocument();
// Try to load the HTML (turn off errors temporarily; most don't matter, and if they do get
// in the way of finding the API URL, will be reported in the RsdException below).
$internalErrors = libxml_use_internal_errors( true );
$pageDoc->loadHTML( $pageHtml );
$libXmlErrors = libxml_get_errors();
libxml_use_internal_errors( $internalErrors );
// Extract the RSD link.
$xpath = 'head/link[@type="application/rsd+xml"][@href]';
$link = ( new DOMXpath( $pageDoc ) )->query( $xpath );
if ( $link->length === 0 ) {
// Format libxml errors for display.
$libXmlErrorStr = array_reduce( $libXmlErrors, function ( $prevErr, $err ) {
return $prevErr . ', ' . $err->message . ' (line '.$err->line . ')';
} );
if ( $libXmlErrorStr ) {
$libXmlErrorStr = "In addition, libxml had the following errors: $libXmlErrorStr";
}
throw new RsdException( "Unable to find RSD URL in page: $url $libXmlErrorStr" );
}
$rsdUrl = $link->item( 0 )->attributes->getnamedItem( 'href' )->nodeValue;
// Then get the RSD XML, and return the API link.
$rsdXml = new SimpleXMLElement( $tempClient->get( $rsdUrl )->getBody() );
return self::newFromApiEndpoint( (string)$rsdXml->service->apis->api->attributes()->apiLink );
} | php | public static function newFromPage( $url ) {
// Set up HTTP client and HTML document.
$tempClient = new Client( [ 'headers' => [ 'User-Agent' => 'addwiki-mediawiki-client' ] ] );
$pageHtml = $tempClient->get( $url )->getBody();
$pageDoc = new DOMDocument();
// Try to load the HTML (turn off errors temporarily; most don't matter, and if they do get
// in the way of finding the API URL, will be reported in the RsdException below).
$internalErrors = libxml_use_internal_errors( true );
$pageDoc->loadHTML( $pageHtml );
$libXmlErrors = libxml_get_errors();
libxml_use_internal_errors( $internalErrors );
// Extract the RSD link.
$xpath = 'head/link[@type="application/rsd+xml"][@href]';
$link = ( new DOMXpath( $pageDoc ) )->query( $xpath );
if ( $link->length === 0 ) {
// Format libxml errors for display.
$libXmlErrorStr = array_reduce( $libXmlErrors, function ( $prevErr, $err ) {
return $prevErr . ', ' . $err->message . ' (line '.$err->line . ')';
} );
if ( $libXmlErrorStr ) {
$libXmlErrorStr = "In addition, libxml had the following errors: $libXmlErrorStr";
}
throw new RsdException( "Unable to find RSD URL in page: $url $libXmlErrorStr" );
}
$rsdUrl = $link->item( 0 )->attributes->getnamedItem( 'href' )->nodeValue;
// Then get the RSD XML, and return the API link.
$rsdXml = new SimpleXMLElement( $tempClient->get( $rsdUrl )->getBody() );
return self::newFromApiEndpoint( (string)$rsdXml->service->apis->api->attributes()->apiLink );
} | [
"public",
"static",
"function",
"newFromPage",
"(",
"$",
"url",
")",
"{",
"// Set up HTTP client and HTML document.",
"$",
"tempClient",
"=",
"new",
"Client",
"(",
"[",
"'headers'",
"=>",
"[",
"'User-Agent'",
"=>",
"'addwiki-mediawiki-client'",
"]",
"]",
")",
";",... | Create a new MediawikiApi object from a URL to any page in a MediaWiki website.
@since 2.0
@see https://en.wikipedia.org/wiki/Really_Simple_Discovery
@param string $url e.g. https://en.wikipedia.org OR https://de.wikipedia.org/wiki/Berlin
@return self returns a MediawikiApi instance using the apiEndpoint provided by the RSD
file accessible on all Mediawiki pages
@throws RsdException If the RSD URL could not be found in the page's HTML. | [
"Create",
"a",
"new",
"MediawikiApi",
"object",
"from",
"a",
"URL",
"to",
"any",
"page",
"in",
"a",
"MediaWiki",
"website",
"."
] | 48202fcce7490c15bb6932aaa8b39c7795febbbe | https://github.com/addwiki/mediawiki-api-base/blob/48202fcce7490c15bb6932aaa8b39c7795febbbe/src/MediawikiApi.php#L81-L112 |
38,597 | addwiki/mediawiki-api-base | src/MultipartRequest.php | MultipartRequest.checkMultipartParams | protected function checkMultipartParams( $params ) {
foreach ( $params as $key => $val ) {
if ( !is_array( $val ) ) {
throw new Exception( "Parameter '$key' must be an array." );
}
if ( !in_array( $key, array_keys( $this->getParams() ) ) ) {
throw new Exception( "Parameter '$key' is not already set on this request." );
}
}
} | php | protected function checkMultipartParams( $params ) {
foreach ( $params as $key => $val ) {
if ( !is_array( $val ) ) {
throw new Exception( "Parameter '$key' must be an array." );
}
if ( !in_array( $key, array_keys( $this->getParams() ) ) ) {
throw new Exception( "Parameter '$key' is not already set on this request." );
}
}
} | [
"protected",
"function",
"checkMultipartParams",
"(",
"$",
"params",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
... | Check the structure of a multipart parameter array.
@param mixed[] $params The multipart parameters to check.
@throws Exception | [
"Check",
"the",
"structure",
"of",
"a",
"multipart",
"parameter",
"array",
"."
] | 48202fcce7490c15bb6932aaa8b39c7795febbbe | https://github.com/addwiki/mediawiki-api-base/blob/48202fcce7490c15bb6932aaa8b39c7795febbbe/src/MultipartRequest.php#L27-L36 |
38,598 | addwiki/mediawiki-api-base | src/MultipartRequest.php | MultipartRequest.addMultipartParams | public function addMultipartParams( $params ) {
$this->checkMultipartParams( $params );
$this->multipartParams = array_merge( $this->multipartParams, $params );
return $this;
} | php | public function addMultipartParams( $params ) {
$this->checkMultipartParams( $params );
$this->multipartParams = array_merge( $this->multipartParams, $params );
return $this;
} | [
"public",
"function",
"addMultipartParams",
"(",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkMultipartParams",
"(",
"$",
"params",
")",
";",
"$",
"this",
"->",
"multipartParams",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"multipartParams",
",",
"$",
... | Add extra multipart parameters.
Each key of the array passed in here must be the name of a parameter already set on this
request object.
@param mixed[] $params The multipart parameters to add to any already present.
@return $this | [
"Add",
"extra",
"multipart",
"parameters",
"."
] | 48202fcce7490c15bb6932aaa8b39c7795febbbe | https://github.com/addwiki/mediawiki-api-base/blob/48202fcce7490c15bb6932aaa8b39c7795febbbe/src/MultipartRequest.php#L63-L67 |
38,599 | addwiki/mediawiki-api-base | src/MediawikiSession.php | MediawikiSession.getToken | public function getToken( $type = 'csrf' ) {
// If we don't already have the token that we want
if ( !array_key_exists( $type, $this->tokens ) ) {
$this->logger->log( LogLevel::DEBUG, 'Getting fresh token', [ 'type' => $type ] );
// If we know that we don't have the new module mw<1.25
if ( $this->usePre125TokensModule ) {
return $this->reallyGetPre125Token( $type );
} else {
return $this->reallyGetToken( $type );
}
}
return $this->tokens[$type];
} | php | public function getToken( $type = 'csrf' ) {
// If we don't already have the token that we want
if ( !array_key_exists( $type, $this->tokens ) ) {
$this->logger->log( LogLevel::DEBUG, 'Getting fresh token', [ 'type' => $type ] );
// If we know that we don't have the new module mw<1.25
if ( $this->usePre125TokensModule ) {
return $this->reallyGetPre125Token( $type );
} else {
return $this->reallyGetToken( $type );
}
}
return $this->tokens[$type];
} | [
"public",
"function",
"getToken",
"(",
"$",
"type",
"=",
"'csrf'",
")",
"{",
"// If we don't already have the token that we want",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"tokens",
")",
")",
"{",
"$",
"this",
"->",
"logg... | Tries to get the specified token from the API
@since 0.1
@param string $type The type of token to get.
@return string | [
"Tries",
"to",
"get",
"the",
"specified",
"token",
"from",
"the",
"API"
] | 48202fcce7490c15bb6932aaa8b39c7795febbbe | https://github.com/addwiki/mediawiki-api-base/blob/48202fcce7490c15bb6932aaa8b39c7795febbbe/src/MediawikiSession.php#L67-L82 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.