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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
neos/Neos.MarketPlace | Classes/Command/MarketPlaceCommandController.php | MarketPlaceCommandController.cleanupVendors | protected function cleanupVendors(Storage $storage)
{
$this->outputLine();
$this->outputLine('Cleanup vendors ...');
$this->outputLine('-------------------');
$count = $this->importer->cleanupVendors($storage, function (NodeInterface $vendor) {
$this->outputLine(sprintf('%s deleted', $vendor->getLabel()));
});
if ($count > 0) {
$this->outputLine(sprintf(' Deleted %d vendor(s)', $count));
}
} | php | protected function cleanupVendors(Storage $storage)
{
$this->outputLine();
$this->outputLine('Cleanup vendors ...');
$this->outputLine('-------------------');
$count = $this->importer->cleanupVendors($storage, function (NodeInterface $vendor) {
$this->outputLine(sprintf('%s deleted', $vendor->getLabel()));
});
if ($count > 0) {
$this->outputLine(sprintf(' Deleted %d vendor(s)', $count));
}
} | [
"protected",
"function",
"cleanupVendors",
"(",
"Storage",
"$",
"storage",
")",
"{",
"$",
"this",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"'Cleanup vendors ...'",
")",
";",
"$",
"this",
"->",
"outputLine",
"(",
"'------------... | Remove vendors that don't exist on Packagist or contains no packages
@param Storage $storage | [
"Remove",
"vendors",
"that",
"don",
"t",
"exist",
"on",
"Packagist",
"or",
"contains",
"no",
"packages"
] | 42b844be976cfcd1e2ab4c8966da006047f04abf | https://github.com/neos/Neos.MarketPlace/blob/42b844be976cfcd1e2ab4c8966da006047f04abf/Classes/Command/MarketPlaceCommandController.php#L173-L184 | train |
Bartacus/BartacusBundle | ContentElement/Definition/RenderDefinitionCollection.php | RenderDefinitionCollection.addCollection | public function addCollection(self $collection)
{
$this->renderDefinitions = \array_merge($this->renderDefinitions, $collection->all());
$this->resources = \array_merge($this->resources, $collection->getResources());
} | php | public function addCollection(self $collection)
{
$this->renderDefinitions = \array_merge($this->renderDefinitions, $collection->all());
$this->resources = \array_merge($this->resources, $collection->getResources());
} | [
"public",
"function",
"addCollection",
"(",
"self",
"$",
"collection",
")",
"{",
"$",
"this",
"->",
"renderDefinitions",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"renderDefinitions",
",",
"$",
"collection",
"->",
"all",
"(",
")",
")",
";",
"$",
... | Adds a render definition collection at the end of the current set by appending all
render definitions of the added collection.
@param RenderDefinitionCollection $collection | [
"Adds",
"a",
"render",
"definition",
"collection",
"at",
"the",
"end",
"of",
"the",
"current",
"set",
"by",
"appending",
"all",
"render",
"definitions",
"of",
"the",
"added",
"collection",
"."
] | a24937be00e1a8f0b35f92db0c722907339b1ccb | https://github.com/Bartacus/BartacusBundle/blob/a24937be00e1a8f0b35f92db0c722907339b1ccb/ContentElement/Definition/RenderDefinitionCollection.php#L106-L110 | train |
Bartacus/BartacusBundle | ContentElement/Loader/ContentElementConfigLoader.php | ContentElementConfigLoader.loadTypoScript | private function loadTypoScript(): string
{
if (null === $this->options['cache_dir']) {
return $this->concatenateTypoScript();
}
$cache = $this->getConfigCacheFactory()
->cache($this->options['cache_dir'].'/content_elements.typoscript',
function (ConfigCacheInterface $cache) {
$cache->write(
$this->concatenateTypoScript(),
$this->getRenderDefinitionCollection()->getResources()
);
}
)
;
return \file_get_contents($cache->getPath());
} | php | private function loadTypoScript(): string
{
if (null === $this->options['cache_dir']) {
return $this->concatenateTypoScript();
}
$cache = $this->getConfigCacheFactory()
->cache($this->options['cache_dir'].'/content_elements.typoscript',
function (ConfigCacheInterface $cache) {
$cache->write(
$this->concatenateTypoScript(),
$this->getRenderDefinitionCollection()->getResources()
);
}
)
;
return \file_get_contents($cache->getPath());
} | [
"private",
"function",
"loadTypoScript",
"(",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"options",
"[",
"'cache_dir'",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"concatenateTypoScript",
"(",
")",
";",
"}",
"$",
"cache",
"=... | Load the TypoScript code for the content element render definitions
itself without adding them to the template.
@throws \Exception
@return string | [
"Load",
"the",
"TypoScript",
"code",
"for",
"the",
"content",
"element",
"render",
"definitions",
"itself",
"without",
"adding",
"them",
"to",
"the",
"template",
"."
] | a24937be00e1a8f0b35f92db0c722907339b1ccb | https://github.com/Bartacus/BartacusBundle/blob/a24937be00e1a8f0b35f92db0c722907339b1ccb/ContentElement/Loader/ContentElementConfigLoader.php#L190-L208 | train |
softberg/quantum-core | src/Libraries/JWToken/JWToken.php | JWToken.compose | public function compose($keyId = null, $head = null) {
if (!$this->payload)
throw new \Firebase\JWT\BeforeValidException(ExceptionMessages::JWT_PAYLOAD_NOT_FOUND);
return parent::encode($this->payload, $this->key, $this->algorithm, $keyId, $head);
} | php | public function compose($keyId = null, $head = null) {
if (!$this->payload)
throw new \Firebase\JWT\BeforeValidException(ExceptionMessages::JWT_PAYLOAD_NOT_FOUND);
return parent::encode($this->payload, $this->key, $this->algorithm, $keyId, $head);
} | [
"public",
"function",
"compose",
"(",
"$",
"keyId",
"=",
"null",
",",
"$",
"head",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"payload",
")",
"throw",
"new",
"\\",
"Firebase",
"\\",
"JWT",
"\\",
"BeforeValidException",
"(",
"ExceptionMes... | Composes and signs the JWT
@param mixed $keyId
@param mixed $head
@return string
@throws \Firebase\JWT\BeforeValidException | [
"Composes",
"and",
"signs",
"the",
"JWT"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/JWToken/JWToken.php#L92-L97 | train |
softberg/quantum-core | src/Http/Request.php | Request.hasFile | public static function hasFile($key) {
if (isset($_FILES[$key]) === false || (isset($_FILES[$key]['error']) && $_FILES[$key]['error'] != 0)) {
return false;
}
return true;
} | php | public static function hasFile($key) {
if (isset($_FILES[$key]) === false || (isset($_FILES[$key]['error']) && $_FILES[$key]['error'] != 0)) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"hasFile",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_FILES",
"[",
"$",
"key",
"]",
")",
"===",
"false",
"||",
"(",
"isset",
"(",
"$",
"_FILES",
"[",
"$",
"key",
"]",
"[",
"'error'",
"]",
")",
"&&... | Checks to see if request contains file
@return bool | [
"Checks",
"to",
"see",
"if",
"request",
"contains",
"file"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Http/Request.php#L83-L88 | train |
softberg/quantum-core | src/Http/Request.php | Request.getAuthorizationBearer | public function getAuthorizationBearer() {
$allHeaders = array_change_key_case(parent::getHeaders(), CASE_UPPER);
if (array_key_exists('AUTHORIZATION', $allHeaders)) {
if (preg_match('/Bearer\s(\S+)/', $allHeaders['AUTHORIZATION'], $matches)) {
return $matches[1];
}
} else {
throw new \Exception(ExceptionMessages::AUTH_BEARER_NOT_FOUND);
}
} | php | public function getAuthorizationBearer() {
$allHeaders = array_change_key_case(parent::getHeaders(), CASE_UPPER);
if (array_key_exists('AUTHORIZATION', $allHeaders)) {
if (preg_match('/Bearer\s(\S+)/', $allHeaders['AUTHORIZATION'], $matches)) {
return $matches[1];
}
} else {
throw new \Exception(ExceptionMessages::AUTH_BEARER_NOT_FOUND);
}
} | [
"public",
"function",
"getAuthorizationBearer",
"(",
")",
"{",
"$",
"allHeaders",
"=",
"array_change_key_case",
"(",
"parent",
"::",
"getHeaders",
"(",
")",
",",
"CASE_UPPER",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'AUTHORIZATION'",
",",
"$",
"allHeaders... | Gets Authorization Bearer token
@return string
@throws \Exception | [
"Gets",
"Authorization",
"Bearer",
"token"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Http/Request.php#L112-L122 | train |
vegas-cmf/core | src/Bootstrap/ErrorHandlerInitializerTrait.php | ErrorHandlerInitializerTrait.initErrorHandler | public function initErrorHandler(Config $config)
{
if ($this->getDI()->get('environment') === Constants::PROD_ENV) {
return;
}
$this->debug = new Debug();
$this->debug->listen();
set_error_handler([$this, 'errorHandler'], error_reporting());
register_shutdown_function(function() {
if ((error_reporting() & E_ERROR) === E_ERROR) {
$lastError = error_get_last();
if ($lastError['type'] === E_ERROR) {
// fatal error
$this->errorHandler(E_ERROR, $lastError['message'], $lastError['file'], $lastError['line']);
}
}
});
} | php | public function initErrorHandler(Config $config)
{
if ($this->getDI()->get('environment') === Constants::PROD_ENV) {
return;
}
$this->debug = new Debug();
$this->debug->listen();
set_error_handler([$this, 'errorHandler'], error_reporting());
register_shutdown_function(function() {
if ((error_reporting() & E_ERROR) === E_ERROR) {
$lastError = error_get_last();
if ($lastError['type'] === E_ERROR) {
// fatal error
$this->errorHandler(E_ERROR, $lastError['message'], $lastError['file'], $lastError['line']);
}
}
});
} | [
"public",
"function",
"initErrorHandler",
"(",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDI",
"(",
")",
"->",
"get",
"(",
"'environment'",
")",
"===",
"Constants",
"::",
"PROD_ENV",
")",
"{",
"return",
";",
"}",
"$",
"this",
... | Initializes error handling | [
"Initializes",
"error",
"handling"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Bootstrap/ErrorHandlerInitializerTrait.php#L20-L41 | train |
vegas-cmf/core | src/Bootstrap/ErrorHandlerInitializerTrait.php | ErrorHandlerInitializerTrait.errorHandler | public function errorHandler($code, $message, $file, $line)
{
$this->debug->setShowBackTrace(false);
$this->debug->onUncaughtException(new \ErrorException($message, $code, 0, $file, $line));
} | php | public function errorHandler($code, $message, $file, $line)
{
$this->debug->setShowBackTrace(false);
$this->debug->onUncaughtException(new \ErrorException($message, $code, 0, $file, $line));
} | [
"public",
"function",
"errorHandler",
"(",
"$",
"code",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"setShowBackTrace",
"(",
"false",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"onUncaughtExcept... | Create default error handler.
@param $code
@param $message
@param $file
@param $line | [
"Create",
"default",
"error",
"handler",
"."
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Bootstrap/ErrorHandlerInitializerTrait.php#L51-L55 | train |
bitban/php-code-quality-tools | src/Infrastructure/CodeSniffer/Standards/Custom/Sniffs/CodeAnalysis/VariableAnalysisSniff.php | Custom_Sniffs_CodeAnalysis_VariableAnalysisSniff.processVariable | protected function processVariable(
PHP_CodeSniffer_File $phpcsFile,
$stackPtr
) {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
$varName = $this->normalizeVarName($token['content']);
if (($currScope = $this->findVariableScope($phpcsFile, $stackPtr)) === false) {
return;
}
//static $dump_token = false;
//if ($varName == 'property') {
// $dump_token = true;
//}
//if ($dump_token) {
// echo "Found variable {$varName} on line {$token['line']} in scope {$currScope}.\n" . print_r($token, true);
// echo "Prev:\n" . print_r($tokens[$stackPtr - 1], true);
//}
// Determine if variable is being assigned or read.
// Read methods that preempt assignment:
// Are we a $object->$property type symbolic reference?
// Possible assignment methods:
// Is a mandatory function/closure parameter
// Is an optional function/closure parameter with non-null value
// Is closure use declaration of a variable defined within containing scope
// catch (...) block start
// $this within a class (but not within a closure).
// $GLOBALS, $_REQUEST, etc superglobals.
// $var part of class::$var static member
// Assignment via =
// Assignment via list (...) =
// Declares as a global
// Declares as a static
// Assignment via foreach (... as ...) { }
// Pass-by-reference to known pass-by-reference function
// Are we a $object->$property type symbolic reference?
if ($this->checkForSymbolicObjectProperty($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a function or closure parameter?
if ($this->checkForFunctionPrototype($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a catch parameter?
if ($this->checkForCatchBlock($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we $this within a class?
if ($this->checkForThisWithinClass($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a $GLOBALS, $_REQUEST, etc superglobal?
if ($this->checkForSuperGlobal($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// $var part of class::$var static member
if ($this->checkForStaticMember($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Is the next non-whitespace an assignment?
if ($this->checkForAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// OK, are we within a list (...) = construct?
if ($this->checkForListAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a global declaration?
if ($this->checkForGlobalDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a static declaration?
if ($this->checkForStaticDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a foreach loopvar?
if ($this->checkForForeachLoopVar($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we pass-by-reference to known pass-by-reference function?
if ($this->checkForPassByReferenceFunctionCall($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// OK, we don't appear to be a write to the var, assume we're a read.
$this->markVariableReadAndWarnIfUndefined($phpcsFile, $varName, $stackPtr, $currScope);
} | php | protected function processVariable(
PHP_CodeSniffer_File $phpcsFile,
$stackPtr
) {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
$varName = $this->normalizeVarName($token['content']);
if (($currScope = $this->findVariableScope($phpcsFile, $stackPtr)) === false) {
return;
}
//static $dump_token = false;
//if ($varName == 'property') {
// $dump_token = true;
//}
//if ($dump_token) {
// echo "Found variable {$varName} on line {$token['line']} in scope {$currScope}.\n" . print_r($token, true);
// echo "Prev:\n" . print_r($tokens[$stackPtr - 1], true);
//}
// Determine if variable is being assigned or read.
// Read methods that preempt assignment:
// Are we a $object->$property type symbolic reference?
// Possible assignment methods:
// Is a mandatory function/closure parameter
// Is an optional function/closure parameter with non-null value
// Is closure use declaration of a variable defined within containing scope
// catch (...) block start
// $this within a class (but not within a closure).
// $GLOBALS, $_REQUEST, etc superglobals.
// $var part of class::$var static member
// Assignment via =
// Assignment via list (...) =
// Declares as a global
// Declares as a static
// Assignment via foreach (... as ...) { }
// Pass-by-reference to known pass-by-reference function
// Are we a $object->$property type symbolic reference?
if ($this->checkForSymbolicObjectProperty($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a function or closure parameter?
if ($this->checkForFunctionPrototype($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a catch parameter?
if ($this->checkForCatchBlock($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we $this within a class?
if ($this->checkForThisWithinClass($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a $GLOBALS, $_REQUEST, etc superglobal?
if ($this->checkForSuperGlobal($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// $var part of class::$var static member
if ($this->checkForStaticMember($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Is the next non-whitespace an assignment?
if ($this->checkForAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// OK, are we within a list (...) = construct?
if ($this->checkForListAssignment($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a global declaration?
if ($this->checkForGlobalDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a static declaration?
if ($this->checkForStaticDeclaration($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we a foreach loopvar?
if ($this->checkForForeachLoopVar($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// Are we pass-by-reference to known pass-by-reference function?
if ($this->checkForPassByReferenceFunctionCall($phpcsFile, $stackPtr, $varName, $currScope)) {
return;
}
// OK, we don't appear to be a write to the var, assume we're a read.
$this->markVariableReadAndWarnIfUndefined($phpcsFile, $varName, $stackPtr, $currScope);
} | [
"protected",
"function",
"processVariable",
"(",
"PHP_CodeSniffer_File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",
"]",
... | Called to process normal member vars.
@param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
token was found.
@param int $stackPtr The position where the token was found.
@return void | [
"Called",
"to",
"process",
"normal",
"member",
"vars",
"."
] | 8fba7ad95e44d6e5e0e963c40b60ee9f6eb170fe | https://github.com/bitban/php-code-quality-tools/blob/8fba7ad95e44d6e5e0e963c40b60ee9f6eb170fe/src/Infrastructure/CodeSniffer/Standards/Custom/Sniffs/CodeAnalysis/VariableAnalysisSniff.php#L1214-L1317 | train |
bitban/php-code-quality-tools | src/Infrastructure/CodeSniffer/Standards/Custom/Sniffs/CodeAnalysis/VariableAnalysisSniff.php | Custom_Sniffs_CodeAnalysis_VariableAnalysisSniff.processVariableInString | protected function processVariableInString(
PHP_CodeSniffer_File
$phpcsFile,
$stackPtr
) {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
if (!preg_match_all($this->_double_quoted_variable_regexp, $token['content'], $matches)) {
return;
}
$currScope = $this->findVariableScope($phpcsFile, $stackPtr);
foreach ($matches[1] as $varName) {
$varName = $this->normalizeVarName($varName);
// Are we $this within a class?
if ($this->checkForThisWithinClass($phpcsFile, $stackPtr, $varName, $currScope)) {
continue;
}
if ($this->checkForSuperGlobal($phpcsFile, $stackPtr, $varName, $currScope)) {
continue;
}
$this->markVariableReadAndWarnIfUndefined($phpcsFile, $varName, $stackPtr, $currScope);
}
} | php | protected function processVariableInString(
PHP_CodeSniffer_File
$phpcsFile,
$stackPtr
) {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
if (!preg_match_all($this->_double_quoted_variable_regexp, $token['content'], $matches)) {
return;
}
$currScope = $this->findVariableScope($phpcsFile, $stackPtr);
foreach ($matches[1] as $varName) {
$varName = $this->normalizeVarName($varName);
// Are we $this within a class?
if ($this->checkForThisWithinClass($phpcsFile, $stackPtr, $varName, $currScope)) {
continue;
}
if ($this->checkForSuperGlobal($phpcsFile, $stackPtr, $varName, $currScope)) {
continue;
}
$this->markVariableReadAndWarnIfUndefined($phpcsFile, $varName, $stackPtr, $currScope);
}
} | [
"protected",
"function",
"processVariableInString",
"(",
"PHP_CodeSniffer_File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"tokens",
"=",
"$",
"phpcsFile",
"->",
"getTokens",
"(",
")",
";",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"stackPtr",... | Called to process variables found in double quoted strings.
Note that there may be more than one variable in the string, which will
result only in one call for the string.
@param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
token was found.
@param int $stackPtr The position where the double quoted
string was found.
@return void | [
"Called",
"to",
"process",
"variables",
"found",
"in",
"double",
"quoted",
"strings",
"."
] | 8fba7ad95e44d6e5e0e963c40b60ee9f6eb170fe | https://github.com/bitban/php-code-quality-tools/blob/8fba7ad95e44d6e5e0e963c40b60ee9f6eb170fe/src/Infrastructure/CodeSniffer/Standards/Custom/Sniffs/CodeAnalysis/VariableAnalysisSniff.php#L1332-L1356 | train |
bitban/php-code-quality-tools | src/Infrastructure/CodeSniffer/Standards/Custom/Sniffs/CodeAnalysis/VariableAnalysisSniff.php | Custom_Sniffs_CodeAnalysis_VariableAnalysisSniff.processScopeClose | protected function processScopeClose(
PHP_CodeSniffer_File
$phpcsFile,
$stackPtr
) {
$scopeInfo = $this->getScopeInfo($stackPtr, false);
if (is_null($scopeInfo)) {
return;
}
foreach ($scopeInfo->variables as $varInfo) {
if ($varInfo->ignoreUnused || isset($varInfo->firstRead)) {
continue;
}
if ($this->allowUnusedFunctionParameters && $varInfo->scopeType == 'param') {
continue;
}
if ($varInfo->passByReference && isset($varInfo->firstInitialized)) {
// If we're pass-by-reference then it's a common pattern to
// use the variable to return data to the caller, so any
// assignment also counts as "variable use" for the purposes
// of "unused variable" warnings.
continue;
}
if (isset($varInfo->firstDeclared)) {
$phpcsFile->addWarning(
"Unused %s %s.",
$varInfo->firstDeclared,
'UnusedVariable',
array(
VariableInfo::$scopeTypeDescriptions[$varInfo->scopeType],
"\${$varInfo->name}",
)
);
}
if (isset($varInfo->firstInitialized)) {
$phpcsFile->addWarning(
"Unused %s %s.",
$varInfo->firstInitialized,
'UnusedVariable',
array(
VariableInfo::$scopeTypeDescriptions[$varInfo->scopeType],
"\${$varInfo->name}",
)
);
}
}
} | php | protected function processScopeClose(
PHP_CodeSniffer_File
$phpcsFile,
$stackPtr
) {
$scopeInfo = $this->getScopeInfo($stackPtr, false);
if (is_null($scopeInfo)) {
return;
}
foreach ($scopeInfo->variables as $varInfo) {
if ($varInfo->ignoreUnused || isset($varInfo->firstRead)) {
continue;
}
if ($this->allowUnusedFunctionParameters && $varInfo->scopeType == 'param') {
continue;
}
if ($varInfo->passByReference && isset($varInfo->firstInitialized)) {
// If we're pass-by-reference then it's a common pattern to
// use the variable to return data to the caller, so any
// assignment also counts as "variable use" for the purposes
// of "unused variable" warnings.
continue;
}
if (isset($varInfo->firstDeclared)) {
$phpcsFile->addWarning(
"Unused %s %s.",
$varInfo->firstDeclared,
'UnusedVariable',
array(
VariableInfo::$scopeTypeDescriptions[$varInfo->scopeType],
"\${$varInfo->name}",
)
);
}
if (isset($varInfo->firstInitialized)) {
$phpcsFile->addWarning(
"Unused %s %s.",
$varInfo->firstInitialized,
'UnusedVariable',
array(
VariableInfo::$scopeTypeDescriptions[$varInfo->scopeType],
"\${$varInfo->name}",
)
);
}
}
} | [
"protected",
"function",
"processScopeClose",
"(",
"PHP_CodeSniffer_File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"scopeInfo",
"=",
"$",
"this",
"->",
"getScopeInfo",
"(",
"$",
"stackPtr",
",",
"false",
")",
";",
"if",
"(",
"is_null",
"(",
... | Called to process the end of a scope.
Note that although triggered by the closing curly brace of the scope, $stackPtr is
the scope conditional, not the closing curly brace.
@param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
token was found.
@param int $stackPtr The position of the scope conditional.
@return void | [
"Called",
"to",
"process",
"the",
"end",
"of",
"a",
"scope",
"."
] | 8fba7ad95e44d6e5e0e963c40b60ee9f6eb170fe | https://github.com/bitban/php-code-quality-tools/blob/8fba7ad95e44d6e5e0e963c40b60ee9f6eb170fe/src/Infrastructure/CodeSniffer/Standards/Custom/Sniffs/CodeAnalysis/VariableAnalysisSniff.php#L1449-L1495 | train |
vegas-cmf/core | src/Cli/Task/Action.php | Action.validate | public function validate($args)
{
$matched = false;
//validates arguments
foreach ($args as $arg => $value) {
//non-named option are skipped from validation
if (is_numeric($arg)) continue;
//validates action options
foreach ($this->options as $option) {
//checks if options matches specified parameter
if ($option->matchParam($arg)) {
//validates option
if (!$option->validate($value)) {
throw new InvalidArgumentException($arg, $value);
}
$matched = true;
}
}
if (!$matched) {
throw new InvalidOptionException($arg);
}
}
//validates required options
foreach ($this->options as $option) {
if (!$option->isRequired()) {
continue;
}
if (!$option->getValue($args)) {
throw new MissingRequiredArgumentException($option->getName());
}
}
return true;
} | php | public function validate($args)
{
$matched = false;
//validates arguments
foreach ($args as $arg => $value) {
//non-named option are skipped from validation
if (is_numeric($arg)) continue;
//validates action options
foreach ($this->options as $option) {
//checks if options matches specified parameter
if ($option->matchParam($arg)) {
//validates option
if (!$option->validate($value)) {
throw new InvalidArgumentException($arg, $value);
}
$matched = true;
}
}
if (!$matched) {
throw new InvalidOptionException($arg);
}
}
//validates required options
foreach ($this->options as $option) {
if (!$option->isRequired()) {
continue;
}
if (!$option->getValue($args)) {
throw new MissingRequiredArgumentException($option->getName());
}
}
return true;
} | [
"public",
"function",
"validate",
"(",
"$",
"args",
")",
"{",
"$",
"matched",
"=",
"false",
";",
"//validates arguments",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
"=>",
"$",
"value",
")",
"{",
"//non-named option are skipped from validation",
"if",
"(",
... | Validates current action options
@param array $args
@throws Exception\MissingRequiredArgumentException
@throws Exception\InvalidArgumentException
@throws Exception\InvalidOptionException
@return bool | [
"Validates",
"current",
"action",
"options"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Cli/Task/Action.php#L112-L147 | train |
softberg/quantum-core | src/Libraries/Mailer/Mailer.php | Mailer.phpMailerSettings | private function phpMailerSettings() {
$phpMailer = new PHPMailer();
if (strlen(env('MAIL_HOST')) > 0) {
$phpMailer->SMTPDebug = 0;
$phpMailer->isSMTP();
$phpMailer->Host = env('MAIL_HOST');
$phpMailer->SMTPAuth = true;
$phpMailer->SMTPSecure = env('MAIL_SMTP_SECURE');
$phpMailer->Port = env('MAIL_PORT');
$phpMailer->Username = env('MAIL_USERNAME');
$phpMailer->Password = env('MAIL_PASSWORD');
} else {
$phpMailer->isMail();
}
$phpMailer->isHTML(true);
$this->mailer = $phpMailer;
} | php | private function phpMailerSettings() {
$phpMailer = new PHPMailer();
if (strlen(env('MAIL_HOST')) > 0) {
$phpMailer->SMTPDebug = 0;
$phpMailer->isSMTP();
$phpMailer->Host = env('MAIL_HOST');
$phpMailer->SMTPAuth = true;
$phpMailer->SMTPSecure = env('MAIL_SMTP_SECURE');
$phpMailer->Port = env('MAIL_PORT');
$phpMailer->Username = env('MAIL_USERNAME');
$phpMailer->Password = env('MAIL_PASSWORD');
} else {
$phpMailer->isMail();
}
$phpMailer->isHTML(true);
$this->mailer = $phpMailer;
} | [
"private",
"function",
"phpMailerSettings",
"(",
")",
"{",
"$",
"phpMailer",
"=",
"new",
"PHPMailer",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"env",
"(",
"'MAIL_HOST'",
")",
")",
">",
"0",
")",
"{",
"$",
"phpMailer",
"->",
"SMTPDebug",
"=",
"0",
";"... | PHP Mailer Settings
Configures the PHP Mailer
@uses \PHPMailer
@return void | [
"PHP",
"Mailer",
"Settings"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Mailer/Mailer.php#L53-L71 | train |
softberg/quantum-core | src/Libraries/Mailer/Mailer.php | Mailer.createFromTemplate | private function createFromTemplate($message, $template) {
ob_start();
ob_implicit_flush(false);
if (is_array($message) && !empty($message)) {
extract($message, EXTR_OVERWRITE);
}
$current_module = RouteController::$currentRoute['module'];
$templatePath = MODULES_DIR . '/' . $current_module . '/Views/' . $template . '.php';
require $templatePath;
return ob_get_clean();
} | php | private function createFromTemplate($message, $template) {
ob_start();
ob_implicit_flush(false);
if (is_array($message) && !empty($message)) {
extract($message, EXTR_OVERWRITE);
}
$current_module = RouteController::$currentRoute['module'];
$templatePath = MODULES_DIR . '/' . $current_module . '/Views/' . $template . '.php';
require $templatePath;
return ob_get_clean();
} | [
"private",
"function",
"createFromTemplate",
"(",
"$",
"message",
",",
"$",
"template",
")",
"{",
"ob_start",
"(",
")",
";",
"ob_implicit_flush",
"(",
"false",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"message",
")",
"&&",
"!",
"empty",
"(",
"$",
"me... | Create From Template
Create message body from email template
@param mixed $message
@param string $template
@return string | [
"Create",
"From",
"Template"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Mailer/Mailer.php#L143-L155 | train |
softberg/quantum-core | src/Libraries/Mailer/Mailer.php | Mailer.createStringAttachments | private function createStringAttachments($attachments)
{
if (array_key_exists('string', $attachments)) {
$this->mailer->addStringAttachment($attachments['string'], $attachments['name']);
} else {
foreach ($attachments as $attachment) {
$this->mailer->addStringAttachment($attachment['string'], $attachment['name']);
}
}
} | php | private function createStringAttachments($attachments)
{
if (array_key_exists('string', $attachments)) {
$this->mailer->addStringAttachment($attachments['string'], $attachments['name']);
} else {
foreach ($attachments as $attachment) {
$this->mailer->addStringAttachment($attachment['string'], $attachment['name']);
}
}
} | [
"private",
"function",
"createStringAttachments",
"(",
"$",
"attachments",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'string'",
",",
"$",
"attachments",
")",
")",
"{",
"$",
"this",
"->",
"mailer",
"->",
"addStringAttachment",
"(",
"$",
"attachments",
"[",... | Create String Attachments
Add attachments from a string
@param mixed $attachments
@uses \PHPMailer | [
"Create",
"String",
"Attachments"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Mailer/Mailer.php#L183-L192 | train |
vegas-cmf/core | src/Tag/Pagination.php | Pagination.render | public function render($page, $settings=array())
{
$this->settings = array_merge($this->settings, $settings);
if (!empty($page->currentUri)) {
$this->htmlAHref = str_replace('?', '&', $this->htmlAHref);
$this->currentUri = $page->currentUri;
} else {
$this->currentUri = $this->di->get('router')->getRewriteUri();
}
$html = '';
if ($page->total_pages > 1) {
$this->page = $page;
$this->checkBoundary();
$html .= '<ul class="pagination">';
$html .= $this->renderPreviousButton();
$html .= $this->renderPages();
$html .= $this->renderNextButton();
$html .= '</ul>';
}
return $html;
} | php | public function render($page, $settings=array())
{
$this->settings = array_merge($this->settings, $settings);
if (!empty($page->currentUri)) {
$this->htmlAHref = str_replace('?', '&', $this->htmlAHref);
$this->currentUri = $page->currentUri;
} else {
$this->currentUri = $this->di->get('router')->getRewriteUri();
}
$html = '';
if ($page->total_pages > 1) {
$this->page = $page;
$this->checkBoundary();
$html .= '<ul class="pagination">';
$html .= $this->renderPreviousButton();
$html .= $this->renderPages();
$html .= $this->renderNextButton();
$html .= '</ul>';
}
return $html;
} | [
"public",
"function",
"render",
"(",
"$",
"page",
",",
"$",
"settings",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"settings",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"settings",
",",
"$",
"settings",
")",
";",
"if",
"(",
"!",
"empty"... | Renders pagination html
@param $page
@param array $settings
@return string | [
"Renders",
"pagination",
"html"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Tag/Pagination.php#L86-L111 | train |
vegas-cmf/core | src/Tag/Pagination.php | Pagination.checkBoundary | private function checkBoundary()
{
if($this->page->current > $this->page->total_pages) {
$queryLink = !empty($this->page->currentUri) ? '&' : '?';
$redirectUrl = substr($this->currentUri, 1) . $queryLink . 'page=' . $this->page->total_pages;
$this->di->get('response')->redirect($redirectUrl);
}
} | php | private function checkBoundary()
{
if($this->page->current > $this->page->total_pages) {
$queryLink = !empty($this->page->currentUri) ? '&' : '?';
$redirectUrl = substr($this->currentUri, 1) . $queryLink . 'page=' . $this->page->total_pages;
$this->di->get('response')->redirect($redirectUrl);
}
} | [
"private",
"function",
"checkBoundary",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"current",
">",
"$",
"this",
"->",
"page",
"->",
"total_pages",
")",
"{",
"$",
"queryLink",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"page",
"->",
... | Checks if current page fit in total pages
@internal | [
"Checks",
"if",
"current",
"page",
"fit",
"in",
"total",
"pages"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Tag/Pagination.php#L117-L126 | train |
vegas-cmf/core | src/Tag/Pagination.php | Pagination.renderPreviousButton | private function renderPreviousButton()
{
$before = $this->page->before;
$extraClass = $before ? '' : ' not-active';
if (empty($before)) {
$before = 1;
}
return $this->renderElement($before, $this->settings['label_previous'], 'prev'.$extraClass);
} | php | private function renderPreviousButton()
{
$before = $this->page->before;
$extraClass = $before ? '' : ' not-active';
if (empty($before)) {
$before = 1;
}
return $this->renderElement($before, $this->settings['label_previous'], 'prev'.$extraClass);
} | [
"private",
"function",
"renderPreviousButton",
"(",
")",
"{",
"$",
"before",
"=",
"$",
"this",
"->",
"page",
"->",
"before",
";",
"$",
"extraClass",
"=",
"$",
"before",
"?",
"''",
":",
"' not-active'",
";",
"if",
"(",
"empty",
"(",
"$",
"before",
")",
... | Renders button - previous page
@return string
@internal | [
"Renders",
"button",
"-",
"previous",
"page"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Tag/Pagination.php#L134-L142 | train |
vegas-cmf/core | src/Tag/Pagination.php | Pagination.renderNextButton | private function renderNextButton()
{
$next = $this->page->next;
$extraClass = $next ? '' : ' not-active';
if (empty($next)) {
$next = $this->page->total_pages;
}
return $this->renderElement($next, $this->settings['label_next'], 'next'.$extraClass);
} | php | private function renderNextButton()
{
$next = $this->page->next;
$extraClass = $next ? '' : ' not-active';
if (empty($next)) {
$next = $this->page->total_pages;
}
return $this->renderElement($next, $this->settings['label_next'], 'next'.$extraClass);
} | [
"private",
"function",
"renderNextButton",
"(",
")",
"{",
"$",
"next",
"=",
"$",
"this",
"->",
"page",
"->",
"next",
";",
"$",
"extraClass",
"=",
"$",
"next",
"?",
"''",
":",
"' not-active'",
";",
"if",
"(",
"empty",
"(",
"$",
"next",
")",
")",
"{"... | Renders button - next page
@return string
@internal | [
"Renders",
"button",
"-",
"next",
"page"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Tag/Pagination.php#L150-L158 | train |
vegas-cmf/core | src/Tag/Pagination.php | Pagination.renderElement | private function renderElement($page, $title, $class = '')
{
$href = sprintf($this->htmlHref, $this->currentUri, $page);
$href .= $this->getUrlParams();
$element = sprintf($this->htmlAHref, $href, $title);
return sprintf($this->htmlElement, $class, $element);
} | php | private function renderElement($page, $title, $class = '')
{
$href = sprintf($this->htmlHref, $this->currentUri, $page);
$href .= $this->getUrlParams();
$element = sprintf($this->htmlAHref, $href, $title);
return sprintf($this->htmlElement, $class, $element);
} | [
"private",
"function",
"renderElement",
"(",
"$",
"page",
",",
"$",
"title",
",",
"$",
"class",
"=",
"''",
")",
"{",
"$",
"href",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"htmlHref",
",",
"$",
"this",
"->",
"currentUri",
",",
"$",
"page",
")",
";",
... | Renders html element
@param $page
@param $title
@param string $class
@return string
@internal | [
"Renders",
"html",
"element"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Tag/Pagination.php#L169-L176 | train |
vegas-cmf/core | src/Tag/Pagination.php | Pagination.renderPages | private function renderPages()
{
$html = '';
for($i=1; $i<=$this->page->total_pages; $i++) {
if ($i == $this->page->current) {
$html .= $this->renderElement($i, $i, 'active');
} elseif($this->isPrintablePage($i)) {
$html .= $this->renderElement($i, $i);
} elseif($this->isMiddleOffsetPage($i)) {
$html .= $this->renderElement($this->page->current, '...', 'more');
}
}
return $html;
} | php | private function renderPages()
{
$html = '';
for($i=1; $i<=$this->page->total_pages; $i++) {
if ($i == $this->page->current) {
$html .= $this->renderElement($i, $i, 'active');
} elseif($this->isPrintablePage($i)) {
$html .= $this->renderElement($i, $i);
} elseif($this->isMiddleOffsetPage($i)) {
$html .= $this->renderElement($this->page->current, '...', 'more');
}
}
return $html;
} | [
"private",
"function",
"renderPages",
"(",
")",
"{",
"$",
"html",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"this",
"->",
"page",
"->",
"total_pages",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"==",
... | Renders the pages list
@return string
@internal | [
"Renders",
"the",
"pages",
"list"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Tag/Pagination.php#L200-L215 | train |
vegas-cmf/core | src/Paginator/Adapter/AggregateMongo.php | AggregateMongo.getResults | public function getResults()
{
$skip = ($this->page-1)*$this->limit;
$cursor = $this->getCursor();
$cursor->skip($skip);
$results = array();
$i = 0;
while($cursor->valid() && $cursor->current() && $i++ < $this->limit) {
$object = new $this->modelName();
$object->writeAttributes($cursor->current());
$pseudoCursor = new \stdClass();
foreach ($object as $key => $value) {
$pseudoCursor->$key = $value;
}
$results[] = $pseudoCursor;
$cursor->skip();
}
return $results;
} | php | public function getResults()
{
$skip = ($this->page-1)*$this->limit;
$cursor = $this->getCursor();
$cursor->skip($skip);
$results = array();
$i = 0;
while($cursor->valid() && $cursor->current() && $i++ < $this->limit) {
$object = new $this->modelName();
$object->writeAttributes($cursor->current());
$pseudoCursor = new \stdClass();
foreach ($object as $key => $value) {
$pseudoCursor->$key = $value;
}
$results[] = $pseudoCursor;
$cursor->skip();
}
return $results;
} | [
"public",
"function",
"getResults",
"(",
")",
"{",
"$",
"skip",
"=",
"(",
"$",
"this",
"->",
"page",
"-",
"1",
")",
"*",
"$",
"this",
"->",
"limit",
";",
"$",
"cursor",
"=",
"$",
"this",
"->",
"getCursor",
"(",
")",
";",
"$",
"cursor",
"->",
"s... | Returns results for current page
@return array | [
"Returns",
"results",
"for",
"current",
"page"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Paginator/Adapter/AggregateMongo.php#L39-L64 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.stateless | public function stateless($username, $password)
{
$user = $this->sentinel->stateless(
[
'email' => $username,
'password' => $password,
]
);
if ( ! ($user instanceof CartalystUserInterface)) {
return false;
}
// This is still a login, and while we don't want persistence, we do want it to be recorded
$this->sentinel->getUserRepository()->recordLogin($user);
event( new CmsUserLoggedIn($user, true) );
return true;
} | php | public function stateless($username, $password)
{
$user = $this->sentinel->stateless(
[
'email' => $username,
'password' => $password,
]
);
if ( ! ($user instanceof CartalystUserInterface)) {
return false;
}
// This is still a login, and while we don't want persistence, we do want it to be recorded
$this->sentinel->getUserRepository()->recordLogin($user);
event( new CmsUserLoggedIn($user, true) );
return true;
} | [
"public",
"function",
"stateless",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"stateless",
"(",
"[",
"'email'",
"=>",
"$",
"username",
",",
"'password'",
"=>",
"$",
"password",
",",
"]",... | Performs stateless login.
@param string $username
@param string $password
@return bool | [
"Performs",
"stateless",
"login",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L132-L150 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.forceUser | public function forceUser(UserInterface $user, $remember = true)
{
$user = $this->sentinel->authenticate($user, $remember);
if ( ! ($user instanceof CartalystUserInterface)) {
return false;
}
event( new CmsUserLoggedIn($user, false, true) );
return true;
} | php | public function forceUser(UserInterface $user, $remember = true)
{
$user = $this->sentinel->authenticate($user, $remember);
if ( ! ($user instanceof CartalystUserInterface)) {
return false;
}
event( new CmsUserLoggedIn($user, false, true) );
return true;
} | [
"public",
"function",
"forceUser",
"(",
"UserInterface",
"$",
"user",
",",
"$",
"remember",
"=",
"true",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"authenticate",
"(",
"$",
"user",
",",
"$",
"remember",
")",
";",
"if",
"(",
"!"... | Forces a user to be logged in without credentials verification.
@param UserInterface|CartalystUserInterface $user
@param bool $remember
@return bool | [
"Forces",
"a",
"user",
"to",
"be",
"logged",
"in",
"without",
"credentials",
"verification",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L159-L169 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.forceUserStateless | public function forceUserStateless(UserInterface $user)
{
$user = $this->sentinel->authenticate($user, false, false);
if ( ! ($user instanceof CartalystUserInterface)) {
return false;
}
event( new CmsUserLoggedIn($user, true, true) );
return true;
} | php | public function forceUserStateless(UserInterface $user)
{
$user = $this->sentinel->authenticate($user, false, false);
if ( ! ($user instanceof CartalystUserInterface)) {
return false;
}
event( new CmsUserLoggedIn($user, true, true) );
return true;
} | [
"public",
"function",
"forceUserStateless",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"authenticate",
"(",
"$",
"user",
",",
"false",
",",
"false",
")",
";",
"if",
"(",
"!",
"(",
"$",
"user",
... | Forces a user to be logged in without credentials verification,
without persistence, and without marking it as a login.
@param UserInterface|CartalystUserInterface $user
@return bool | [
"Forces",
"a",
"user",
"to",
"be",
"logged",
"in",
"without",
"credentials",
"verification",
"without",
"persistence",
"and",
"without",
"marking",
"it",
"as",
"a",
"login",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L178-L188 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.assign | public function assign($role, UserInterface $user)
{
$roles = is_array($role) ? $role : [ $role ];
$count = 0;
foreach ($roles as $singleRole) {
$count += $this->assignSingleRole($singleRole, $user) ? 1 : 0;
}
if ($count !== count($roles)) {
return false;
}
$this->fireUserPermissionChangeEvent($user);
return true;
} | php | public function assign($role, UserInterface $user)
{
$roles = is_array($role) ? $role : [ $role ];
$count = 0;
foreach ($roles as $singleRole) {
$count += $this->assignSingleRole($singleRole, $user) ? 1 : 0;
}
if ($count !== count($roles)) {
return false;
}
$this->fireUserPermissionChangeEvent($user);
return true;
} | [
"public",
"function",
"assign",
"(",
"$",
"role",
",",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"roles",
"=",
"is_array",
"(",
"$",
"role",
")",
"?",
"$",
"role",
":",
"[",
"$",
"role",
"]",
";",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
... | Assigns one or several roles to a user.
@param string|string[] $role
@param UserInterface $user
@return bool | [
"Assigns",
"one",
"or",
"several",
"roles",
"to",
"a",
"user",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L258-L274 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.unassign | public function unassign($role, UserInterface $user)
{
$roles = is_array($role) ? $role : [ $role ];
$count = 0;
foreach ($roles as $singleRole) {
$count += $this->unassignSingleRole($singleRole, $user) ? 1 : 0;
}
if ($count !== count($roles)) {
// @codeCoverageIgnoreStart
return false;
// @codeCoverageIgnoreEnd
}
$this->fireUserPermissionChangeEvent($user);
return true;
} | php | public function unassign($role, UserInterface $user)
{
$roles = is_array($role) ? $role : [ $role ];
$count = 0;
foreach ($roles as $singleRole) {
$count += $this->unassignSingleRole($singleRole, $user) ? 1 : 0;
}
if ($count !== count($roles)) {
// @codeCoverageIgnoreStart
return false;
// @codeCoverageIgnoreEnd
}
$this->fireUserPermissionChangeEvent($user);
return true;
} | [
"public",
"function",
"unassign",
"(",
"$",
"role",
",",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"roles",
"=",
"is_array",
"(",
"$",
"role",
")",
"?",
"$",
"role",
":",
"[",
"$",
"role",
"]",
";",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",... | Removes one or several roles from a user.
@param string|string[] $role
@param UserInterface $user
@return bool | [
"Removes",
"one",
"or",
"several",
"roles",
"from",
"a",
"user",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L304-L322 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.removeRole | public function removeRole($role)
{
if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
return false;
}
/** @var EloquentRole $roleModel */
$roleModel->delete();
$this->fireRoleChangeEvent();
return true;
} | php | public function removeRole($role)
{
if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
return false;
}
/** @var EloquentRole $roleModel */
$roleModel->delete();
$this->fireRoleChangeEvent();
return true;
} | [
"public",
"function",
"removeRole",
"(",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"roleModel",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"findRoleBySlug",
"(",
"$",
"role",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"/** @var EloquentRole... | Removes a role.
@param string $role
@return bool | [
"Removes",
"a",
"role",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L448-L459 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.grantToRole | public function grantToRole($permission, $role)
{
/** @var EloquentRole $roleModel */
if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
return false;
}
$permissions = is_array($permission) ? $permission : [ $permission ];
foreach ($permissions as $singlePermission) {
$this->grantSinglePermissionToRole($singlePermission, $roleModel);
}
if ( ! $roleModel->save()) {
// @codeCoverageIgnoreStart
return false;
// @codeCoverageIgnoreEnd
}
$this->fireRoleChangeEvent();
return true;
} | php | public function grantToRole($permission, $role)
{
/** @var EloquentRole $roleModel */
if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
return false;
}
$permissions = is_array($permission) ? $permission : [ $permission ];
foreach ($permissions as $singlePermission) {
$this->grantSinglePermissionToRole($singlePermission, $roleModel);
}
if ( ! $roleModel->save()) {
// @codeCoverageIgnoreStart
return false;
// @codeCoverageIgnoreEnd
}
$this->fireRoleChangeEvent();
return true;
} | [
"public",
"function",
"grantToRole",
"(",
"$",
"permission",
",",
"$",
"role",
")",
"{",
"/** @var EloquentRole $roleModel */",
"if",
"(",
"!",
"(",
"$",
"roleModel",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"findRoleBySlug",
"(",
"$",
"role",
")",
")",
"... | Grants one or more permissions to a role.
@param string|string[] $permission
@param string $role
@return bool | [
"Grants",
"one",
"or",
"more",
"permissions",
"to",
"a",
"role",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L468-L489 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.revokeFromRole | public function revokeFromRole($permission, $role)
{
/** @var EloquentRole $roleModel */
if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
return false;
}
$permissions = is_array($permission) ? $permission : [ $permission ];
foreach ($permissions as $singlePermission) {
$this->revokeSinglePermissionFromRole($singlePermission, $roleModel);
}
if ( ! $roleModel->save()) {
// @codeCoverageIgnoreStart
return false;
// @codeCoverageIgnoreEnd
}
$this->fireRoleChangeEvent();
return true;
} | php | public function revokeFromRole($permission, $role)
{
/** @var EloquentRole $roleModel */
if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
return false;
}
$permissions = is_array($permission) ? $permission : [ $permission ];
foreach ($permissions as $singlePermission) {
$this->revokeSinglePermissionFromRole($singlePermission, $roleModel);
}
if ( ! $roleModel->save()) {
// @codeCoverageIgnoreStart
return false;
// @codeCoverageIgnoreEnd
}
$this->fireRoleChangeEvent();
return true;
} | [
"public",
"function",
"revokeFromRole",
"(",
"$",
"permission",
",",
"$",
"role",
")",
"{",
"/** @var EloquentRole $roleModel */",
"if",
"(",
"!",
"(",
"$",
"roleModel",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"findRoleBySlug",
"(",
"$",
"role",
")",
")",
... | Revokes one or more permissions of a role.
@param string|string[] $permission
@param string $role
@return bool | [
"Revokes",
"one",
"or",
"more",
"permissions",
"of",
"a",
"role",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L507-L528 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.createUser | public function createUser($username, $password, array $data = [])
{
/** @var UserInterface|EloquentUser $user */
$user = $this->sentinel->registerAndActivate([
'email' => $username,
'password' => $password,
]);
if ( ! $user) {
// @codeCoverageIgnoreStart
throw new \Exception("Failed to create user '{$username}'");
// @codeCoverageIgnoreEnd
}
$user->update($data);
return $user;
} | php | public function createUser($username, $password, array $data = [])
{
/** @var UserInterface|EloquentUser $user */
$user = $this->sentinel->registerAndActivate([
'email' => $username,
'password' => $password,
]);
if ( ! $user) {
// @codeCoverageIgnoreStart
throw new \Exception("Failed to create user '{$username}'");
// @codeCoverageIgnoreEnd
}
$user->update($data);
return $user;
} | [
"public",
"function",
"createUser",
"(",
"$",
"username",
",",
"$",
"password",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"/** @var UserInterface|EloquentUser $user */",
"$",
"user",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"registerAndActivate",
"(... | Create new CMS user.
@param string $username
@param string $password
@param array $data
@return UserInterface
@throws \Exception | [
"Create",
"new",
"CMS",
"user",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L548-L565 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.deleteUser | public function deleteUser($username)
{
/** @var UserInterface|EloquentUser $user */
if ( ! ($user = $this->sentinel->findByCredentials(['email' => $username]))) {
return false;
}
// The super admin may not be deleted.
if ($user->isAdmin()) {
return false;
}
return (bool) $user->delete();
} | php | public function deleteUser($username)
{
/** @var UserInterface|EloquentUser $user */
if ( ! ($user = $this->sentinel->findByCredentials(['email' => $username]))) {
return false;
}
// The super admin may not be deleted.
if ($user->isAdmin()) {
return false;
}
return (bool) $user->delete();
} | [
"public",
"function",
"deleteUser",
"(",
"$",
"username",
")",
"{",
"/** @var UserInterface|EloquentUser $user */",
"if",
"(",
"!",
"(",
"$",
"user",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"findByCredentials",
"(",
"[",
"'email'",
"=>",
"$",
"username",
"]"... | Removes a user from the CMS.
@param string $username
@return bool | [
"Removes",
"a",
"user",
"from",
"the",
"CMS",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L573-L586 | train |
czim/laravel-cms-auth | src/Auth/Authenticator.php | Authenticator.updatePassword | public function updatePassword($username, $password)
{
/** @var UserInterface|EloquentUser $user */
if ( ! ($user = $this->sentinel->findByCredentials(['email' => $username]))) {
return false;
}
return $this->sentinel->update($user, ['password' => $password]) instanceof UserInterface;
} | php | public function updatePassword($username, $password)
{
/** @var UserInterface|EloquentUser $user */
if ( ! ($user = $this->sentinel->findByCredentials(['email' => $username]))) {
return false;
}
return $this->sentinel->update($user, ['password' => $password]) instanceof UserInterface;
} | [
"public",
"function",
"updatePassword",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"/** @var UserInterface|EloquentUser $user */",
"if",
"(",
"!",
"(",
"$",
"user",
"=",
"$",
"this",
"->",
"sentinel",
"->",
"findByCredentials",
"(",
"[",
"'email'",
... | Sets a new password for an existing CMS user.
@param string $username
@param string $password
@return bool | [
"Sets",
"a",
"new",
"password",
"for",
"an",
"existing",
"CMS",
"user",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Auth/Authenticator.php#L595-L603 | train |
vegas-cmf/core | src/Task/CacheTask.php | CacheTask.cleanAction | public function cleanAction()
{
$this->putText("Cleaning cache...");
$di = DI::getDefault();
if ($di->has('config')) {
$config = $di->get('config');
if (!empty($config->application->view->cacheDir)) {
$this->removeFilesFromDir($config->application->view->cacheDir);
}
$this->putSuccess("Done.");
}
} | php | public function cleanAction()
{
$this->putText("Cleaning cache...");
$di = DI::getDefault();
if ($di->has('config')) {
$config = $di->get('config');
if (!empty($config->application->view->cacheDir)) {
$this->removeFilesFromDir($config->application->view->cacheDir);
}
$this->putSuccess("Done.");
}
} | [
"public",
"function",
"cleanAction",
"(",
")",
"{",
"$",
"this",
"->",
"putText",
"(",
"\"Cleaning cache...\"",
")",
";",
"$",
"di",
"=",
"DI",
"::",
"getDefault",
"(",
")",
";",
"if",
"(",
"$",
"di",
"->",
"has",
"(",
"'config'",
")",
")",
"{",
"$... | Cleans application cache | [
"Cleans",
"application",
"cache"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Task/CacheTask.php#L29-L44 | train |
vegas-cmf/core | src/Task/CacheTask.php | CacheTask.removeFilesFromDir | private function removeFilesFromDir($dir)
{
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry == "." || $entry == "..") {
continue;
}
if (!unlink($dir.DIRECTORY_SEPARATOR.$entry)) {
$this->putWarning("Can not remove: ".$dir.DIRECTORY_SEPARATOR.$entry);
}
}
closedir($handle);
}
} | php | private function removeFilesFromDir($dir)
{
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry == "." || $entry == "..") {
continue;
}
if (!unlink($dir.DIRECTORY_SEPARATOR.$entry)) {
$this->putWarning("Can not remove: ".$dir.DIRECTORY_SEPARATOR.$entry);
}
}
closedir($handle);
}
} | [
"private",
"function",
"removeFilesFromDir",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"dir",
")",
")",
"{",
"while",
"(",
"false",
"!==",
"(",
"$",
"entry",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
... | Removes files from cache dir
@param $dir
@internal | [
"Removes",
"files",
"from",
"cache",
"dir"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Task/CacheTask.php#L52-L66 | train |
alex-oleshkevich/zf-annotations | src/ZfAnnotation/EventListener/RouteListener.php | RouteListener.filterActionMethodName | protected function filterActionMethodName($name)
{
$filter = new FilterChain;
$filter->attachByName('Zend\Filter\Word\CamelCaseToDash');
$filter->attachByName('StringToLower');
return rtrim(preg_replace('/action$/', '', $filter->filter($name)), '-');
} | php | protected function filterActionMethodName($name)
{
$filter = new FilterChain;
$filter->attachByName('Zend\Filter\Word\CamelCaseToDash');
$filter->attachByName('StringToLower');
return rtrim(preg_replace('/action$/', '', $filter->filter($name)), '-');
} | [
"protected",
"function",
"filterActionMethodName",
"(",
"$",
"name",
")",
"{",
"$",
"filter",
"=",
"new",
"FilterChain",
";",
"$",
"filter",
"->",
"attachByName",
"(",
"'Zend\\Filter\\Word\\CamelCaseToDash'",
")",
";",
"$",
"filter",
"->",
"attachByName",
"(",
"... | Sanitizes action name to use in route.
@param string $name
@return string | [
"Sanitizes",
"action",
"name",
"to",
"use",
"in",
"route",
"."
] | 1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6 | https://github.com/alex-oleshkevich/zf-annotations/blob/1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6/src/ZfAnnotation/EventListener/RouteListener.php#L273-L279 | train |
alex-oleshkevich/zf-annotations | src/ZfAnnotation/EventListener/RouteListener.php | RouteListener.getRouteConfig | protected function getRouteConfig(Route $annotation)
{
return [
$annotation->getName() => [
'type' => $annotation->getType(),
'options' => [
'route' => $annotation->getRoute(),
'defaults' => $annotation->getDefaults(),
'constraints' => $annotation->getConstraints()
],
'priority' => (int) $annotation->getPriority(),
'may_terminate' => (bool) $annotation->getMayTerminate(),
'child_routes' => []
]
];
} | php | protected function getRouteConfig(Route $annotation)
{
return [
$annotation->getName() => [
'type' => $annotation->getType(),
'options' => [
'route' => $annotation->getRoute(),
'defaults' => $annotation->getDefaults(),
'constraints' => $annotation->getConstraints()
],
'priority' => (int) $annotation->getPriority(),
'may_terminate' => (bool) $annotation->getMayTerminate(),
'child_routes' => []
]
];
} | [
"protected",
"function",
"getRouteConfig",
"(",
"Route",
"$",
"annotation",
")",
"{",
"return",
"[",
"$",
"annotation",
"->",
"getName",
"(",
")",
"=>",
"[",
"'type'",
"=>",
"$",
"annotation",
"->",
"getType",
"(",
")",
",",
"'options'",
"=>",
"[",
"'rou... | Converts annotation into ZF2 route config item.
@param Route $annotation
@return array | [
"Converts",
"annotation",
"into",
"ZF2",
"route",
"config",
"item",
"."
] | 1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6 | https://github.com/alex-oleshkevich/zf-annotations/blob/1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6/src/ZfAnnotation/EventListener/RouteListener.php#L287-L302 | train |
alex-oleshkevich/zf-annotations | src/ZfAnnotation/EventListener/RouteListener.php | RouteListener.& | protected function &getReferenceForPath(array $path, array &$config)
{
$path = array_filter($path, function ($value) {
return (bool) $value;
});
$ref = &$config;
if (empty($path)) {
return $ref;
}
foreach ($path as $key) {
if (!isset($ref[$key])) {
$ref[$key] = [
'child_routes' => []
];
}
$ref = &$ref[$key]['child_routes'];
}
return $ref;
} | php | protected function &getReferenceForPath(array $path, array &$config)
{
$path = array_filter($path, function ($value) {
return (bool) $value;
});
$ref = &$config;
if (empty($path)) {
return $ref;
}
foreach ($path as $key) {
if (!isset($ref[$key])) {
$ref[$key] = [
'child_routes' => []
];
}
$ref = &$ref[$key]['child_routes'];
}
return $ref;
} | [
"protected",
"function",
"&",
"getReferenceForPath",
"(",
"array",
"$",
"path",
",",
"array",
"&",
"$",
"config",
")",
"{",
"$",
"path",
"=",
"array_filter",
"(",
"$",
"path",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"bool",
")",
... | Extend parent route with children.
@param array $path
@param array $config
@return array | [
"Extend",
"parent",
"route",
"with",
"children",
"."
] | 1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6 | https://github.com/alex-oleshkevich/zf-annotations/blob/1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6/src/ZfAnnotation/EventListener/RouteListener.php#L311-L333 | train |
alex-oleshkevich/zf-annotations | src/ZfAnnotation/EventListener/RouteListener.php | RouteListener.isValidForRootNode | public function isValidForRootNode(Route $annotation)
{
if (!$annotation->name) {
return false;
}
if (!$annotation->route) {
return false;
}
return true;
} | php | public function isValidForRootNode(Route $annotation)
{
if (!$annotation->name) {
return false;
}
if (!$annotation->route) {
return false;
}
return true;
} | [
"public",
"function",
"isValidForRootNode",
"(",
"Route",
"$",
"annotation",
")",
"{",
"if",
"(",
"!",
"$",
"annotation",
"->",
"name",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"annotation",
"->",
"route",
")",
"{",
"return",
"false"... | Checks if current route can be a class-level route.
@return bool | [
"Checks",
"if",
"current",
"route",
"can",
"be",
"a",
"class",
"-",
"level",
"route",
"."
] | 1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6 | https://github.com/alex-oleshkevich/zf-annotations/blob/1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6/src/ZfAnnotation/EventListener/RouteListener.php#L340-L351 | train |
softberg/quantum-core | src/Libraries/Lang/Lang.php | Lang.load | public function load($lang) {
$langDir = MODULES_DIR . DS . RouteController::$currentModule . '/Views/lang/' . $lang;
$files = glob($langDir . "/*.php");
if (count($files) == 0) {
throw new \Exception(ExceptionMessages::TRANSLATION_FILES_NOT_FOUND);
}
foreach ($files as $file) {
$fileInfo = pathinfo($file);
self::$translations[$fileInfo['filename']] = require_once $file;
}
} | php | public function load($lang) {
$langDir = MODULES_DIR . DS . RouteController::$currentModule . '/Views/lang/' . $lang;
$files = glob($langDir . "/*.php");
if (count($files) == 0) {
throw new \Exception(ExceptionMessages::TRANSLATION_FILES_NOT_FOUND);
}
foreach ($files as $file) {
$fileInfo = pathinfo($file);
self::$translations[$fileInfo['filename']] = require_once $file;
}
} | [
"public",
"function",
"load",
"(",
"$",
"lang",
")",
"{",
"$",
"langDir",
"=",
"MODULES_DIR",
".",
"DS",
".",
"RouteController",
"::",
"$",
"currentModule",
".",
"'/Views/lang/'",
".",
"$",
"lang",
";",
"$",
"files",
"=",
"glob",
"(",
"$",
"langDir",
"... | Finds and loads translation files
@param string $lang
@return void
@throws \Exception | [
"Finds",
"and",
"loads",
"translation",
"files"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Lang/Lang.php#L50-L62 | train |
softberg/quantum-core | src/Libraries/Lang/Lang.php | Lang.set | public static function set($lang = NULL) {
$languages = get_config('langs');
if (!$languages) {
throw new \Exception(ExceptionMessages::MISCONFIGURED_LANG_CONFIG);
}
if (!get_config('lang_default')) {
throw new \Exception(ExceptionMessages::MISCONFIGURED_LANG_DEFAULT_CONFIG);
}
if (empty($lang) || !in_array($lang, $languages)) {
$lang = get_config('lang_default');
}
self::$currentLang = $lang;
self::load($lang);
} | php | public static function set($lang = NULL) {
$languages = get_config('langs');
if (!$languages) {
throw new \Exception(ExceptionMessages::MISCONFIGURED_LANG_CONFIG);
}
if (!get_config('lang_default')) {
throw new \Exception(ExceptionMessages::MISCONFIGURED_LANG_DEFAULT_CONFIG);
}
if (empty($lang) || !in_array($lang, $languages)) {
$lang = get_config('lang_default');
}
self::$currentLang = $lang;
self::load($lang);
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"lang",
"=",
"NULL",
")",
"{",
"$",
"languages",
"=",
"get_config",
"(",
"'langs'",
")",
";",
"if",
"(",
"!",
"$",
"languages",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"ExceptionMessages",
"::"... | Sets current language
@param string $lang
@return void
@throws \Exception | [
"Sets",
"current",
"language"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Lang/Lang.php#L71-L87 | train |
MichaelPavlista/nette-palette | src/NettePalette/PaletteExtension.php | PaletteExtension.loadConfiguration | public function loadConfiguration()
{
// Load extension configuration
$config = $this->getConfig();
if(!isset($config['path']))
{
throw new ServiceCreationException('Missing required path parameter in PaletteExtension configuration');
}
if(!isset($config['url']))
{
throw new ServiceCreationException('Missing required url parameter in PaletteExtension configuration');
}
// Register extension services
$builder = $this->getContainerBuilder();
// Register palette service
$builder->addDefinition($this->prefix('service'))
->setClass('NettePalette\Palette', array(
$config['path'],
$config['url'],
$config['basepath'],
empty($config['fallbackImage']) ? NULL : $config['fallbackImage'],
empty($config['template']) ? NULL : $config['template'],
empty($config['websiteUrl']) ? NULL : $config['websiteUrl'],
empty($config['pictureLoader']) ? NULL : $config['pictureLoader'],
))
->addSetup('setHandleExceptions', [
!isset($config['handleException']) ? TRUE : $config['handleException'],
]);
// Register latte filter service
$builder->addDefinition($this->prefix('filter'))
->setClass('NettePalette\LatteFilter', [$this->prefix('@service')]);
// Register latte filter
$this->getLatteService()
->addSetup('addFilter', ['palette', $this->prefix('@filter')]);
// Register extension presenter
$builder->getDefinition('nette.presenterFactory')
->addSetup('setMapping', [['Palette' => 'NettePalette\*Presenter']]);
} | php | public function loadConfiguration()
{
// Load extension configuration
$config = $this->getConfig();
if(!isset($config['path']))
{
throw new ServiceCreationException('Missing required path parameter in PaletteExtension configuration');
}
if(!isset($config['url']))
{
throw new ServiceCreationException('Missing required url parameter in PaletteExtension configuration');
}
// Register extension services
$builder = $this->getContainerBuilder();
// Register palette service
$builder->addDefinition($this->prefix('service'))
->setClass('NettePalette\Palette', array(
$config['path'],
$config['url'],
$config['basepath'],
empty($config['fallbackImage']) ? NULL : $config['fallbackImage'],
empty($config['template']) ? NULL : $config['template'],
empty($config['websiteUrl']) ? NULL : $config['websiteUrl'],
empty($config['pictureLoader']) ? NULL : $config['pictureLoader'],
))
->addSetup('setHandleExceptions', [
!isset($config['handleException']) ? TRUE : $config['handleException'],
]);
// Register latte filter service
$builder->addDefinition($this->prefix('filter'))
->setClass('NettePalette\LatteFilter', [$this->prefix('@service')]);
// Register latte filter
$this->getLatteService()
->addSetup('addFilter', ['palette', $this->prefix('@filter')]);
// Register extension presenter
$builder->getDefinition('nette.presenterFactory')
->addSetup('setMapping', [['Palette' => 'NettePalette\*Presenter']]);
} | [
"public",
"function",
"loadConfiguration",
"(",
")",
"{",
"// Load extension configuration",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'path'",
"]",
")",
")",
"{",
"throw",
"new"... | Processes configuration data.
@return void
@throws ServiceCreationException | [
"Processes",
"configuration",
"data",
"."
] | 025266096e3cbc02eb5db8d931cc6caf2cc16745 | https://github.com/MichaelPavlista/nette-palette/blob/025266096e3cbc02eb5db8d931cc6caf2cc16745/src/NettePalette/PaletteExtension.php#L31-L77 | train |
MichaelPavlista/nette-palette | src/NettePalette/PaletteExtension.php | PaletteExtension.getLatteService | protected function getLatteService()
{
$builder = $this->getContainerBuilder();
return $builder->hasDefinition('nette.latteFactory')
? $builder->getDefinition('nette.latteFactory')
: $builder->getDefinition('nette.latte');
} | php | protected function getLatteService()
{
$builder = $this->getContainerBuilder();
return $builder->hasDefinition('nette.latteFactory')
? $builder->getDefinition('nette.latteFactory')
: $builder->getDefinition('nette.latte');
} | [
"protected",
"function",
"getLatteService",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"return",
"$",
"builder",
"->",
"hasDefinition",
"(",
"'nette.latteFactory'",
")",
"?",
"$",
"builder",
"->",
"getDefinitio... | Get Latte service definition
@return \Nette\DI\ServiceDefinition | [
"Get",
"Latte",
"service",
"definition"
] | 025266096e3cbc02eb5db8d931cc6caf2cc16745 | https://github.com/MichaelPavlista/nette-palette/blob/025266096e3cbc02eb5db8d931cc6caf2cc16745/src/NettePalette/PaletteExtension.php#L84-L91 | train |
vegas-cmf/core | src/Util/FileWriter.php | FileWriter.write | public static function write($filePath, $content, $compareContents = false)
{
if ($compareContents && self::compareContents($filePath, $content)) {
return 0;
}
return file_put_contents($filePath, $content);
} | php | public static function write($filePath, $content, $compareContents = false)
{
if ($compareContents && self::compareContents($filePath, $content)) {
return 0;
}
return file_put_contents($filePath, $content);
} | [
"public",
"static",
"function",
"write",
"(",
"$",
"filePath",
",",
"$",
"content",
",",
"$",
"compareContents",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"compareContents",
"&&",
"self",
"::",
"compareContents",
"(",
"$",
"filePath",
",",
"$",
"content",
... | Writes string content to a file
@param $filePath
@param $content
@param bool $compareContents Determines if new content should be compared with the
current file content. When contents are the same, then
new content will not be written to the file.
@return int Number of bytes that were written to the file | [
"Writes",
"string",
"content",
"to",
"a",
"file"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Util/FileWriter.php#L33-L40 | train |
vegas-cmf/core | src/Util/FileWriter.php | FileWriter.writeObject | public static function writeObject($filePath, $object, $compareContents = false)
{
$content = '<?php return ' . var_export($object, true) . ';';
return self::write($filePath, $content, $compareContents);
} | php | public static function writeObject($filePath, $object, $compareContents = false)
{
$content = '<?php return ' . var_export($object, true) . ';';
return self::write($filePath, $content, $compareContents);
} | [
"public",
"static",
"function",
"writeObject",
"(",
"$",
"filePath",
",",
"$",
"object",
",",
"$",
"compareContents",
"=",
"false",
")",
"{",
"$",
"content",
"=",
"'<?php return '",
".",
"var_export",
"(",
"$",
"object",
",",
"true",
")",
".",
"';'",
";"... | Writes string representation of PHP object into plain file
@param $filePath
@param $object
@param bool $compareContents Determines if new content should be compared with the
current file content. When contents are the same, then
new content will not be written to the file.
@return int Number of bytes that were written to the file | [
"Writes",
"string",
"representation",
"of",
"PHP",
"object",
"into",
"plain",
"file"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Util/FileWriter.php#L52-L56 | train |
vegas-cmf/core | src/Util/FileWriter.php | FileWriter.compareContents | private static function compareContents($filePath, $newContent)
{
if (file_exists($filePath)) {
$currentContent = file_get_contents($filePath);
return strcmp($currentContent, $newContent) === 0;
}
return false;
} | php | private static function compareContents($filePath, $newContent)
{
if (file_exists($filePath)) {
$currentContent = file_get_contents($filePath);
return strcmp($currentContent, $newContent) === 0;
}
return false;
} | [
"private",
"static",
"function",
"compareContents",
"(",
"$",
"filePath",
",",
"$",
"newContent",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"currentContent",
"=",
"file_get_contents",
"(",
"$",
"filePath",
")",
";",
"ret... | Compares file contents
@param $filePath
@param $newContent
@return bool
@internal | [
"Compares",
"file",
"contents"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Util/FileWriter.php#L66-L74 | train |
vegas-cmf/core | src/Mvc/View/Engine/Volt.php | Volt.registerFilter | public function registerFilter($filterName)
{
$className = __CLASS__ . '\\Filter\\' . ucfirst($filterName);
try {
$filterInstance = $this->getClassInstance($className);
if (!$filterInstance instanceof VoltFilterAbstract) {
throw new InvalidFilterException();
}
$this->getCompiler()->addFilter($filterName, $filterInstance->getFilter());
} catch (\ReflectionException $e) {
throw new UnknownFilterException(sprintf('Filter \'%s\' does not exist', $filterName));
} catch (\Exception $e) {
throw new InvalidFilterException(sprintf('Invalid filter \'%s\'', $filterName));
}
} | php | public function registerFilter($filterName)
{
$className = __CLASS__ . '\\Filter\\' . ucfirst($filterName);
try {
$filterInstance = $this->getClassInstance($className);
if (!$filterInstance instanceof VoltFilterAbstract) {
throw new InvalidFilterException();
}
$this->getCompiler()->addFilter($filterName, $filterInstance->getFilter());
} catch (\ReflectionException $e) {
throw new UnknownFilterException(sprintf('Filter \'%s\' does not exist', $filterName));
} catch (\Exception $e) {
throw new InvalidFilterException(sprintf('Invalid filter \'%s\'', $filterName));
}
} | [
"public",
"function",
"registerFilter",
"(",
"$",
"filterName",
")",
"{",
"$",
"className",
"=",
"__CLASS__",
".",
"'\\\\Filter\\\\'",
".",
"ucfirst",
"(",
"$",
"filterName",
")",
";",
"try",
"{",
"$",
"filterInstance",
"=",
"$",
"this",
"->",
"getClassInsta... | Registers a new filter in the compiler
@param $filterName
@throws InvalidFilterException
@throws UnknownFilterException | [
"Registers",
"a",
"new",
"filter",
"in",
"the",
"compiler"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View/Engine/Volt.php#L55-L69 | train |
vegas-cmf/core | src/Mvc/View/Engine/Volt.php | Volt.registerHelper | public function registerHelper($helperName)
{
$className = __CLASS__ . '\\Helper\\' . ucfirst($helperName);
try {
$helperInstance = $this->getClassInstance($className);
if (!$helperInstance instanceof VoltHelperAbstract) {
throw new InvalidHelperException();
}
$this->getCompiler()->addFunction($helperName, $helperInstance->getHelper());
} catch (\ReflectionException $e) {
throw new UnknownHelperException(sprintf('Helper \'%s\' does not exist', $helperName));
} catch (\Exception $e) {
throw new InvalidHelperException(sprintf('Invalid helper \'%s\'', $helperName));
}
} | php | public function registerHelper($helperName)
{
$className = __CLASS__ . '\\Helper\\' . ucfirst($helperName);
try {
$helperInstance = $this->getClassInstance($className);
if (!$helperInstance instanceof VoltHelperAbstract) {
throw new InvalidHelperException();
}
$this->getCompiler()->addFunction($helperName, $helperInstance->getHelper());
} catch (\ReflectionException $e) {
throw new UnknownHelperException(sprintf('Helper \'%s\' does not exist', $helperName));
} catch (\Exception $e) {
throw new InvalidHelperException(sprintf('Invalid helper \'%s\'', $helperName));
}
} | [
"public",
"function",
"registerHelper",
"(",
"$",
"helperName",
")",
"{",
"$",
"className",
"=",
"__CLASS__",
".",
"'\\\\Helper\\\\'",
".",
"ucfirst",
"(",
"$",
"helperName",
")",
";",
"try",
"{",
"$",
"helperInstance",
"=",
"$",
"this",
"->",
"getClassInsta... | Registers a new helper in the compiler
@param $helperName
@throws InvalidHelperException
@throws UnknownHelperException | [
"Registers",
"a",
"new",
"helper",
"in",
"the",
"compiler"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/View/Engine/Volt.php#L78-L92 | train |
jetwaves/laravel-implicit-router | src/Router.php | Router.controller | public function controller($uri, $controller, $names = [])
{
$arr = explode('\\', $controller);
$controllerClassName = $arr[ sizeof($arr) -1 ];
$routable = (new ControllerInspector)->getRoutable($this->addGroupNamespace($controller), $uri);
foreach ($routable as $method => $routes) {
if ($method == 'getMethodProperties') {
continue;
}
foreach ($routes as $route) {
// original code
// $this->{$route['verb']}($route['uri'], [
// 'uses' => $controller.'@'.$method,
// 'as' => array_get($names, $method)
// ]);
// Route::{$route['verb']}( $route['uri'] , "{$controller}@{$method}" );
// should add middleware support later
Route::{$route['verb']}( $route['uri'] , "{$controllerClassName}@{$method}" );
// middleware support not working as following
// Route::{$route['verb']}( $route['uri'] , [
// 'uses' => $controller.'@'.$method,
// 'as' => array_get($names, $method)
// ]);
}
}
} | php | public function controller($uri, $controller, $names = [])
{
$arr = explode('\\', $controller);
$controllerClassName = $arr[ sizeof($arr) -1 ];
$routable = (new ControllerInspector)->getRoutable($this->addGroupNamespace($controller), $uri);
foreach ($routable as $method => $routes) {
if ($method == 'getMethodProperties') {
continue;
}
foreach ($routes as $route) {
// original code
// $this->{$route['verb']}($route['uri'], [
// 'uses' => $controller.'@'.$method,
// 'as' => array_get($names, $method)
// ]);
// Route::{$route['verb']}( $route['uri'] , "{$controller}@{$method}" );
// should add middleware support later
Route::{$route['verb']}( $route['uri'] , "{$controllerClassName}@{$method}" );
// middleware support not working as following
// Route::{$route['verb']}( $route['uri'] , [
// 'uses' => $controller.'@'.$method,
// 'as' => array_get($names, $method)
// ]);
}
}
} | [
"public",
"function",
"controller",
"(",
"$",
"uri",
",",
"$",
"controller",
",",
"$",
"names",
"=",
"[",
"]",
")",
"{",
"$",
"arr",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"controller",
")",
";",
"$",
"controllerClassName",
"=",
"$",
"arr",
"[",
... | Register a controller.
@param string $uri
@param string $controller
@param array $names
@return void | [
"Register",
"a",
"controller",
"."
] | 2e4f4e6a1439f4f5ffb26359ab3157cea0afa725 | https://github.com/jetwaves/laravel-implicit-router/blob/2e4f4e6a1439f4f5ffb26359ab3157cea0afa725/src/Router.php#L325-L353 | train |
jetwaves/laravel-implicit-router | src/Router.php | Router.addGroupNamespace | protected function addGroupNamespace($controller)
{
if (! empty($this->groupStack)) {
$group = end($this->groupStack);
if (isset($group['namespace']) && strpos($controller, '\\') !== 0) {
return $group['namespace'].'\\'.$controller;
}
}
return $controller;
} | php | protected function addGroupNamespace($controller)
{
if (! empty($this->groupStack)) {
$group = end($this->groupStack);
if (isset($group['namespace']) && strpos($controller, '\\') !== 0) {
return $group['namespace'].'\\'.$controller;
}
}
return $controller;
} | [
"protected",
"function",
"addGroupNamespace",
"(",
"$",
"controller",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"groupStack",
")",
")",
"{",
"$",
"group",
"=",
"end",
"(",
"$",
"this",
"->",
"groupStack",
")",
";",
"if",
"(",
"isset"... | Add the group namespace to a controller.
@param string $controller
@return string | [
"Add",
"the",
"group",
"namespace",
"to",
"a",
"controller",
"."
] | 2e4f4e6a1439f4f5ffb26359ab3157cea0afa725 | https://github.com/jetwaves/laravel-implicit-router/blob/2e4f4e6a1439f4f5ffb26359ab3157cea0afa725/src/Router.php#L362-L373 | train |
jetwaves/laravel-implicit-router | src/Router.php | Router.addRouteMiddlewares | protected function addRouteMiddlewares(array $action)
{
foreach ([static::API_RATE_LIMIT_MIDDLEWARE, static::API_AUTH_MIDDLEWARE] as $middleware) {
if (($key = array_search($middleware, $action['middleware'])) !== false) {
unset($action['middleware'][$key]);
}
array_unshift($action['middleware'], $middleware);
}
return $action;
} | php | protected function addRouteMiddlewares(array $action)
{
foreach ([static::API_RATE_LIMIT_MIDDLEWARE, static::API_AUTH_MIDDLEWARE] as $middleware) {
if (($key = array_search($middleware, $action['middleware'])) !== false) {
unset($action['middleware'][$key]);
}
array_unshift($action['middleware'], $middleware);
}
return $action;
} | [
"protected",
"function",
"addRouteMiddlewares",
"(",
"array",
"$",
"action",
")",
"{",
"foreach",
"(",
"[",
"static",
"::",
"API_RATE_LIMIT_MIDDLEWARE",
",",
"static",
"::",
"API_AUTH_MIDDLEWARE",
"]",
"as",
"$",
"middleware",
")",
"{",
"if",
"(",
"(",
"$",
... | Add the route middlewares to the action array.
@param array $action
@return array | [
"Add",
"the",
"route",
"middlewares",
"to",
"the",
"action",
"array",
"."
] | 2e4f4e6a1439f4f5ffb26359ab3157cea0afa725 | https://github.com/jetwaves/laravel-implicit-router/blob/2e4f4e6a1439f4f5ffb26359ab3157cea0afa725/src/Router.php#L418-L429 | train |
Kolyunya/codeception-markup-validator | sources/Lib/MarkupValidator/W3CMarkupValidatorMessage.php | W3CMarkupValidatorMessage.initializeType | private function initializeType(array $data)
{
if (isset($data['type']) === false) {
return;
}
if ($data['type'] === 'error') {
$this->type = self::TYPE_ERROR;
} elseif ($data['type'] === 'info') {
if (isset($data['subType']) === true &&
$data['subType'] === 'warning'
) {
$this->type = self::TYPE_WARNING;
} else {
$this->type = self::TYPE_INFO;
}
}
} | php | private function initializeType(array $data)
{
if (isset($data['type']) === false) {
return;
}
if ($data['type'] === 'error') {
$this->type = self::TYPE_ERROR;
} elseif ($data['type'] === 'info') {
if (isset($data['subType']) === true &&
$data['subType'] === 'warning'
) {
$this->type = self::TYPE_WARNING;
} else {
$this->type = self::TYPE_INFO;
}
}
} | [
"private",
"function",
"initializeType",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'type'",
"]",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"data",
"[",
"'type'",
"]",
"===",
"'error'",... | Initializes message type.
@param array $data Message data. | [
"Initializes",
"message",
"type",
"."
] | 89b5fa5e28602af7e7f2a8ee42686be697dd00a7 | https://github.com/Kolyunya/codeception-markup-validator/blob/89b5fa5e28602af7e7f2a8ee42686be697dd00a7/sources/Lib/MarkupValidator/W3CMarkupValidatorMessage.php#L35-L52 | train |
alex-oleshkevich/zf-annotations | src/ZfAnnotation/Annotation/Route.php | Route.extend | public function extend($annotation)
{
$params = get_object_vars($annotation);
foreach ($params as $property => $value) {
if (property_exists($this, $property) && !in_array($property, ['name', 'route'])) {
if (!$this->$property) {
$this->$property = $value;
}
}
}
} | php | public function extend($annotation)
{
$params = get_object_vars($annotation);
foreach ($params as $property => $value) {
if (property_exists($this, $property) && !in_array($property, ['name', 'route'])) {
if (!$this->$property) {
$this->$property = $value;
}
}
}
} | [
"public",
"function",
"extend",
"(",
"$",
"annotation",
")",
"{",
"$",
"params",
"=",
"get_object_vars",
"(",
"$",
"annotation",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"property_exists",
... | Extend this route with data from another one.
@param AnnotationInterface $annotation | [
"Extend",
"this",
"route",
"with",
"data",
"from",
"another",
"one",
"."
] | 1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6 | https://github.com/alex-oleshkevich/zf-annotations/blob/1de5ae9ae4fae1c4b8b2a4b73f3ff19d6b4547c6/src/ZfAnnotation/Annotation/Route.php#L325-L335 | train |
jasny/db | src/QueryBuilder/Step/FilterParser.php | FilterParser.parse | protected function parse(string $key): array
{
if (strpos($key, '(') === false && strpos($key, ')') === false) {
return ['field' => trim($key), 'operator' => ''];
}
if (!preg_match(static::REGEXP, $key, $matches)) {
throw new InvalidFilterException("Invalid filter item '$key': Bad use of parentheses");
}
return array_only($matches, ['field', 'operator']) + ['operator' => ''];
} | php | protected function parse(string $key): array
{
if (strpos($key, '(') === false && strpos($key, ')') === false) {
return ['field' => trim($key), 'operator' => ''];
}
if (!preg_match(static::REGEXP, $key, $matches)) {
throw new InvalidFilterException("Invalid filter item '$key': Bad use of parentheses");
}
return array_only($matches, ['field', 'operator']) + ['operator' => ''];
} | [
"protected",
"function",
"parse",
"(",
"string",
"$",
"key",
")",
":",
"array",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'('",
")",
"===",
"false",
"&&",
"strpos",
"(",
"$",
"key",
",",
"')'",
")",
"===",
"false",
")",
"{",
"return",
"[",... | Parse the key into field and operator.
@param string $key
@return array | [
"Parse",
"the",
"key",
"into",
"field",
"and",
"operator",
"."
] | efd57d9dd8f3f40235c4da8b39a81f03d5f79b25 | https://github.com/jasny/db/blob/efd57d9dd8f3f40235c4da8b39a81f03d5f79b25/src/QueryBuilder/Step/FilterParser.php#L38-L49 | train |
vegas-cmf/core | src/Mvc/Controller/CrudAbstract.php | CrudAbstract.indexAction | public function indexAction()
{
$this->initializeScaffolding();
$paginator = $this->scaffolding->doPaginate($this->request->get('page', 'int', 1));
$this->view->page = $paginator->getPaginate();
$this->view->fields = $this->indexFields;
} | php | public function indexAction()
{
$this->initializeScaffolding();
$paginator = $this->scaffolding->doPaginate($this->request->get('page', 'int', 1));
$this->view->page = $paginator->getPaginate();
$this->view->fields = $this->indexFields;
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"this",
"->",
"initializeScaffolding",
"(",
")",
";",
"$",
"paginator",
"=",
"$",
"this",
"->",
"scaffolding",
"->",
"doPaginate",
"(",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'page'",
","... | Display records list.
@ACL(name="new", description="Create a new record") | [
"Display",
"records",
"list",
"."
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Controller/CrudAbstract.php#L123-L130 | train |
vegas-cmf/core | src/Mvc/Controller/CrudAbstract.php | CrudAbstract.showAction | public function showAction($id)
{
$this->initializeScaffolding();
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->view->fields = $this->showFields;
$this->afterRead();
} | php | public function showAction($id)
{
$this->initializeScaffolding();
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->view->fields = $this->showFields;
$this->afterRead();
} | [
"public",
"function",
"showAction",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"initializeScaffolding",
"(",
")",
";",
"$",
"this",
"->",
"beforeRead",
"(",
")",
";",
"$",
"this",
"->",
"view",
"->",
"record",
"=",
"$",
"this",
"->",
"scaffolding",
... | Display record details.
@ACL(name="new", description="Create a new record") | [
"Display",
"record",
"details",
"."
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Controller/CrudAbstract.php#L137-L145 | train |
vegas-cmf/core | src/Mvc/Controller/CrudAbstract.php | CrudAbstract.newAction | public function newAction()
{
$this->initializeScaffolding();
$this->beforeNew();
$this->view->form = $this->scaffolding->getForm();
$this->afterNew();
} | php | public function newAction()
{
$this->initializeScaffolding();
$this->beforeNew();
$this->view->form = $this->scaffolding->getForm();
$this->afterNew();
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"this",
"->",
"initializeScaffolding",
"(",
")",
";",
"$",
"this",
"->",
"beforeNew",
"(",
")",
";",
"$",
"this",
"->",
"view",
"->",
"form",
"=",
"$",
"this",
"->",
"scaffolding",
"->",
"getForm",... | Displays form for new record
@ACL(name="new", description="Create a new record") | [
"Displays",
"form",
"for",
"new",
"record"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Controller/CrudAbstract.php#L152-L159 | train |
vegas-cmf/core | src/Mvc/Controller/CrudAbstract.php | CrudAbstract.createAction | public function createAction()
{
$this->initializeScaffolding();
$this->checkRequest();
try {
$this->beforeCreate();
$this->scaffolding->doCreate($this->request->getPost());
$this->flash->success($this->successMessage);
return $this->afterCreate();
} catch (Exception $e) {
$this->flash->error($e->getMessage());
$this->afterCreateException();
}
return $this->dispatcher->forward(['action' => 'new']);
} | php | public function createAction()
{
$this->initializeScaffolding();
$this->checkRequest();
try {
$this->beforeCreate();
$this->scaffolding->doCreate($this->request->getPost());
$this->flash->success($this->successMessage);
return $this->afterCreate();
} catch (Exception $e) {
$this->flash->error($e->getMessage());
$this->afterCreateException();
}
return $this->dispatcher->forward(['action' => 'new']);
} | [
"public",
"function",
"createAction",
"(",
")",
"{",
"$",
"this",
"->",
"initializeScaffolding",
"(",
")",
";",
"$",
"this",
"->",
"checkRequest",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"beforeCreate",
"(",
")",
";",
"$",
"this",
"->",
"scaffold... | Creates new record
@ACL(name="create", inherit='new')
@return mixed | [
"Creates",
"new",
"record"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Controller/CrudAbstract.php#L167-L183 | train |
vegas-cmf/core | src/Mvc/Controller/CrudAbstract.php | CrudAbstract.editAction | public function editAction($id)
{
$this->initializeScaffolding();
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->afterRead();
$this->beforeEdit();
$this->view->form = $this->scaffolding->getForm($this->view->record);
$this->afterEdit();
} | php | public function editAction($id)
{
$this->initializeScaffolding();
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->afterRead();
$this->beforeEdit();
$this->view->form = $this->scaffolding->getForm($this->view->record);
$this->afterEdit();
} | [
"public",
"function",
"editAction",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"initializeScaffolding",
"(",
")",
";",
"$",
"this",
"->",
"beforeRead",
"(",
")",
";",
"$",
"this",
"->",
"view",
"->",
"record",
"=",
"$",
"this",
"->",
"scaffolding",
... | Displays form for existing record
@ACL(name="edit", description="Record edit")
@param $id | [
"Displays",
"form",
"for",
"existing",
"record"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Controller/CrudAbstract.php#L191-L202 | train |
vegas-cmf/core | src/Mvc/Controller/CrudAbstract.php | CrudAbstract.updateAction | public function updateAction($id)
{
$this->initializeScaffolding();
$this->checkRequest();
try {
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->afterRead();
$this->beforeUpdate();
$this->scaffolding->doUpdate($id, $this->request->getPost());
$this->flash->success($this->successMessage);
return $this->afterUpdate();
} catch (Exception $e) {
$this->flash->error($e->getMessage());
$this->afterUpdateException();
}
return $this->dispatcher->forward(['action' => 'edit']);
} | php | public function updateAction($id)
{
$this->initializeScaffolding();
$this->checkRequest();
try {
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->afterRead();
$this->beforeUpdate();
$this->scaffolding->doUpdate($id, $this->request->getPost());
$this->flash->success($this->successMessage);
return $this->afterUpdate();
} catch (Exception $e) {
$this->flash->error($e->getMessage());
$this->afterUpdateException();
}
return $this->dispatcher->forward(['action' => 'edit']);
} | [
"public",
"function",
"updateAction",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"initializeScaffolding",
"(",
")",
";",
"$",
"this",
"->",
"checkRequest",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"beforeRead",
"(",
")",
";",
"$",
"this",
"->"... | Updates existing record indicated by its ID
@ACL(name="update", inherit='edit')
@param $id
@return mixed | [
"Updates",
"existing",
"record",
"indicated",
"by",
"its",
"ID"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Controller/CrudAbstract.php#L211-L231 | train |
vegas-cmf/core | src/Mvc/Controller/CrudAbstract.php | CrudAbstract.deleteAction | public function deleteAction($id)
{
$this->initializeScaffolding();
try {
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->afterRead();
$this->beforeDelete();
$this->scaffolding->doDelete($id);
$this->flash->success($this->successMessage);
return $this->afterDelete();
} catch (Exception $e) {
$this->flash->error($e->getMessage());
return $this->afterDeleteException();
}
} | php | public function deleteAction($id)
{
$this->initializeScaffolding();
try {
$this->beforeRead();
$this->view->record = $this->scaffolding->doRead($id);
$this->afterRead();
$this->beforeDelete();
$this->scaffolding->doDelete($id);
$this->flash->success($this->successMessage);
return $this->afterDelete();
} catch (Exception $e) {
$this->flash->error($e->getMessage());
return $this->afterDeleteException();
}
} | [
"public",
"function",
"deleteAction",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"initializeScaffolding",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"beforeRead",
"(",
")",
";",
"$",
"this",
"->",
"view",
"->",
"record",
"=",
"$",
"this",
"->",
... | Deletes existing record by its ID
@ACL(name="delete", description="Delete a record")
@param $id
@return mixed | [
"Deletes",
"existing",
"record",
"by",
"its",
"ID"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Mvc/Controller/CrudAbstract.php#L252-L269 | train |
vegas-cmf/core | src/Db/Adapter/Mongo/DbRef.php | DbRef.create | public static function create($collection, $id = null, $database = null)
{
if ($collection instanceof \Phalcon\Mvc\Collection) {
$id = $collection->getId();
$collection = $collection->getSource();
}
if ($id instanceof \Phalcon\Mvc\Collection) {
$id = $id->getId();
}
if (!$id instanceof \MongoId && $id !== null) {
$id = new \MongoId($id);
}
return parent::create($collection, $id, $database);
} | php | public static function create($collection, $id = null, $database = null)
{
if ($collection instanceof \Phalcon\Mvc\Collection) {
$id = $collection->getId();
$collection = $collection->getSource();
}
if ($id instanceof \Phalcon\Mvc\Collection) {
$id = $id->getId();
}
if (!$id instanceof \MongoId && $id !== null) {
$id = new \MongoId($id);
}
return parent::create($collection, $id, $database);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"collection",
",",
"$",
"id",
"=",
"null",
",",
"$",
"database",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"collection",
"instanceof",
"\\",
"Phalcon",
"\\",
"Mvc",
"\\",
"Collection",
")",
"{",
"$",
"... | Creates a new database reference
@param string|\Phalcon\Mvc\Collection $collection
@param mixed|\MongoId|\Phalcon\Mvc\Collection $id
@param string $database
@return array | [
"Creates",
"a",
"new",
"database",
"reference"
] | 50fc3f31a6a8fc3cf274efd5b3eb3203d1206100 | https://github.com/vegas-cmf/core/blob/50fc3f31a6a8fc3cf274efd5b3eb3203d1206100/src/Db/Adapter/Mongo/DbRef.php#L44-L58 | train |
duncan3dc/php-helpers | src/Env.php | Env.usePath | public static function usePath($path)
{
# Use the document root normally set via apache
if ($path === self::PATH_DOCUMENT_ROOT) {
if (empty($_SERVER["DOCUMENT_ROOT"]) || !is_dir($_SERVER["DOCUMENT_ROOT"])) {
throw new \InvalidArgumentException("DOCUMENT_ROOT not defined");
}
static::$path = $_SERVER["DOCUMENT_ROOT"];
return;
}
# Get the full path of the running script and use it's directory
if ($path === self::PATH_PHP_SELF) {
if (empty($_SERVER["PHP_SELF"]) || !$path = realpath($_SERVER["PHP_SELF"])) {
throw new \InvalidArgumentException("PHP_SELF not defined");
}
static::$path = pathinfo($path, PATHINFO_DIRNAME);
return;
}
# Calculate the parent of the vendor directory and use that
if ($path === self::PATH_VENDOR_PARENT) {
static::$path = realpath(__DIR__ . "/../../../..");
return;
}
if (is_dir($path)) {
static::$path = $path;
} else {
throw new \InvalidArgumentException("Invalid path specified");
}
} | php | public static function usePath($path)
{
# Use the document root normally set via apache
if ($path === self::PATH_DOCUMENT_ROOT) {
if (empty($_SERVER["DOCUMENT_ROOT"]) || !is_dir($_SERVER["DOCUMENT_ROOT"])) {
throw new \InvalidArgumentException("DOCUMENT_ROOT not defined");
}
static::$path = $_SERVER["DOCUMENT_ROOT"];
return;
}
# Get the full path of the running script and use it's directory
if ($path === self::PATH_PHP_SELF) {
if (empty($_SERVER["PHP_SELF"]) || !$path = realpath($_SERVER["PHP_SELF"])) {
throw new \InvalidArgumentException("PHP_SELF not defined");
}
static::$path = pathinfo($path, PATHINFO_DIRNAME);
return;
}
# Calculate the parent of the vendor directory and use that
if ($path === self::PATH_VENDOR_PARENT) {
static::$path = realpath(__DIR__ . "/../../../..");
return;
}
if (is_dir($path)) {
static::$path = $path;
} else {
throw new \InvalidArgumentException("Invalid path specified");
}
} | [
"public",
"static",
"function",
"usePath",
"(",
"$",
"path",
")",
"{",
"# Use the document root normally set via apache",
"if",
"(",
"$",
"path",
"===",
"self",
"::",
"PATH_DOCUMENT_ROOT",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_SERVER",
"[",
"\"DOCUMENT_ROOT\... | Set the root path to use in the path methods.
@param int|string $path Either one of the PATH class constants or an actual path to a directory that exists, and is readable
@return void | [
"Set",
"the",
"root",
"path",
"to",
"use",
"in",
"the",
"path",
"methods",
"."
] | 0305d220183d9b515f17600bf064291da7a8813b | https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Env.php#L42-L73 | train |
duncan3dc/php-helpers | src/Env.php | Env.getRevision | public static function getRevision($length = 10)
{
$revision = Cache::call("revision", function() {
$path = static::path(".git");
if (!is_dir($path)) {
return;
}
$head = $path . "/HEAD";
if (!file_exists($head)) {
return;
}
$data = File::getContents($head);
if (!preg_match("/ref: ([^\s]+)\s/", $data, $matches)) {
return;
}
$ref = $path . "/" . $matches[1];
if (!file_exists($ref)) {
return;
}
return File::getContents($ref);
});
if ($length > 0) {
return substr($revision, 0, $length);
} else {
return $revision;
}
} | php | public static function getRevision($length = 10)
{
$revision = Cache::call("revision", function() {
$path = static::path(".git");
if (!is_dir($path)) {
return;
}
$head = $path . "/HEAD";
if (!file_exists($head)) {
return;
}
$data = File::getContents($head);
if (!preg_match("/ref: ([^\s]+)\s/", $data, $matches)) {
return;
}
$ref = $path . "/" . $matches[1];
if (!file_exists($ref)) {
return;
}
return File::getContents($ref);
});
if ($length > 0) {
return substr($revision, 0, $length);
} else {
return $revision;
}
} | [
"public",
"static",
"function",
"getRevision",
"(",
"$",
"length",
"=",
"10",
")",
"{",
"$",
"revision",
"=",
"Cache",
"::",
"call",
"(",
"\"revision\"",
",",
"function",
"(",
")",
"{",
"$",
"path",
"=",
"static",
"::",
"path",
"(",
"\".git\"",
")",
... | Get the revision number from the local git clone data.
@param int $length The length of the revision hash to return
@return string|void | [
"Get",
"the",
"revision",
"number",
"from",
"the",
"local",
"git",
"clone",
"data",
"."
] | 0305d220183d9b515f17600bf064291da7a8813b | https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Env.php#L180-L210 | train |
duncan3dc/php-helpers | src/Env.php | Env.getVars | public static function getVars()
{
if (!is_array(static::$vars)) {
$path = static::path("data/env.json");
try {
$vars = Json::decodeFromFile($path);
} catch(\Exception $e) {
$vars = [];
}
static::$vars = Helper::toArray($vars);
}
return static::$vars;
} | php | public static function getVars()
{
if (!is_array(static::$vars)) {
$path = static::path("data/env.json");
try {
$vars = Json::decodeFromFile($path);
} catch(\Exception $e) {
$vars = [];
}
static::$vars = Helper::toArray($vars);
}
return static::$vars;
} | [
"public",
"static",
"function",
"getVars",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"static",
"::",
"$",
"vars",
")",
")",
"{",
"$",
"path",
"=",
"static",
"::",
"path",
"(",
"\"data/env.json\"",
")",
";",
"try",
"{",
"$",
"vars",
"=",
"Json... | Get all defined environment variables.
@return array | [
"Get",
"all",
"defined",
"environment",
"variables",
"."
] | 0305d220183d9b515f17600bf064291da7a8813b | https://github.com/duncan3dc/php-helpers/blob/0305d220183d9b515f17600bf064291da7a8813b/src/Env.php#L218-L233 | train |
czim/laravel-cms-auth | src/Providers/CmsAuthServiceProvider.php | CmsAuthServiceProvider.registerAuthRepository | protected function registerAuthRepository()
{
$this->app->singleton(AuthRepositoryInterface::class, function (Application $app) {
return $app->make(AuthRepository::class);
});
return $this;
} | php | protected function registerAuthRepository()
{
$this->app->singleton(AuthRepositoryInterface::class, function (Application $app) {
return $app->make(AuthRepository::class);
});
return $this;
} | [
"protected",
"function",
"registerAuthRepository",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"AuthRepositoryInterface",
"::",
"class",
",",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
... | Registers authentication repository
@return $this | [
"Registers",
"authentication",
"repository"
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Providers/CmsAuthServiceProvider.php#L41-L48 | train |
czim/laravel-cms-auth | src/Providers/CmsAuthServiceProvider.php | CmsAuthServiceProvider.registerCommands | protected function registerCommands()
{
$this->app->singleton('cms.commands.user-create', CreateUser::class);
$this->app->singleton('cms.commands.user-delete', DeleteUser::class);
$this->commands([
'cms.commands.user-create',
'cms.commands.user-delete',
]);
return $this;
} | php | protected function registerCommands()
{
$this->app->singleton('cms.commands.user-create', CreateUser::class);
$this->app->singleton('cms.commands.user-delete', DeleteUser::class);
$this->commands([
'cms.commands.user-create',
'cms.commands.user-delete',
]);
return $this;
} | [
"protected",
"function",
"registerCommands",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'cms.commands.user-create'",
",",
"CreateUser",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'cms.commands.user-delete'"... | Register Authorization CMS commands
@return $this | [
"Register",
"Authorization",
"CMS",
"commands"
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Providers/CmsAuthServiceProvider.php#L55-L66 | train |
softberg/quantum-core | src/Libraries/Validation/Validation.php | Validation.is_valid | public static function is_valid(array $data, array $validators) {
$gump = self::get_instance();
$gump->validation_rules($validators);
if ($gump->run($data) === false) {
return $gump->get_errors_array(false);
} else {
return true;
}
} | php | public static function is_valid(array $data, array $validators) {
$gump = self::get_instance();
$gump->validation_rules($validators);
if ($gump->run($data) === false) {
return $gump->get_errors_array(false);
} else {
return true;
}
} | [
"public",
"static",
"function",
"is_valid",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"validators",
")",
"{",
"$",
"gump",
"=",
"self",
"::",
"get_instance",
"(",
")",
";",
"$",
"gump",
"->",
"validation_rules",
"(",
"$",
"validators",
")",
";",
"i... | Validates by rules
@param array $data
@param array $validators
@return mixed | [
"Validates",
"by",
"rules"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Validation/Validation.php#L48-L58 | train |
softberg/quantum-core | src/Libraries/Libraries.php | Libraries.load | public static function load($path = BASE_DIR) {
$librariesDir = dirname(dirname($path)) . DS . 'libraries';
foreach (glob($librariesDir . DS . "*.php") as $filename) {
require_once $filename;
}
} | php | public static function load($path = BASE_DIR) {
$librariesDir = dirname(dirname($path)) . DS . 'libraries';
foreach (glob($librariesDir . DS . "*.php") as $filename) {
require_once $filename;
}
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"path",
"=",
"BASE_DIR",
")",
"{",
"$",
"librariesDir",
"=",
"dirname",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
".",
"DS",
".",
"'libraries'",
";",
"foreach",
"(",
"glob",
"(",
"$",
"librariesDir",
... | Loads 3rd party libraries
@return void | [
"Loads",
"3rd",
"party",
"libraries"
] | 081d42a4ce4197ac8687d438c571914473ade9da | https://github.com/softberg/quantum-core/blob/081d42a4ce4197ac8687d438c571914473ade9da/src/Libraries/Libraries.php#L35-L40 | train |
czim/laravel-cms-auth | src/Repositories/AuthRepository.php | AuthRepository.getAllUsers | public function getAllUsers($withAdmin = false)
{
$query = $this->userModel->query()
->orderBy('email');
if ( ! $withAdmin) {
$query->where('is_superadmin', false);
}
return $query->get();
} | php | public function getAllUsers($withAdmin = false)
{
$query = $this->userModel->query()
->orderBy('email');
if ( ! $withAdmin) {
$query->where('is_superadmin', false);
}
return $query->get();
} | [
"public",
"function",
"getAllUsers",
"(",
"$",
"withAdmin",
"=",
"false",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"userModel",
"->",
"query",
"(",
")",
"->",
"orderBy",
"(",
"'email'",
")",
";",
"if",
"(",
"!",
"$",
"withAdmin",
")",
"{",
"... | Returns all CMS users.
@param bool $withAdmin include superadmins
@return array|Collection|UserInterface[] | [
"Returns",
"all",
"CMS",
"users",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Repositories/AuthRepository.php#L71-L81 | train |
czim/laravel-cms-auth | src/Repositories/AuthRepository.php | AuthRepository.getUsersForRole | public function getUsersForRole($role, $withAdmin = false)
{
$query = $this->userModel->query()
->orderBy('email')
->whereHas('roles', function ($query) use ($role) {
$query->where('slug', $role);
});
if ( ! $withAdmin) {
$query->where('is_superadmin', false);
}
return $query->get();
} | php | public function getUsersForRole($role, $withAdmin = false)
{
$query = $this->userModel->query()
->orderBy('email')
->whereHas('roles', function ($query) use ($role) {
$query->where('slug', $role);
});
if ( ! $withAdmin) {
$query->where('is_superadmin', false);
}
return $query->get();
} | [
"public",
"function",
"getUsersForRole",
"(",
"$",
"role",
",",
"$",
"withAdmin",
"=",
"false",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"userModel",
"->",
"query",
"(",
")",
"->",
"orderBy",
"(",
"'email'",
")",
"->",
"whereHas",
"(",
"'roles'"... | Returns all CMS users with the given role.
@param string $role
@param bool $withAdmin include superadmins
@return array|Collection|UserInterface[] | [
"Returns",
"all",
"CMS",
"users",
"with",
"the",
"given",
"role",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Repositories/AuthRepository.php#L90-L103 | train |
czim/laravel-cms-auth | src/Repositories/AuthRepository.php | AuthRepository.getAllPermissions | public function getAllPermissions()
{
$permissions = [];
// Gather and combine all permissions for roles
foreach ($this->roleModel->all() as $role) {
$permissions = array_merge(
$permissions,
array_keys(array_filter($role->getPermissions()))
);
}
// Gather permissions set specifically for users
foreach ($this->userModel->all() as $user) {
$permissions = array_merge(
$permissions,
array_keys(array_filter($user->getPermissions()))
);
}
sort($permissions);
return array_unique($permissions);
} | php | public function getAllPermissions()
{
$permissions = [];
// Gather and combine all permissions for roles
foreach ($this->roleModel->all() as $role) {
$permissions = array_merge(
$permissions,
array_keys(array_filter($role->getPermissions()))
);
}
// Gather permissions set specifically for users
foreach ($this->userModel->all() as $user) {
$permissions = array_merge(
$permissions,
array_keys(array_filter($user->getPermissions()))
);
}
sort($permissions);
return array_unique($permissions);
} | [
"public",
"function",
"getAllPermissions",
"(",
")",
"{",
"$",
"permissions",
"=",
"[",
"]",
";",
"// Gather and combine all permissions for roles",
"foreach",
"(",
"$",
"this",
"->",
"roleModel",
"->",
"all",
"(",
")",
"as",
"$",
"role",
")",
"{",
"$",
"per... | Returns all permissions known by the authenticator.
@todo This should be cached
@return string[] | [
"Returns",
"all",
"permissions",
"known",
"by",
"the",
"authenticator",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Repositories/AuthRepository.php#L124-L147 | train |
czim/laravel-cms-auth | src/Repositories/AuthRepository.php | AuthRepository.getAllPermissionsForRole | public function getAllPermissionsForRole($role)
{
/** @var EloquentRole $role */
$role = $this->getRole($role);
if ( ! $role) {
return [];
}
$permissions = array_keys(array_filter($role->getPermissions()));
sort($permissions);
return $permissions;
} | php | public function getAllPermissionsForRole($role)
{
/** @var EloquentRole $role */
$role = $this->getRole($role);
if ( ! $role) {
return [];
}
$permissions = array_keys(array_filter($role->getPermissions()));
sort($permissions);
return $permissions;
} | [
"public",
"function",
"getAllPermissionsForRole",
"(",
"$",
"role",
")",
"{",
"/** @var EloquentRole $role */",
"$",
"role",
"=",
"$",
"this",
"->",
"getRole",
"(",
"$",
"role",
")",
";",
"if",
"(",
"!",
"$",
"role",
")",
"{",
"return",
"[",
"]",
";",
... | Returns all permission keys for a given role.
@param string $role
@return string[] | [
"Returns",
"all",
"permission",
"keys",
"for",
"a",
"given",
"role",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Repositories/AuthRepository.php#L155-L168 | train |
czim/laravel-cms-auth | src/Repositories/AuthRepository.php | AuthRepository.getAllPermissionsForUser | public function getAllPermissionsForUser($user)
{
$user = $this->resolveUser($user);
if ( ! $user) {
return [];
}
$permissions = [];
// Get all permissions for the roles this user belongs to
foreach ($user->getRoles() as $role) {
/** @var EloquentRole $role */
$permissions = array_merge(
$permissions,
array_keys(array_filter($role->getPermissions()))
);
}
// Add permissions set specifically for the user
$permissions = array_merge(
$permissions,
array_keys(array_filter($user->getPermissions()))
);
sort($permissions);
return array_unique($permissions);
} | php | public function getAllPermissionsForUser($user)
{
$user = $this->resolveUser($user);
if ( ! $user) {
return [];
}
$permissions = [];
// Get all permissions for the roles this user belongs to
foreach ($user->getRoles() as $role) {
/** @var EloquentRole $role */
$permissions = array_merge(
$permissions,
array_keys(array_filter($role->getPermissions()))
);
}
// Add permissions set specifically for the user
$permissions = array_merge(
$permissions,
array_keys(array_filter($user->getPermissions()))
);
sort($permissions);
return array_unique($permissions);
} | [
"public",
"function",
"getAllPermissionsForUser",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"resolveUser",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"permissions",
"... | Returns all permission keys for a given user.
@param string|UserInterface $user user: name or instance
@return string[] | [
"Returns",
"all",
"permission",
"keys",
"for",
"a",
"given",
"user",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Repositories/AuthRepository.php#L176-L204 | train |
czim/laravel-cms-auth | src/Repositories/AuthRepository.php | AuthRepository.resolveUser | protected function resolveUser($user)
{
if ($user instanceof UserInterface) {
return $user;
}
if (is_integer($user)) {
$user = $this->sentinel->findById($user);
} else {
$user = $this->sentinel->findByCredentials([
'email' => $user
]);
}
return $user ?: false;
} | php | protected function resolveUser($user)
{
if ($user instanceof UserInterface) {
return $user;
}
if (is_integer($user)) {
$user = $this->sentinel->findById($user);
} else {
$user = $this->sentinel->findByCredentials([
'email' => $user
]);
}
return $user ?: false;
} | [
"protected",
"function",
"resolveUser",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"user",
"instanceof",
"UserInterface",
")",
"{",
"return",
"$",
"user",
";",
"}",
"if",
"(",
"is_integer",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"=",
"$",
"... | Resolves user to UserInterface, if possible
@param mixed $user
@return UserInterface|EloquentUser|false | [
"Resolves",
"user",
"to",
"UserInterface",
"if",
"possible"
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Repositories/AuthRepository.php#L212-L227 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.signUp | public static function signUp(UserId $anId, UserEmail $anEmail, UserPassword $aPassword, array $userRoles)
{
$user = new static($anId, $anEmail, $userRoles, $aPassword);
$user->confirmationToken = new UserToken();
$user->publish(
new UserRegistered(
$user->id(),
$user->email(),
$user->confirmationToken()
)
);
return $user;
} | php | public static function signUp(UserId $anId, UserEmail $anEmail, UserPassword $aPassword, array $userRoles)
{
$user = new static($anId, $anEmail, $userRoles, $aPassword);
$user->confirmationToken = new UserToken();
$user->publish(
new UserRegistered(
$user->id(),
$user->email(),
$user->confirmationToken()
)
);
return $user;
} | [
"public",
"static",
"function",
"signUp",
"(",
"UserId",
"$",
"anId",
",",
"UserEmail",
"$",
"anEmail",
",",
"UserPassword",
"$",
"aPassword",
",",
"array",
"$",
"userRoles",
")",
"{",
"$",
"user",
"=",
"new",
"static",
"(",
"$",
"anId",
",",
"$",
"anE... | Sign up user.
@param UserId $anId The id
@param UserEmail $anEmail The email
@param UserPassword $aPassword The encoded password
@param array $userRoles Array which contains the roles
@return static | [
"Sign",
"up",
"user",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L143-L156 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.invite | public static function invite(UserId $anId, UserEmail $anEmail, array $userRoles)
{
$user = new static($anId, $anEmail, $userRoles);
$user->invitationToken = new UserToken();
$user->publish(
new UserInvited(
$user->id(),
$user->email(),
$user->invitationToken()
)
);
return $user;
} | php | public static function invite(UserId $anId, UserEmail $anEmail, array $userRoles)
{
$user = new static($anId, $anEmail, $userRoles);
$user->invitationToken = new UserToken();
$user->publish(
new UserInvited(
$user->id(),
$user->email(),
$user->invitationToken()
)
);
return $user;
} | [
"public",
"static",
"function",
"invite",
"(",
"UserId",
"$",
"anId",
",",
"UserEmail",
"$",
"anEmail",
",",
"array",
"$",
"userRoles",
")",
"{",
"$",
"user",
"=",
"new",
"static",
"(",
"$",
"anId",
",",
"$",
"anEmail",
",",
"$",
"userRoles",
")",
";... | Invites user.
@param UserId $anId The id
@param UserEmail $anEmail The email
@param array $userRoles Array which contains the roles
@return static | [
"Invites",
"user",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L167-L180 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.acceptInvitation | public function acceptInvitation()
{
if ($this->isInvitationTokenAccepted()) {
throw new UserInvitationAlreadyAcceptedException();
}
if ($this->isInvitationTokenExpired()) {
throw new UserTokenExpiredException();
}
$this->invitationToken = null;
$this->updatedOn = new \DateTimeImmutable();
$this->publish(
new UserRegistered(
$this->id(),
$this->email()
)
);
} | php | public function acceptInvitation()
{
if ($this->isInvitationTokenAccepted()) {
throw new UserInvitationAlreadyAcceptedException();
}
if ($this->isInvitationTokenExpired()) {
throw new UserTokenExpiredException();
}
$this->invitationToken = null;
$this->updatedOn = new \DateTimeImmutable();
$this->publish(
new UserRegistered(
$this->id(),
$this->email()
)
);
} | [
"public",
"function",
"acceptInvitation",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isInvitationTokenAccepted",
"(",
")",
")",
"{",
"throw",
"new",
"UserInvitationAlreadyAcceptedException",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isInvitationTok... | Accepts the invitation request.
@throws UserTokenExpiredException when the token is expired | [
"Accepts",
"the",
"invitation",
"request",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L197-L213 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.changePassword | public function changePassword(UserPassword $aPassword)
{
$this->password = $aPassword;
$this->rememberPasswordToken = null;
$this->updatedOn = new \DateTimeImmutable();
} | php | public function changePassword(UserPassword $aPassword)
{
$this->password = $aPassword;
$this->rememberPasswordToken = null;
$this->updatedOn = new \DateTimeImmutable();
} | [
"public",
"function",
"changePassword",
"(",
"UserPassword",
"$",
"aPassword",
")",
"{",
"$",
"this",
"->",
"password",
"=",
"$",
"aPassword",
";",
"$",
"this",
"->",
"rememberPasswordToken",
"=",
"null",
";",
"$",
"this",
"->",
"updatedOn",
"=",
"new",
"\... | Updates the user password.
@param UserPassword $aPassword The old password
@throws UserTokenExpiredException when the token is expired | [
"Updates",
"the",
"user",
"password",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L222-L227 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.confirmationToken | public function confirmationToken()
{
// This ternary is a hack that avoids the
// DoctrineORM limitation with nullable embeddables
return $this->confirmationToken instanceof UserToken
&& null === $this->confirmationToken->token()
? null
: $this->confirmationToken;
} | php | public function confirmationToken()
{
// This ternary is a hack that avoids the
// DoctrineORM limitation with nullable embeddables
return $this->confirmationToken instanceof UserToken
&& null === $this->confirmationToken->token()
? null
: $this->confirmationToken;
} | [
"public",
"function",
"confirmationToken",
"(",
")",
"{",
"// This ternary is a hack that avoids the",
"// DoctrineORM limitation with nullable embeddables",
"return",
"$",
"this",
"->",
"confirmationToken",
"instanceof",
"UserToken",
"&&",
"null",
"===",
"$",
"this",
"->",
... | Gets the confirmation token.
@return UserToken|null | [
"Gets",
"the",
"confirmation",
"token",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L254-L262 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.enableAccount | public function enableAccount()
{
$this->confirmationToken = null;
$this->updatedOn = new \DateTimeImmutable();
$this->publish(
new UserEnabled(
$this->id,
$this->email
)
);
} | php | public function enableAccount()
{
$this->confirmationToken = null;
$this->updatedOn = new \DateTimeImmutable();
$this->publish(
new UserEnabled(
$this->id,
$this->email
)
);
} | [
"public",
"function",
"enableAccount",
"(",
")",
"{",
"$",
"this",
"->",
"confirmationToken",
"=",
"null",
";",
"$",
"this",
"->",
"updatedOn",
"=",
"new",
"\\",
"DateTimeImmutable",
"(",
")",
";",
"$",
"this",
"->",
"publish",
"(",
"new",
"UserEnabled",
... | Enables the user account. | [
"Enables",
"the",
"user",
"account",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L287-L298 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.grant | public function grant(UserRole $aRole)
{
if (false === $this->isRoleAllowed($aRole)) {
throw new UserRoleInvalidException();
}
if (true === $this->isGranted($aRole)) {
throw new UserRoleAlreadyGrantedException();
}
$this->roles[] = $aRole;
$this->updatedOn = new \DateTimeImmutable();
$this->publish(
new UserRoleGranted(
$this->id,
$this->email,
$aRole
)
);
} | php | public function grant(UserRole $aRole)
{
if (false === $this->isRoleAllowed($aRole)) {
throw new UserRoleInvalidException();
}
if (true === $this->isGranted($aRole)) {
throw new UserRoleAlreadyGrantedException();
}
$this->roles[] = $aRole;
$this->updatedOn = new \DateTimeImmutable();
$this->publish(
new UserRoleGranted(
$this->id,
$this->email,
$aRole
)
);
} | [
"public",
"function",
"grant",
"(",
"UserRole",
"$",
"aRole",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"isRoleAllowed",
"(",
"$",
"aRole",
")",
")",
"{",
"throw",
"new",
"UserRoleInvalidException",
"(",
")",
";",
"}",
"if",
"(",
"true",
... | Adds the given role.
@param UserRole $aRole The user role
@throws UserRoleInvalidException when the user is role is invalid
@throws UserRoleAlreadyGrantedException when the user role is already granted | [
"Adds",
"the",
"given",
"role",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L308-L326 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.invitationToken | public function invitationToken()
{
// This ternary is a hack that avoids the
// DoctrineORM limitation with nullable embeddables
return $this->invitationToken instanceof UserToken
&& null === $this->invitationToken->token()
? null
: $this->invitationToken;
} | php | public function invitationToken()
{
// This ternary is a hack that avoids the
// DoctrineORM limitation with nullable embeddables
return $this->invitationToken instanceof UserToken
&& null === $this->invitationToken->token()
? null
: $this->invitationToken;
} | [
"public",
"function",
"invitationToken",
"(",
")",
"{",
"// This ternary is a hack that avoids the",
"// DoctrineORM limitation with nullable embeddables",
"return",
"$",
"this",
"->",
"invitationToken",
"instanceof",
"UserToken",
"&&",
"null",
"===",
"$",
"this",
"->",
"in... | Gets the invitation token.
@return UserToken|null | [
"Gets",
"the",
"invitation",
"token",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L333-L341 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.isInvitationTokenExpired | public function isInvitationTokenExpired()
{
if (!$this->invitationToken() instanceof UserToken) {
throw new UserTokenNotFoundException();
}
return $this->invitationToken->isExpired(
$this->invitationTokenLifetime()
);
} | php | public function isInvitationTokenExpired()
{
if (!$this->invitationToken() instanceof UserToken) {
throw new UserTokenNotFoundException();
}
return $this->invitationToken->isExpired(
$this->invitationTokenLifetime()
);
} | [
"public",
"function",
"isInvitationTokenExpired",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"invitationToken",
"(",
")",
"instanceof",
"UserToken",
")",
"{",
"throw",
"new",
"UserTokenNotFoundException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->... | Checks if the invitation token is expired or not.
@throws UserTokenNotFoundException when the invitation token does not exist
@return bool | [
"Checks",
"if",
"the",
"invitation",
"token",
"is",
"expired",
"or",
"not",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L388-L397 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.isRememberPasswordTokenExpired | public function isRememberPasswordTokenExpired()
{
if (!$this->rememberPasswordToken() instanceof UserToken) {
throw new UserTokenNotFoundException();
}
return $this->rememberPasswordToken->isExpired(
$this->rememberPasswordTokenLifetime()
);
} | php | public function isRememberPasswordTokenExpired()
{
if (!$this->rememberPasswordToken() instanceof UserToken) {
throw new UserTokenNotFoundException();
}
return $this->rememberPasswordToken->isExpired(
$this->rememberPasswordTokenLifetime()
);
} | [
"public",
"function",
"isRememberPasswordTokenExpired",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"rememberPasswordToken",
"(",
")",
"instanceof",
"UserToken",
")",
"{",
"throw",
"new",
"UserTokenNotFoundException",
"(",
")",
";",
"}",
"return",
"$",
"... | Checks if the remember password token is expired or not.
@throws UserTokenNotFoundException when the remember password token does not exist
@return bool | [
"Checks",
"if",
"the",
"remember",
"password",
"token",
"is",
"expired",
"or",
"not",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L406-L415 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.login | public function login($aPlainPassword, UserPasswordEncoder $anEncoder)
{
if (false === $this->isEnabled()) {
throw new UserInactiveException();
}
if (false === $this->password()->equals($aPlainPassword, $anEncoder)) {
throw new UserPasswordInvalidException();
}
$this->lastLogin = new \DateTimeImmutable();
$this->publish(
new UserLoggedIn(
$this->id,
$this->email
)
);
} | php | public function login($aPlainPassword, UserPasswordEncoder $anEncoder)
{
if (false === $this->isEnabled()) {
throw new UserInactiveException();
}
if (false === $this->password()->equals($aPlainPassword, $anEncoder)) {
throw new UserPasswordInvalidException();
}
$this->lastLogin = new \DateTimeImmutable();
$this->publish(
new UserLoggedIn(
$this->id,
$this->email
)
);
} | [
"public",
"function",
"login",
"(",
"$",
"aPlainPassword",
",",
"UserPasswordEncoder",
"$",
"anEncoder",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"throw",
"new",
"UserInactiveException",
"(",
")",
";",
"}",
... | Validates user login for the given password.
@param string $aPlainPassword Plain password used to log in
@param UserPasswordEncoder $anEncoder The encoder used to encode the password
@throws UserInactiveException when the user is not enabled
@throws UserPasswordInvalidException when the user password is invalid | [
"Validates",
"user",
"login",
"for",
"the",
"given",
"password",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L448-L464 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.logout | public function logout()
{
if (false === $this->isEnabled()) {
throw new UserInactiveException();
}
$this->publish(
new UserLoggedOut(
$this->id,
$this->email
)
);
} | php | public function logout()
{
if (false === $this->isEnabled()) {
throw new UserInactiveException();
}
$this->publish(
new UserLoggedOut(
$this->id,
$this->email
)
);
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"throw",
"new",
"UserInactiveException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"publish",
"(",
"new",
"UserLoggedOut",
"(",
... | Updated the user state after logout.
@throws UserInactiveException when the user is not enabled | [
"Updated",
"the",
"user",
"state",
"after",
"logout",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L471-L483 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.regenerateInvitationToken | public function regenerateInvitationToken()
{
if (null === $this->invitationToken()) {
throw new UserInvitationAlreadyAcceptedException();
}
$this->invitationToken = new UserToken();
$this->publish(
new UserInvitationTokenRegenerated(
$this->id,
$this->email,
$this->invitationToken
)
);
} | php | public function regenerateInvitationToken()
{
if (null === $this->invitationToken()) {
throw new UserInvitationAlreadyAcceptedException();
}
$this->invitationToken = new UserToken();
$this->publish(
new UserInvitationTokenRegenerated(
$this->id,
$this->email,
$this->invitationToken
)
);
} | [
"public",
"function",
"regenerateInvitationToken",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"invitationToken",
"(",
")",
")",
"{",
"throw",
"new",
"UserInvitationAlreadyAcceptedException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"invitationTo... | Updates the invitation token in case a user has
been already invited and has lost the token.
@throws UserInvitationAlreadyAcceptedException in case user has already accepted the invitation | [
"Updates",
"the",
"invitation",
"token",
"in",
"case",
"a",
"user",
"has",
"been",
"already",
"invited",
"and",
"has",
"lost",
"the",
"token",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L501-L515 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.rememberPasswordToken | public function rememberPasswordToken()
{
// This ternary is a hack that avoids the
// DoctrineORM limitation with nullable embeddables
return $this->rememberPasswordToken instanceof UserToken
&& null === $this->rememberPasswordToken->token()
? null
: $this->rememberPasswordToken;
} | php | public function rememberPasswordToken()
{
// This ternary is a hack that avoids the
// DoctrineORM limitation with nullable embeddables
return $this->rememberPasswordToken instanceof UserToken
&& null === $this->rememberPasswordToken->token()
? null
: $this->rememberPasswordToken;
} | [
"public",
"function",
"rememberPasswordToken",
"(",
")",
"{",
"// This ternary is a hack that avoids the",
"// DoctrineORM limitation with nullable embeddables",
"return",
"$",
"this",
"->",
"rememberPasswordToken",
"instanceof",
"UserToken",
"&&",
"null",
"===",
"$",
"this",
... | Gets the remember password token.
@return UserToken | [
"Gets",
"the",
"remember",
"password",
"token",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L522-L530 | train |
BenGorUser/User | src/BenGorUser/User/Domain/Model/User.php | User.rememberPassword | public function rememberPassword()
{
$this->rememberPasswordToken = new UserToken();
$this->publish(
new UserRememberPasswordRequested(
$this->id,
$this->email,
$this->rememberPasswordToken
)
);
} | php | public function rememberPassword()
{
$this->rememberPasswordToken = new UserToken();
$this->publish(
new UserRememberPasswordRequested(
$this->id,
$this->email,
$this->rememberPasswordToken
)
);
} | [
"public",
"function",
"rememberPassword",
"(",
")",
"{",
"$",
"this",
"->",
"rememberPasswordToken",
"=",
"new",
"UserToken",
"(",
")",
";",
"$",
"this",
"->",
"publish",
"(",
"new",
"UserRememberPasswordRequested",
"(",
"$",
"this",
"->",
"id",
",",
"$",
... | Remembers the password. | [
"Remembers",
"the",
"password",
"."
] | 734900f463042194502191e4fb3e4f588cb7bf6f | https://github.com/BenGorUser/User/blob/734900f463042194502191e4fb3e4f588cb7bf6f/src/BenGorUser/User/Domain/Model/User.php#L535-L546 | train |
neos/party | Classes/Domain/Validator/ElectronicAddressValidator.php | ElectronicAddressValidator.isValid | public function isValid($value)
{
if ($value instanceof ElectronicAddress) {
$addressType = $value->getType();
switch ($addressType) {
case 'Email':
$addressValidator = $this->validatorResolver->createValidator('EmailAddress');
break;
default:
$addressValidator = $this->validatorResolver->createValidator('Neos.Party:' . $addressType . 'Address');
}
if ($addressValidator === null) {
$this->addError('No validator found for electronic address of type "' . $addressType . '".', 1268676030);
} else {
$result = $addressValidator->validate($value->getIdentifier());
if ($result->hasErrors()) {
$this->result = $result;
}
}
}
} | php | public function isValid($value)
{
if ($value instanceof ElectronicAddress) {
$addressType = $value->getType();
switch ($addressType) {
case 'Email':
$addressValidator = $this->validatorResolver->createValidator('EmailAddress');
break;
default:
$addressValidator = $this->validatorResolver->createValidator('Neos.Party:' . $addressType . 'Address');
}
if ($addressValidator === null) {
$this->addError('No validator found for electronic address of type "' . $addressType . '".', 1268676030);
} else {
$result = $addressValidator->validate($value->getIdentifier());
if ($result->hasErrors()) {
$this->result = $result;
}
}
}
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"ElectronicAddress",
")",
"{",
"$",
"addressType",
"=",
"$",
"value",
"->",
"getType",
"(",
")",
";",
"switch",
"(",
"$",
"addressType",
")",
"{",
"cas... | Checks if the given value is a valid electronic address according to its type.
If at least one error occurred, the result is FALSE and any errors can
be retrieved through the getErrors() method.
@param mixed $value The value that should be validated
@return void | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"electronic",
"address",
"according",
"to",
"its",
"type",
"."
] | cf771039e8da24762c21640f8761d40d281c0cd0 | https://github.com/neos/party/blob/cf771039e8da24762c21640f8761d40d281c0cd0/Classes/Domain/Validator/ElectronicAddressValidator.php#L49-L69 | train |
hiqdev/omnipay-bitpay | src/Message/CompletePurchaseResponse.php | CompletePurchaseResponse.isSuccessful | public function isSuccessful()
{
return $this->data->getStatus() === InvoiceInterface::STATUS_CONFIRMED || $this->data->getStatus() === InvoiceInterface::STATUS_COMPLETE;
} | php | public function isSuccessful()
{
return $this->data->getStatus() === InvoiceInterface::STATUS_CONFIRMED || $this->data->getStatus() === InvoiceInterface::STATUS_COMPLETE;
} | [
"public",
"function",
"isSuccessful",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"->",
"getStatus",
"(",
")",
"===",
"InvoiceInterface",
"::",
"STATUS_CONFIRMED",
"||",
"$",
"this",
"->",
"data",
"->",
"getStatus",
"(",
")",
"===",
"InvoiceInterface... | Whether the payment is successful.
@return boolean | [
"Whether",
"the",
"payment",
"is",
"successful",
"."
] | b2786c95b04382e30c61cf6b08be3744bd887df1 | https://github.com/hiqdev/omnipay-bitpay/blob/b2786c95b04382e30c61cf6b08be3744bd887df1/src/Message/CompletePurchaseResponse.php#L45-L48 | train |
hiqdev/omnipay-bitpay | src/Message/CompletePurchaseResponse.php | CompletePurchaseResponse.getTime | public function getTime()
{
$time = $this->data->getInvoiceTime();
if ($time instanceof \DateTime) {
return $time->format('c');
}
return date('c', $time/1000); // time in ms
} | php | public function getTime()
{
$time = $this->data->getInvoiceTime();
if ($time instanceof \DateTime) {
return $time->format('c');
}
return date('c', $time/1000); // time in ms
} | [
"public",
"function",
"getTime",
"(",
")",
"{",
"$",
"time",
"=",
"$",
"this",
"->",
"data",
"->",
"getInvoiceTime",
"(",
")",
";",
"if",
"(",
"$",
"time",
"instanceof",
"\\",
"DateTime",
")",
"{",
"return",
"$",
"time",
"->",
"format",
"(",
"'c'",
... | Returns the payment date.
@return string | [
"Returns",
"the",
"payment",
"date",
"."
] | b2786c95b04382e30c61cf6b08be3744bd887df1 | https://github.com/hiqdev/omnipay-bitpay/blob/b2786c95b04382e30c61cf6b08be3744bd887df1/src/Message/CompletePurchaseResponse.php#L139-L148 | train |
czim/laravel-cms-auth | src/Providers/SentinelServiceProvider.php | SentinelServiceProvider.registerSentinel | protected function registerSentinel()
{
$this->app->singleton('sentinel', function ($app) {
// @codeCoverageIgnoreStart
$sentinel = new Sentinel(
$app['sentinel.persistence'],
$app['sentinel.users'],
$app['sentinel.roles'],
$app['sentinel.activations'],
$app['events']
);
if (isset($app['sentinel.checkpoints'])) {
foreach ($app['sentinel.checkpoints'] as $key => $checkpoint) {
$sentinel->addCheckpoint($key, $checkpoint);
}
}
$sentinel->setActivationRepository($app['sentinel.activations']);
$sentinel->setReminderRepository($app['sentinel.reminders']);
$sentinel->setRequestCredentials(function () use ($app) {
$request = $app['request'];
$login = $request->getUser();
$password = $request->getPassword();
if ($login === null && $password === null) {
return null;
}
return compact('login', 'password');
});
$sentinel->creatingBasicResponse(function () {
$headers = ['WWW-Authenticate' => 'Basic'];
return response('Invalid credentials.', 401, $headers);
});
return $sentinel;
// @codeCoverageIgnoreEnd
});
// no alias
} | php | protected function registerSentinel()
{
$this->app->singleton('sentinel', function ($app) {
// @codeCoverageIgnoreStart
$sentinel = new Sentinel(
$app['sentinel.persistence'],
$app['sentinel.users'],
$app['sentinel.roles'],
$app['sentinel.activations'],
$app['events']
);
if (isset($app['sentinel.checkpoints'])) {
foreach ($app['sentinel.checkpoints'] as $key => $checkpoint) {
$sentinel->addCheckpoint($key, $checkpoint);
}
}
$sentinel->setActivationRepository($app['sentinel.activations']);
$sentinel->setReminderRepository($app['sentinel.reminders']);
$sentinel->setRequestCredentials(function () use ($app) {
$request = $app['request'];
$login = $request->getUser();
$password = $request->getPassword();
if ($login === null && $password === null) {
return null;
}
return compact('login', 'password');
});
$sentinel->creatingBasicResponse(function () {
$headers = ['WWW-Authenticate' => 'Basic'];
return response('Invalid credentials.', 401, $headers);
});
return $sentinel;
// @codeCoverageIgnoreEnd
});
// no alias
} | [
"protected",
"function",
"registerSentinel",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'sentinel'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"// @codeCoverageIgnoreStart",
"$",
"sentinel",
"=",
"new",
"Sentinel",
"(",
"$",
"app",
... | Overrides parent so as not to use the alias.
{@inheritdoc} | [
"Overrides",
"parent",
"so",
"as",
"not",
"to",
"use",
"the",
"alias",
"."
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Providers/SentinelServiceProvider.php#L30-L75 | train |
czim/laravel-cms-auth | src/Providers/SentinelServiceProvider.php | SentinelServiceProvider.registerUsers | protected function registerUsers()
{
$this->registerHasher();
$this->app->singleton('sentinel.users', function ($app) {
$config = $app['config']->get('cartalyst.sentinel');
$users = array_get($config, 'users.model');
$roles = array_get($config, 'roles.model');
$persistences = array_get($config, 'persistences.model');
$permissions = array_get($config, 'permissions.class');
if (class_exists($roles) && method_exists($roles, 'setUsersModel')) {
forward_static_call_array([$roles, 'setUsersModel'], [$users]);
}
if (class_exists($persistences) && method_exists($persistences, 'setUsersModel')) {
forward_static_call_array([$persistences, 'setUsersModel'], [$users]);
}
if (class_exists($users) && method_exists($users, 'setPermissionsClass')) {
forward_static_call_array([$users, 'setPermissionsClass'], [$permissions]);
}
return new IlluminateUserRepository($app['sentinel.hasher'], $app['events'], $users);
});
} | php | protected function registerUsers()
{
$this->registerHasher();
$this->app->singleton('sentinel.users', function ($app) {
$config = $app['config']->get('cartalyst.sentinel');
$users = array_get($config, 'users.model');
$roles = array_get($config, 'roles.model');
$persistences = array_get($config, 'persistences.model');
$permissions = array_get($config, 'permissions.class');
if (class_exists($roles) && method_exists($roles, 'setUsersModel')) {
forward_static_call_array([$roles, 'setUsersModel'], [$users]);
}
if (class_exists($persistences) && method_exists($persistences, 'setUsersModel')) {
forward_static_call_array([$persistences, 'setUsersModel'], [$users]);
}
if (class_exists($users) && method_exists($users, 'setPermissionsClass')) {
forward_static_call_array([$users, 'setPermissionsClass'], [$permissions]);
}
return new IlluminateUserRepository($app['sentinel.hasher'], $app['events'], $users);
});
} | [
"protected",
"function",
"registerUsers",
"(",
")",
"{",
"$",
"this",
"->",
"registerHasher",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'sentinel.users'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app... | Overrides the parent so we can bind our own UserRepository
{@inheritdoc} | [
"Overrides",
"the",
"parent",
"so",
"we",
"can",
"bind",
"our",
"own",
"UserRepository"
] | dbd7fecc69e891f8befdd6039244037a42c4b10f | https://github.com/czim/laravel-cms-auth/blob/dbd7fecc69e891f8befdd6039244037a42c4b10f/src/Providers/SentinelServiceProvider.php#L82-L108 | train |
jasny/db | src/QueryBuilder/StagedQueryBuilder.php | StagedQueryBuilder.withAddedStep | protected function withAddedStep(string $stage, callable $step, bool $replace = false)
{
$clone = clone $this;
if ($replace) {
$clone->stages[$stage] = [];
}
$clone->stages[$stage][] = $step;
return $clone;
} | php | protected function withAddedStep(string $stage, callable $step, bool $replace = false)
{
$clone = clone $this;
if ($replace) {
$clone->stages[$stage] = [];
}
$clone->stages[$stage][] = $step;
return $clone;
} | [
"protected",
"function",
"withAddedStep",
"(",
"string",
"$",
"stage",
",",
"callable",
"$",
"step",
",",
"bool",
"$",
"replace",
"=",
"false",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"if",
"(",
"$",
"replace",
")",
"{",
"$",
"clone",... | Create a clone with a new step
@param string $stage
@param callable $step
@param bool $replace
@return static | [
"Create",
"a",
"clone",
"with",
"a",
"new",
"step"
] | efd57d9dd8f3f40235c4da8b39a81f03d5f79b25 | https://github.com/jasny/db/blob/efd57d9dd8f3f40235c4da8b39a81f03d5f79b25/src/QueryBuilder/StagedQueryBuilder.php#L33-L44 | train |
jasny/db | src/QueryBuilder/StagedQueryBuilder.php | StagedQueryBuilder.withFilteredSteps | public function withFilteredSteps(callable $matcher)
{
$clone = clone $this;
foreach ($clone->stages as $stage => &$steps) {
$steps = array_filter($steps, function ($step) use ($matcher, $stage) {
return $matcher($stage, $step);
});
}
return $clone;
} | php | public function withFilteredSteps(callable $matcher)
{
$clone = clone $this;
foreach ($clone->stages as $stage => &$steps) {
$steps = array_filter($steps, function ($step) use ($matcher, $stage) {
return $matcher($stage, $step);
});
}
return $clone;
} | [
"public",
"function",
"withFilteredSteps",
"(",
"callable",
"$",
"matcher",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"foreach",
"(",
"$",
"clone",
"->",
"stages",
"as",
"$",
"stage",
"=>",
"&",
"$",
"steps",
")",
"{",
"$",
"steps",
"="... | Return a query builder with some steps removed.
@param callable $matcher
@return static | [
"Return",
"a",
"query",
"builder",
"with",
"some",
"steps",
"removed",
"."
] | efd57d9dd8f3f40235c4da8b39a81f03d5f79b25 | https://github.com/jasny/db/blob/efd57d9dd8f3f40235c4da8b39a81f03d5f79b25/src/QueryBuilder/StagedQueryBuilder.php#L52-L63 | train |
jasny/db | src/QueryBuilder/StagedQueryBuilder.php | StagedQueryBuilder.buildQuery | public function buildQuery(iterable $filter, array $opts = [])
{
return Pipeline::with($this->stages)
->flatten()
->reduce(function($data, callable $step) use ($opts) {
return $step($data, $opts);
}, $filter);
} | php | public function buildQuery(iterable $filter, array $opts = [])
{
return Pipeline::with($this->stages)
->flatten()
->reduce(function($data, callable $step) use ($opts) {
return $step($data, $opts);
}, $filter);
} | [
"public",
"function",
"buildQuery",
"(",
"iterable",
"$",
"filter",
",",
"array",
"$",
"opts",
"=",
"[",
"]",
")",
"{",
"return",
"Pipeline",
"::",
"with",
"(",
"$",
"this",
"->",
"stages",
")",
"->",
"flatten",
"(",
")",
"->",
"reduce",
"(",
"functi... | Create the query from a filter
@param iterable $filter
@param array $opts
@return mixed | [
"Create",
"the",
"query",
"from",
"a",
"filter"
] | efd57d9dd8f3f40235c4da8b39a81f03d5f79b25 | https://github.com/jasny/db/blob/efd57d9dd8f3f40235c4da8b39a81f03d5f79b25/src/QueryBuilder/StagedQueryBuilder.php#L122-L129 | train |
moon-php/moon | src/AppFactory.php | AppFactory.buildFromContainer | public static function buildFromContainer(ContainerInterface $container): App
{
return new App(
self::request($container),
self::response($container),
self::processor($container),
self::matchableRequest($container),
self::errorHandler($container),
self::invalidRequestHandler($container),
self::streamReadLength($container)
);
} | php | public static function buildFromContainer(ContainerInterface $container): App
{
return new App(
self::request($container),
self::response($container),
self::processor($container),
self::matchableRequest($container),
self::errorHandler($container),
self::invalidRequestHandler($container),
self::streamReadLength($container)
);
} | [
"public",
"static",
"function",
"buildFromContainer",
"(",
"ContainerInterface",
"$",
"container",
")",
":",
"App",
"{",
"return",
"new",
"App",
"(",
"self",
"::",
"request",
"(",
"$",
"container",
")",
",",
"self",
"::",
"response",
"(",
"$",
"container",
... | Create an App using a container.
@throws NotFoundExceptionInterface
@throws ContainerExceptionInterface
@throws InvalidArgumentException | [
"Create",
"an",
"App",
"using",
"a",
"container",
"."
] | 25a6be494b829528f6181f544a21cda95d1226a2 | https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L36-L47 | train |
moon-php/moon | src/AppFactory.php | AppFactory.request | private static function request(ContainerInterface $container): ServerRequestInterface
{
if (!$container->has(ServerRequestInterface::class)) {
throw new InvalidArgumentException('Moon received an invalid request instance from the container');
}
return $container->get(ServerRequestInterface::class);
} | php | private static function request(ContainerInterface $container): ServerRequestInterface
{
if (!$container->has(ServerRequestInterface::class)) {
throw new InvalidArgumentException('Moon received an invalid request instance from the container');
}
return $container->get(ServerRequestInterface::class);
} | [
"private",
"static",
"function",
"request",
"(",
"ContainerInterface",
"$",
"container",
")",
":",
"ServerRequestInterface",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"ServerRequestInterface",
"::",
"class",
")",
")",
"{",
"throw",
"new",
"Inval... | Return an instance of the ServerRequestInterface.
@throws ContainerExceptionInterface
@throws InvalidArgumentException
@throws NotFoundExceptionInterface | [
"Return",
"an",
"instance",
"of",
"the",
"ServerRequestInterface",
"."
] | 25a6be494b829528f6181f544a21cda95d1226a2 | https://github.com/moon-php/moon/blob/25a6be494b829528f6181f544a21cda95d1226a2/src/AppFactory.php#L56-L63 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.