id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,200 | boekkooi/TwigJackBundle | src/Twig/Loader/DoctrineLoader.php | DoctrineLoader.findTemplate | protected function findTemplate($name)
{
if (!$this->isLoadableTemplate($name)) {
throw new \Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "%stemplate_name").', $name, $this->prefix));
}
$templateIdentifier = substr($name, strlen($this->prefix));
$template = $this->repository->find($templateIdentifier);
if ($template === null) {
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $name));
}
if (!($template instanceof TemplateInterface)) {
throw new \Twig_Error_Loader(sprintf('Unexpected template type "%s" found for template "%s".', get_class($template), $name));
}
if ($template instanceof TranslatableTemplateInterface) {
/** @var TranslatableTemplateInterface $template */
$locale = $this->getCurrentLocale();
$template->setCurrentLocale($locale);
}
return $template;
} | php | protected function findTemplate($name)
{
if (!$this->isLoadableTemplate($name)) {
throw new \Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "%stemplate_name").', $name, $this->prefix));
}
$templateIdentifier = substr($name, strlen($this->prefix));
$template = $this->repository->find($templateIdentifier);
if ($template === null) {
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $name));
}
if (!($template instanceof TemplateInterface)) {
throw new \Twig_Error_Loader(sprintf('Unexpected template type "%s" found for template "%s".', get_class($template), $name));
}
if ($template instanceof TranslatableTemplateInterface) {
/** @var TranslatableTemplateInterface $template */
$locale = $this->getCurrentLocale();
$template->setCurrentLocale($locale);
}
return $template;
} | [
"protected",
"function",
"findTemplate",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLoadableTemplate",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"Twig_Error_Loader",
"(",
"sprintf",
"(",
"'Malformed namespaced template name \"%s\" (expecting \"%stemplate_name\").'",
",",
"$",
"name",
",",
"$",
"this",
"->",
"prefix",
")",
")",
";",
"}",
"$",
"templateIdentifier",
"=",
"substr",
"(",
"$",
"name",
",",
"strlen",
"(",
"$",
"this",
"->",
"prefix",
")",
")",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"repository",
"->",
"find",
"(",
"$",
"templateIdentifier",
")",
";",
"if",
"(",
"$",
"template",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Twig_Error_Loader",
"(",
"sprintf",
"(",
"'Unable to find template \"%s\".'",
",",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"template",
"instanceof",
"TemplateInterface",
")",
")",
"{",
"throw",
"new",
"\\",
"Twig_Error_Loader",
"(",
"sprintf",
"(",
"'Unexpected template type \"%s\" found for template \"%s\".'",
",",
"get_class",
"(",
"$",
"template",
")",
",",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"$",
"template",
"instanceof",
"TranslatableTemplateInterface",
")",
"{",
"/** @var TranslatableTemplateInterface $template */",
"$",
"locale",
"=",
"$",
"this",
"->",
"getCurrentLocale",
"(",
")",
";",
"$",
"template",
"->",
"setCurrentLocale",
"(",
"$",
"locale",
")",
";",
"}",
"return",
"$",
"template",
";",
"}"
] | Find a template by it's name
@param string $name The name of the template to find
@return TemplateInterface
@throws \Twig_Error_Loader | [
"Find",
"a",
"template",
"by",
"it",
"s",
"name"
] | 8aa9fe7681eaabe6285aa76d0a52e9da4ff67ffa | https://github.com/boekkooi/TwigJackBundle/blob/8aa9fe7681eaabe6285aa76d0a52e9da4ff67ffa/src/Twig/Loader/DoctrineLoader.php#L112-L133 |
28,201 | peakphp/framework | src/Config/FilesHandlers.php | FilesHandlers.get | public function get(string $name): array
{
if (!$this->has($name)) {
throw new NoFileHandlersException($name);
}
return $this->handlers[$name];
} | php | public function get(string $name): array
{
if (!$this->has($name)) {
throw new NoFileHandlersException($name);
}
return $this->handlers[$name];
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"name",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"NoFileHandlersException",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
";",
"}"
] | Get a file handlers
@param string $name
@return array
@throws NoFileHandlersException | [
"Get",
"a",
"file",
"handlers"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Config/FilesHandlers.php#L90-L97 |
28,202 | peakphp/framework | src/Config/FilesHandlers.php | FilesHandlers.set | public function set(string $name, string $loader, string $processor): FilesHandlers
{
$this->handlers[$name] = [
'loader' => new $loader(),
'processor' => new $processor(),
];
return $this;
} | php | public function set(string $name, string $loader, string $processor): FilesHandlers
{
$this->handlers[$name] = [
'loader' => new $loader(),
'processor' => new $processor(),
];
return $this;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"loader",
",",
"string",
"$",
"processor",
")",
":",
"FilesHandlers",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
"=",
"[",
"'loader'",
"=>",
"new",
"$",
"loader",
"(",
")",
",",
"'processor'",
"=>",
"new",
"$",
"processor",
"(",
")",
",",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Add or override a file handlers
@param string $name
@param string $loader
@param string $processor
@return FilesHandlers | [
"Add",
"or",
"override",
"a",
"file",
"handlers"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Config/FilesHandlers.php#L143-L150 |
28,203 | milejko/mmi | src/Mmi/App/BootstrapCli.php | BootstrapCli.run | public function run()
{
$request = new \Mmi\Http\Request;
//ustawianie domyślnego języka jeśli istnieje
if (isset(\App\Registry::$config->languages[0])) {
$request->lang = \App\Registry::$config->languages[0];
}
$request->setModuleName('mmi')
->setControllerName('index')
->setActionName('index');
//ustawianie żądania
FrontController::getInstance()->setRequest($request)
->getView()->setRequest($request);
FrontController::getInstance()->getResponse()->clearHeaders();
} | php | public function run()
{
$request = new \Mmi\Http\Request;
//ustawianie domyślnego języka jeśli istnieje
if (isset(\App\Registry::$config->languages[0])) {
$request->lang = \App\Registry::$config->languages[0];
}
$request->setModuleName('mmi')
->setControllerName('index')
->setActionName('index');
//ustawianie żądania
FrontController::getInstance()->setRequest($request)
->getView()->setRequest($request);
FrontController::getInstance()->getResponse()->clearHeaders();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"\\",
"Mmi",
"\\",
"Http",
"\\",
"Request",
";",
"//ustawianie domyślnego języka jeśli istnieje",
"if",
"(",
"isset",
"(",
"\\",
"App",
"\\",
"Registry",
"::",
"$",
"config",
"->",
"languages",
"[",
"0",
"]",
")",
")",
"{",
"$",
"request",
"->",
"lang",
"=",
"\\",
"App",
"\\",
"Registry",
"::",
"$",
"config",
"->",
"languages",
"[",
"0",
"]",
";",
"}",
"$",
"request",
"->",
"setModuleName",
"(",
"'mmi'",
")",
"->",
"setControllerName",
"(",
"'index'",
")",
"->",
"setActionName",
"(",
"'index'",
")",
";",
"//ustawianie żądania",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"setRequest",
"(",
"$",
"request",
")",
"->",
"getView",
"(",
")",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getResponse",
"(",
")",
"->",
"clearHeaders",
"(",
")",
";",
"}"
] | Uruchamianie bootstrapa - brak front kontrolera | [
"Uruchamianie",
"bootstrapa",
"-",
"brak",
"front",
"kontrolera"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/App/BootstrapCli.php#L31-L45 |
28,204 | milejko/mmi | src/Mmi/Security/Auth.php | Auth._setAuthentication | protected function _setAuthentication(\Mmi\Security\AuthRecord $record)
{
//przekazanie danych z rekordu autoryzacji do sesji
$this->_session->setFromArray((array)$record);
return true;
} | php | protected function _setAuthentication(\Mmi\Security\AuthRecord $record)
{
//przekazanie danych z rekordu autoryzacji do sesji
$this->_session->setFromArray((array)$record);
return true;
} | [
"protected",
"function",
"_setAuthentication",
"(",
"\\",
"Mmi",
"\\",
"Security",
"\\",
"AuthRecord",
"$",
"record",
")",
"{",
"//przekazanie danych z rekordu autoryzacji do sesji",
"$",
"this",
"->",
"_session",
"->",
"setFromArray",
"(",
"(",
"array",
")",
"$",
"record",
")",
";",
"return",
"true",
";",
"}"
] | Wymuszenie ustawienia autoryzacji
@param \Mmi\Security\AuthRecord $record
@return boolean | [
"Wymuszenie",
"ustawienia",
"autoryzacji"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Security/Auth.php#L285-L290 |
28,205 | milejko/mmi | src/Mmi/Security/Auth.php | Auth.httpAuth | public function httpAuth($realm = '', $errorMessage = '')
{
//pobieranie usera i hasła ze zmiennych środowiskowych
$this->setIdentity(\Mmi\App\FrontController::getInstance()->getEnvironment()->authUser)
->setCredential(\Mmi\App\FrontController::getInstance()->getEnvironment()->authPassword);
//model autoryzacji
$model = $this->_modelName;
//autoryzacja
$record = $model::authenticate($this->_identity, $this->_credential);
//autoryzacja poprawna
if ($record) {
return;
}
//odpowiedź 401
\Mmi\App\FrontController::getInstance()->getResponse()
->setHeader('WWW-Authenticate', 'Basic realm="' . $realm . '"')
->setCodeUnauthorized()
->setContent($errorMessage);
//zakończenie skryptu
exit;
} | php | public function httpAuth($realm = '', $errorMessage = '')
{
//pobieranie usera i hasła ze zmiennych środowiskowych
$this->setIdentity(\Mmi\App\FrontController::getInstance()->getEnvironment()->authUser)
->setCredential(\Mmi\App\FrontController::getInstance()->getEnvironment()->authPassword);
//model autoryzacji
$model = $this->_modelName;
//autoryzacja
$record = $model::authenticate($this->_identity, $this->_credential);
//autoryzacja poprawna
if ($record) {
return;
}
//odpowiedź 401
\Mmi\App\FrontController::getInstance()->getResponse()
->setHeader('WWW-Authenticate', 'Basic realm="' . $realm . '"')
->setCodeUnauthorized()
->setContent($errorMessage);
//zakończenie skryptu
exit;
} | [
"public",
"function",
"httpAuth",
"(",
"$",
"realm",
"=",
"''",
",",
"$",
"errorMessage",
"=",
"''",
")",
"{",
"//pobieranie usera i hasła ze zmiennych środowiskowych",
"$",
"this",
"->",
"setIdentity",
"(",
"\\",
"Mmi",
"\\",
"App",
"\\",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getEnvironment",
"(",
")",
"->",
"authUser",
")",
"->",
"setCredential",
"(",
"\\",
"Mmi",
"\\",
"App",
"\\",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getEnvironment",
"(",
")",
"->",
"authPassword",
")",
";",
"//model autoryzacji",
"$",
"model",
"=",
"$",
"this",
"->",
"_modelName",
";",
"//autoryzacja",
"$",
"record",
"=",
"$",
"model",
"::",
"authenticate",
"(",
"$",
"this",
"->",
"_identity",
",",
"$",
"this",
"->",
"_credential",
")",
";",
"//autoryzacja poprawna",
"if",
"(",
"$",
"record",
")",
"{",
"return",
";",
"}",
"//odpowiedź 401",
"\\",
"Mmi",
"\\",
"App",
"\\",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"'WWW-Authenticate'",
",",
"'Basic realm=\"'",
".",
"$",
"realm",
".",
"'\"'",
")",
"->",
"setCodeUnauthorized",
"(",
")",
"->",
"setContent",
"(",
"$",
"errorMessage",
")",
";",
"//zakończenie skryptu",
"exit",
";",
"}"
] | Uwierzytelnienie przez http
@param string $realm identyfikator przestrzeni chronionej
@param string $errorMessage treść komunikatu zwrotnego - błędnego | [
"Uwierzytelnienie",
"przez",
"http"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Security/Auth.php#L317-L337 |
28,206 | peakphp/framework | src/Di/BindingResolver.php | BindingResolver.resolve | public function resolve(BindingInterface $binding, Container $container, $args = [], $explicit = null)
{
return $binding->resolve($container, $args, $explicit);
} | php | public function resolve(BindingInterface $binding, Container $container, $args = [], $explicit = null)
{
return $binding->resolve($container, $args, $explicit);
} | [
"public",
"function",
"resolve",
"(",
"BindingInterface",
"$",
"binding",
",",
"Container",
"$",
"container",
",",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"explicit",
"=",
"null",
")",
"{",
"return",
"$",
"binding",
"->",
"resolve",
"(",
"$",
"container",
",",
"$",
"args",
",",
"$",
"explicit",
")",
";",
"}"
] | Resolve a binding request
@param BindingInterface $binding
@param Container $container
@param array $args
@param null $explicit
@return mixed | [
"Resolve",
"a",
"binding",
"request"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/BindingResolver.php#L20-L23 |
28,207 | peakphp/framework | src/Bedrock/Bootstrap/BootableResolver.php | BootableResolver.resolve | public function resolve($item): Bootable
{
if(is_string($item) && class_exists($item)) {
if (null !== $this->container) {
$item = $this->container->get($item);
}
if (is_string($item)) {
$item = new $item();
}
} elseif (is_callable($item)) {
$item = new CallableProcess($item);
}
if (!$item instanceof Bootable) {
throw new InvalidBootableProcessException($item);
}
return $item;
} | php | public function resolve($item): Bootable
{
if(is_string($item) && class_exists($item)) {
if (null !== $this->container) {
$item = $this->container->get($item);
}
if (is_string($item)) {
$item = new $item();
}
} elseif (is_callable($item)) {
$item = new CallableProcess($item);
}
if (!$item instanceof Bootable) {
throw new InvalidBootableProcessException($item);
}
return $item;
} | [
"public",
"function",
"resolve",
"(",
"$",
"item",
")",
":",
"Bootable",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
"&&",
"class_exists",
"(",
"$",
"item",
")",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"container",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"item",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"$",
"item",
"=",
"new",
"$",
"item",
"(",
")",
";",
"}",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"item",
")",
")",
"{",
"$",
"item",
"=",
"new",
"CallableProcess",
"(",
"$",
"item",
")",
";",
"}",
"if",
"(",
"!",
"$",
"item",
"instanceof",
"Bootable",
")",
"{",
"throw",
"new",
"InvalidBootableProcessException",
"(",
"$",
"item",
")",
";",
"}",
"return",
"$",
"item",
";",
"}"
] | Try to return a resolved item or throw an exception
@param mixed $item
@return Bootable
@throws InvalidBootableProcessException | [
"Try",
"to",
"return",
"a",
"resolved",
"item",
"or",
"throw",
"an",
"exception"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Bootstrap/BootableResolver.php#L36-L54 |
28,208 | cedx/lcov.php | lib/FunctionData.php | FunctionData.fromJson | static function fromJson(object $map): self {
return new static(
isset($map->functionName) && is_string($map->functionName) ? $map->functionName : '',
isset($map->lineNumber) && is_int($map->lineNumber) ? $map->lineNumber : 0,
isset($map->executionCount) && is_int($map->executionCount) ? $map->executionCount : 0
);
} | php | static function fromJson(object $map): self {
return new static(
isset($map->functionName) && is_string($map->functionName) ? $map->functionName : '',
isset($map->lineNumber) && is_int($map->lineNumber) ? $map->lineNumber : 0,
isset($map->executionCount) && is_int($map->executionCount) ? $map->executionCount : 0
);
} | [
"static",
"function",
"fromJson",
"(",
"object",
"$",
"map",
")",
":",
"self",
"{",
"return",
"new",
"static",
"(",
"isset",
"(",
"$",
"map",
"->",
"functionName",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"functionName",
")",
"?",
"$",
"map",
"->",
"functionName",
":",
"''",
",",
"isset",
"(",
"$",
"map",
"->",
"lineNumber",
")",
"&&",
"is_int",
"(",
"$",
"map",
"->",
"lineNumber",
")",
"?",
"$",
"map",
"->",
"lineNumber",
":",
"0",
",",
"isset",
"(",
"$",
"map",
"->",
"executionCount",
")",
"&&",
"is_int",
"(",
"$",
"map",
"->",
"executionCount",
")",
"?",
"$",
"map",
"->",
"executionCount",
":",
"0",
")",
";",
"}"
] | Creates a new function data from the specified JSON map.
@param object $map A JSON map representing a function data.
@return static The instance corresponding to the specified JSON map. | [
"Creates",
"a",
"new",
"function",
"data",
"from",
"the",
"specified",
"JSON",
"map",
"."
] | ae0129ec01f3e77e3598b82971383c334b213afe | https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/lib/FunctionData.php#L41-L47 |
28,209 | cedx/lcov.php | lib/FunctionData.php | FunctionData.toString | function toString(bool $asDefinition = false): string {
$token = $asDefinition ? Token::functionName : Token::functionData;
$number = $asDefinition ? $this->getLineNumber() : $this->getExecutionCount();
return "$token:$number,{$this->getFunctionName()}";
} | php | function toString(bool $asDefinition = false): string {
$token = $asDefinition ? Token::functionName : Token::functionData;
$number = $asDefinition ? $this->getLineNumber() : $this->getExecutionCount();
return "$token:$number,{$this->getFunctionName()}";
} | [
"function",
"toString",
"(",
"bool",
"$",
"asDefinition",
"=",
"false",
")",
":",
"string",
"{",
"$",
"token",
"=",
"$",
"asDefinition",
"?",
"Token",
"::",
"functionName",
":",
"Token",
"::",
"functionData",
";",
"$",
"number",
"=",
"$",
"asDefinition",
"?",
"$",
"this",
"->",
"getLineNumber",
"(",
")",
":",
"$",
"this",
"->",
"getExecutionCount",
"(",
")",
";",
"return",
"\"$token:$number,{$this->getFunctionName()}\"",
";",
"}"
] | Returns a string representation of this object.
@param bool $asDefinition Value indicating whether to return the function definition (e.g. name and line number) instead of its data (e.g. name and execution count).
@return string The string representation of this object. | [
"Returns",
"a",
"string",
"representation",
"of",
"this",
"object",
"."
] | ae0129ec01f3e77e3598b82971383c334b213afe | https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/lib/FunctionData.php#L100-L104 |
28,210 | milejko/mmi | src/Mmi/Db/Deployer.php | Deployer._importIncremental | protected function _importIncremental($file)
{
//nazwa pliku
$baseFileName = basename($file);
//hash pliku
$md5file = md5_file($file);
//ustawianie domyślnych parametrów importu
\App\Registry::$db->setDefaultImportParams();
//pobranie rekordu
try {
$dc = (new Orm\ChangelogQuery)->whereFilename()->equals(basename($file))->findFirst();
} catch (\Exception $e) {
echo 'INITIAL IMPORT.' . "\n";
$dc = null;
}
//restore istnieje md5 zgodne
if ($dc && $dc->md5 == $md5file) {
echo 'INCREMENTAL PRESENT: ' . $baseFileName . "\n";
return;
}
//restore istnieje md5 niezgodne - plik się zmienił - przerwanie importu
if ($dc) {
throw new \Mmi\App\KernelException('INVALID MD5: ' . $baseFileName . ' --- VALID: ' . $md5file . ' --- IMPORT TERMINATED!\n');
}
//informacja na ekran przed importem aby bylo wiadomo który
echo 'RESTORE INCREMENTAL: ' . $baseFileName . "\n";
//import danych
$this->_importSql($file);
//resetowanie struktur tabeli
\Mmi\Orm\DbConnector::resetTableStructures();
//brak restore - zakłada nowy rekord
$newDc = new Orm\ChangelogRecord;
//zapis informacji o incrementalu
$newDc->filename = $baseFileName;
//wstawienie md5
$newDc->md5 = $md5file;
//zapis rekordu
$newDc->save();
} | php | protected function _importIncremental($file)
{
//nazwa pliku
$baseFileName = basename($file);
//hash pliku
$md5file = md5_file($file);
//ustawianie domyślnych parametrów importu
\App\Registry::$db->setDefaultImportParams();
//pobranie rekordu
try {
$dc = (new Orm\ChangelogQuery)->whereFilename()->equals(basename($file))->findFirst();
} catch (\Exception $e) {
echo 'INITIAL IMPORT.' . "\n";
$dc = null;
}
//restore istnieje md5 zgodne
if ($dc && $dc->md5 == $md5file) {
echo 'INCREMENTAL PRESENT: ' . $baseFileName . "\n";
return;
}
//restore istnieje md5 niezgodne - plik się zmienił - przerwanie importu
if ($dc) {
throw new \Mmi\App\KernelException('INVALID MD5: ' . $baseFileName . ' --- VALID: ' . $md5file . ' --- IMPORT TERMINATED!\n');
}
//informacja na ekran przed importem aby bylo wiadomo który
echo 'RESTORE INCREMENTAL: ' . $baseFileName . "\n";
//import danych
$this->_importSql($file);
//resetowanie struktur tabeli
\Mmi\Orm\DbConnector::resetTableStructures();
//brak restore - zakłada nowy rekord
$newDc = new Orm\ChangelogRecord;
//zapis informacji o incrementalu
$newDc->filename = $baseFileName;
//wstawienie md5
$newDc->md5 = $md5file;
//zapis rekordu
$newDc->save();
} | [
"protected",
"function",
"_importIncremental",
"(",
"$",
"file",
")",
"{",
"//nazwa pliku",
"$",
"baseFileName",
"=",
"basename",
"(",
"$",
"file",
")",
";",
"//hash pliku",
"$",
"md5file",
"=",
"md5_file",
"(",
"$",
"file",
")",
";",
"//ustawianie domyślnych parametrów importu",
"\\",
"App",
"\\",
"Registry",
"::",
"$",
"db",
"->",
"setDefaultImportParams",
"(",
")",
";",
"//pobranie rekordu",
"try",
"{",
"$",
"dc",
"=",
"(",
"new",
"Orm",
"\\",
"ChangelogQuery",
")",
"->",
"whereFilename",
"(",
")",
"->",
"equals",
"(",
"basename",
"(",
"$",
"file",
")",
")",
"->",
"findFirst",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"'INITIAL IMPORT.'",
".",
"\"\\n\"",
";",
"$",
"dc",
"=",
"null",
";",
"}",
"//restore istnieje md5 zgodne",
"if",
"(",
"$",
"dc",
"&&",
"$",
"dc",
"->",
"md5",
"==",
"$",
"md5file",
")",
"{",
"echo",
"'INCREMENTAL PRESENT: '",
".",
"$",
"baseFileName",
".",
"\"\\n\"",
";",
"return",
";",
"}",
"//restore istnieje md5 niezgodne - plik się zmienił - przerwanie importu",
"if",
"(",
"$",
"dc",
")",
"{",
"throw",
"new",
"\\",
"Mmi",
"\\",
"App",
"\\",
"KernelException",
"(",
"'INVALID MD5: '",
".",
"$",
"baseFileName",
".",
"' --- VALID: '",
".",
"$",
"md5file",
".",
"' --- IMPORT TERMINATED!\\n'",
")",
";",
"}",
"//informacja na ekran przed importem aby bylo wiadomo który",
"echo",
"'RESTORE INCREMENTAL: '",
".",
"$",
"baseFileName",
".",
"\"\\n\"",
";",
"//import danych",
"$",
"this",
"->",
"_importSql",
"(",
"$",
"file",
")",
";",
"//resetowanie struktur tabeli",
"\\",
"Mmi",
"\\",
"Orm",
"\\",
"DbConnector",
"::",
"resetTableStructures",
"(",
")",
";",
"//brak restore - zakłada nowy rekord",
"$",
"newDc",
"=",
"new",
"Orm",
"\\",
"ChangelogRecord",
";",
"//zapis informacji o incrementalu",
"$",
"newDc",
"->",
"filename",
"=",
"$",
"baseFileName",
";",
"//wstawienie md5",
"$",
"newDc",
"->",
"md5",
"=",
"$",
"md5file",
";",
"//zapis rekordu",
"$",
"newDc",
"->",
"save",
"(",
")",
";",
"}"
] | Importuje pojedynczy plik
@param string $file
@throws \Mmi\App\KernelException | [
"Importuje",
"pojedynczy",
"plik"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Deployer.php#L61-L99 |
28,211 | milejko/mmi | src/Mmi/Db/Deployer.php | Deployer._importSql | protected function _importSql($fileName)
{
//rozbicie zapytań po średniku i końcu linii
foreach (explode(';' . PHP_EOL, file_get_contents($fileName)) as $query) {
//wykonanie zapytania
$this->_performQuery($query);
}
} | php | protected function _importSql($fileName)
{
//rozbicie zapytań po średniku i końcu linii
foreach (explode(';' . PHP_EOL, file_get_contents($fileName)) as $query) {
//wykonanie zapytania
$this->_performQuery($query);
}
} | [
"protected",
"function",
"_importSql",
"(",
"$",
"fileName",
")",
"{",
"//rozbicie zapytań po średniku i końcu linii",
"foreach",
"(",
"explode",
"(",
"';'",
".",
"PHP_EOL",
",",
"file_get_contents",
"(",
"$",
"fileName",
")",
")",
"as",
"$",
"query",
")",
"{",
"//wykonanie zapytania",
"$",
"this",
"->",
"_performQuery",
"(",
"$",
"query",
")",
";",
"}",
"}"
] | Import pliku sql
@param string $fileName nazwa pliku | [
"Import",
"pliku",
"sql"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Deployer.php#L105-L112 |
28,212 | milejko/mmi | src/Mmi/Db/Deployer.php | Deployer._performQuery | protected function _performQuery($query)
{
//brak query
if (!trim($query)) {
return;
}
//start transakcji
\App\Registry::$db->beginTransaction();
//quera jeśli błędna rollback i die, jeśli poprawna commit
try {
//wykonanie zapytania
\App\Registry::$db->query($query);
//commit
\App\Registry::$db->commit();
} catch (\Mmi\Db\DbException $e) {
//rollback
\App\Registry::$db->rollBack();
throw $e;
}
} | php | protected function _performQuery($query)
{
//brak query
if (!trim($query)) {
return;
}
//start transakcji
\App\Registry::$db->beginTransaction();
//quera jeśli błędna rollback i die, jeśli poprawna commit
try {
//wykonanie zapytania
\App\Registry::$db->query($query);
//commit
\App\Registry::$db->commit();
} catch (\Mmi\Db\DbException $e) {
//rollback
\App\Registry::$db->rollBack();
throw $e;
}
} | [
"protected",
"function",
"_performQuery",
"(",
"$",
"query",
")",
"{",
"//brak query",
"if",
"(",
"!",
"trim",
"(",
"$",
"query",
")",
")",
"{",
"return",
";",
"}",
"//start transakcji",
"\\",
"App",
"\\",
"Registry",
"::",
"$",
"db",
"->",
"beginTransaction",
"(",
")",
";",
"//quera jeśli błędna rollback i die, jeśli poprawna commit",
"try",
"{",
"//wykonanie zapytania",
"\\",
"App",
"\\",
"Registry",
"::",
"$",
"db",
"->",
"query",
"(",
"$",
"query",
")",
";",
"//commit",
"\\",
"App",
"\\",
"Registry",
"::",
"$",
"db",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Mmi",
"\\",
"Db",
"\\",
"DbException",
"$",
"e",
")",
"{",
"//rollback",
"\\",
"App",
"\\",
"Registry",
"::",
"$",
"db",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Wykonanie pojedynczego zapytania
@param string $query | [
"Wykonanie",
"pojedynczego",
"zapytania"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Deployer.php#L118-L137 |
28,213 | milejko/mmi | src/Mmi/App/ComposerInstaller.php | ComposerInstaller._copyDistFiles | protected static function _copyDistFiles()
{
//iteracja po wymaganych plikach
foreach (self::$_distFiles as $src => $dest) {
//kalkulacja ścieżki
$source = BASE_PATH . $src;
//brak pliku
if (!file_exists($source)) {
continue;
}
//kopiowanie katalogów
\Mmi\FileSystem::copyRecursive($source, BASE_PATH . $dest, false);
//usuwanie źródła
\Mmi\FileSystem::rmdirRecursive($source);
//usuwanie placeholderów
\Mmi\FileSystem::unlinkRecursive('.placeholder', BASE_PATH . $dest);
}
} | php | protected static function _copyDistFiles()
{
//iteracja po wymaganych plikach
foreach (self::$_distFiles as $src => $dest) {
//kalkulacja ścieżki
$source = BASE_PATH . $src;
//brak pliku
if (!file_exists($source)) {
continue;
}
//kopiowanie katalogów
\Mmi\FileSystem::copyRecursive($source, BASE_PATH . $dest, false);
//usuwanie źródła
\Mmi\FileSystem::rmdirRecursive($source);
//usuwanie placeholderów
\Mmi\FileSystem::unlinkRecursive('.placeholder', BASE_PATH . $dest);
}
} | [
"protected",
"static",
"function",
"_copyDistFiles",
"(",
")",
"{",
"//iteracja po wymaganych plikach ",
"foreach",
"(",
"self",
"::",
"$",
"_distFiles",
"as",
"$",
"src",
"=>",
"$",
"dest",
")",
"{",
"//kalkulacja ścieżki ",
"$",
"source",
"=",
"BASE_PATH",
".",
"$",
"src",
";",
"//brak pliku ",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"source",
")",
")",
"{",
"continue",
";",
"}",
"//kopiowanie katalogów ",
"\\",
"Mmi",
"\\",
"FileSystem",
"::",
"copyRecursive",
"(",
"$",
"source",
",",
"BASE_PATH",
".",
"$",
"dest",
",",
"false",
")",
";",
"//usuwanie źródła ",
"\\",
"Mmi",
"\\",
"FileSystem",
"::",
"rmdirRecursive",
"(",
"$",
"source",
")",
";",
"//usuwanie placeholderów ",
"\\",
"Mmi",
"\\",
"FileSystem",
"::",
"unlinkRecursive",
"(",
"'.placeholder'",
",",
"BASE_PATH",
".",
"$",
"dest",
")",
";",
"}",
"}"
] | Kopiuje pliki z dystrybucji | [
"Kopiuje",
"pliki",
"z",
"dystrybucji"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/App/ComposerInstaller.php#L98-L115 |
28,214 | honeybee/honeybee | src/Infrastructure/DataAccess/Connector/StatusReport.php | StatusReport.generate | public static function generate(ConnectorMap $connector_map)
{
$details = [];
$failing = 0;
$working = 0;
$unknown = 0;
$connections = [];
foreach ($connector_map as $name => $connector) {
try {
$connections[$name] = $connector->getStatus();
} catch (Exception $e) {
$connections[$name] = Status::failing(
$connector,
[ 'message' => 'Exception on getStatus(): ' . $e->getMessage() ]
);
error_log('Error while getting status of connection "' . $name . '": ' . $e->getTraceAsString());
}
}
ksort($connections);
foreach ($connections as $name => $connection) {
$details[$name] = $connection->toArray();
if ($connection->isFailing()) {
$failing++;
} elseif ($connection->isWorking()) {
$working++;
} else {
$unknown++;
}
}
$overall = $connector_map->count();
$status = Status::UNKNOWN;
if ($failing > 0) {
$status = Status::FAILING;
} elseif ($working === $overall) {
$status = Status::WORKING;
}
$stats = [
'overall' => $overall,
'failing' => $failing,
'working' => $working,
'unknown' => $unknown
];
return new static($status, $stats, $details);
} | php | public static function generate(ConnectorMap $connector_map)
{
$details = [];
$failing = 0;
$working = 0;
$unknown = 0;
$connections = [];
foreach ($connector_map as $name => $connector) {
try {
$connections[$name] = $connector->getStatus();
} catch (Exception $e) {
$connections[$name] = Status::failing(
$connector,
[ 'message' => 'Exception on getStatus(): ' . $e->getMessage() ]
);
error_log('Error while getting status of connection "' . $name . '": ' . $e->getTraceAsString());
}
}
ksort($connections);
foreach ($connections as $name => $connection) {
$details[$name] = $connection->toArray();
if ($connection->isFailing()) {
$failing++;
} elseif ($connection->isWorking()) {
$working++;
} else {
$unknown++;
}
}
$overall = $connector_map->count();
$status = Status::UNKNOWN;
if ($failing > 0) {
$status = Status::FAILING;
} elseif ($working === $overall) {
$status = Status::WORKING;
}
$stats = [
'overall' => $overall,
'failing' => $failing,
'working' => $working,
'unknown' => $unknown
];
return new static($status, $stats, $details);
} | [
"public",
"static",
"function",
"generate",
"(",
"ConnectorMap",
"$",
"connector_map",
")",
"{",
"$",
"details",
"=",
"[",
"]",
";",
"$",
"failing",
"=",
"0",
";",
"$",
"working",
"=",
"0",
";",
"$",
"unknown",
"=",
"0",
";",
"$",
"connections",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"connector_map",
"as",
"$",
"name",
"=>",
"$",
"connector",
")",
"{",
"try",
"{",
"$",
"connections",
"[",
"$",
"name",
"]",
"=",
"$",
"connector",
"->",
"getStatus",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"connections",
"[",
"$",
"name",
"]",
"=",
"Status",
"::",
"failing",
"(",
"$",
"connector",
",",
"[",
"'message'",
"=>",
"'Exception on getStatus(): '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
")",
";",
"error_log",
"(",
"'Error while getting status of connection \"'",
".",
"$",
"name",
".",
"'\": '",
".",
"$",
"e",
"->",
"getTraceAsString",
"(",
")",
")",
";",
"}",
"}",
"ksort",
"(",
"$",
"connections",
")",
";",
"foreach",
"(",
"$",
"connections",
"as",
"$",
"name",
"=>",
"$",
"connection",
")",
"{",
"$",
"details",
"[",
"$",
"name",
"]",
"=",
"$",
"connection",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"$",
"connection",
"->",
"isFailing",
"(",
")",
")",
"{",
"$",
"failing",
"++",
";",
"}",
"elseif",
"(",
"$",
"connection",
"->",
"isWorking",
"(",
")",
")",
"{",
"$",
"working",
"++",
";",
"}",
"else",
"{",
"$",
"unknown",
"++",
";",
"}",
"}",
"$",
"overall",
"=",
"$",
"connector_map",
"->",
"count",
"(",
")",
";",
"$",
"status",
"=",
"Status",
"::",
"UNKNOWN",
";",
"if",
"(",
"$",
"failing",
">",
"0",
")",
"{",
"$",
"status",
"=",
"Status",
"::",
"FAILING",
";",
"}",
"elseif",
"(",
"$",
"working",
"===",
"$",
"overall",
")",
"{",
"$",
"status",
"=",
"Status",
"::",
"WORKING",
";",
"}",
"$",
"stats",
"=",
"[",
"'overall'",
"=>",
"$",
"overall",
",",
"'failing'",
"=>",
"$",
"failing",
",",
"'working'",
"=>",
"$",
"working",
",",
"'unknown'",
"=>",
"$",
"unknown",
"]",
";",
"return",
"new",
"static",
"(",
"$",
"status",
",",
"$",
"stats",
",",
"$",
"details",
")",
";",
"}"
] | Generates a new StatusReport by getting the Status from all known connections.
@todo Should only specific exceptions be catched when getStatus() is called on the connectors? Rethrow?
@param ConnectorMap $connector_map
@return StatusReport | [
"Generates",
"a",
"new",
"StatusReport",
"by",
"getting",
"the",
"Status",
"from",
"all",
"known",
"connections",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/DataAccess/Connector/StatusReport.php#L42-L93 |
28,215 | milejko/mmi | src/Mmi/Cache/FileHandler.php | FileHandler._deleteNoBroadcasting | protected function _deleteNoBroadcasting($key)
{
//próba usunięcia pliku
try {
unlink($this->_cache->getConfig()->path . '/' . $key);
} catch (\Exception $e) {
//nic
}
return true;
} | php | protected function _deleteNoBroadcasting($key)
{
//próba usunięcia pliku
try {
unlink($this->_cache->getConfig()->path . '/' . $key);
} catch (\Exception $e) {
//nic
}
return true;
} | [
"protected",
"function",
"_deleteNoBroadcasting",
"(",
"$",
"key",
")",
"{",
"//próba usunięcia pliku",
"try",
"{",
"unlink",
"(",
"$",
"this",
"->",
"_cache",
"->",
"getConfig",
"(",
")",
"->",
"path",
".",
"'/'",
".",
"$",
"key",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//nic",
"}",
"return",
"true",
";",
"}"
] | Kasuje dane o podanym kluczu
@param string $key klucz
@return boolean | [
"Kasuje",
"dane",
"o",
"podanym",
"kluczu"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/FileHandler.php#L54-L63 |
28,216 | peakphp/framework | src/Common/ClassFinder.php | ClassFinder.findFirst | public function findFirst(string $basename): ?string
{
$basename = $this->getClassName($basename);
foreach ($this->namespaces as $ns) {
if (class_exists($ns.'\\'.$basename)) {
return $ns.'\\'.$basename;
}
}
return null;
} | php | public function findFirst(string $basename): ?string
{
$basename = $this->getClassName($basename);
foreach ($this->namespaces as $ns) {
if (class_exists($ns.'\\'.$basename)) {
return $ns.'\\'.$basename;
}
}
return null;
} | [
"public",
"function",
"findFirst",
"(",
"string",
"$",
"basename",
")",
":",
"?",
"string",
"{",
"$",
"basename",
"=",
"$",
"this",
"->",
"getClassName",
"(",
"$",
"basename",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"ns",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"ns",
".",
"'\\\\'",
".",
"$",
"basename",
")",
")",
"{",
"return",
"$",
"ns",
".",
"'\\\\'",
".",
"$",
"basename",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Return the first class name found or false
@param string $basename
@return string|null | [
"Return",
"the",
"first",
"class",
"name",
"found",
"or",
"false"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/ClassFinder.php#L67-L76 |
28,217 | milejko/mmi | src/Mmi/FileSystem.php | FileSystem.unlinkRecursive | public static function unlinkRecursive($fileName, $rootName)
{
//brak katalogu głównego
if (!file_exists($rootName)) {
return false;
}
//iteracja po katalogu głównym
foreach (new \DirectoryIterator($rootName) as $file) {
//katalog .
if ($file->isDot()) {
continue;
}
//katalog
if ($file->isDir()) {
//zejście rekurencyjne
self::unlinkRecursive($fileName, $file->getPathname());
continue;
}
//to nie jest szukany plik
if ($fileName != $file->getFilename()) {
continue;
}
//próba usunięcia
try {
unlink($file->getPathname());
} catch (\Exception $e) {
//nic
}
}
return true;
} | php | public static function unlinkRecursive($fileName, $rootName)
{
//brak katalogu głównego
if (!file_exists($rootName)) {
return false;
}
//iteracja po katalogu głównym
foreach (new \DirectoryIterator($rootName) as $file) {
//katalog .
if ($file->isDot()) {
continue;
}
//katalog
if ($file->isDir()) {
//zejście rekurencyjne
self::unlinkRecursive($fileName, $file->getPathname());
continue;
}
//to nie jest szukany plik
if ($fileName != $file->getFilename()) {
continue;
}
//próba usunięcia
try {
unlink($file->getPathname());
} catch (\Exception $e) {
//nic
}
}
return true;
} | [
"public",
"static",
"function",
"unlinkRecursive",
"(",
"$",
"fileName",
",",
"$",
"rootName",
")",
"{",
"//brak katalogu głównego",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"rootName",
")",
")",
"{",
"return",
"false",
";",
"}",
"//iteracja po katalogu głównym",
"foreach",
"(",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"rootName",
")",
"as",
"$",
"file",
")",
"{",
"//katalog .",
"if",
"(",
"$",
"file",
"->",
"isDot",
"(",
")",
")",
"{",
"continue",
";",
"}",
"//katalog",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"//zejście rekurencyjne",
"self",
"::",
"unlinkRecursive",
"(",
"$",
"fileName",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"continue",
";",
"}",
"//to nie jest szukany plik",
"if",
"(",
"$",
"fileName",
"!=",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
"{",
"continue",
";",
"}",
"//próba usunięcia",
"try",
"{",
"unlink",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//nic",
"}",
"}",
"return",
"true",
";",
"}"
] | Kasuje pliki rekurencyjnie
@param string $fileName nazwa pliku
@param string $rootName katalog główny
@return boolean | [
"Kasuje",
"pliki",
"rekurencyjnie"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/FileSystem.php#L62-L92 |
28,218 | milejko/mmi | src/Mmi/FileSystem.php | FileSystem.rmdirRecursive | public static function rmdirRecursive($dirName)
{
//próba zbadania czy jest plikiem
try {
$isFile = is_file($dirName);
} catch (\Exception $e) {
return false;
}
//zwykły plik
if ($isFile) {
//próba usunięcia
try {
unlink($dirName);
} catch (\Exception $e) {
//prawdopodobnie już usunięty
return false;
}
return true;
}
//próba otwarcia katalogu
try {
$directoryIterator = new \DirectoryIterator($dirName);
} catch (\Exception $e) {
//prawdopodobnie już usunięty
return false;
}
//iteracja po katalogu
foreach ($directoryIterator as $dir) {
//katalog .
if ($dir->isDot()) {
continue;
}
//usunięcie rekurencyjne
self::rmdirRecursive($dir->getPathname());
}
//próba usunięcia pustego katalogu
try {
rmdir($dirName);
} catch (\Exception $e) {
//prawdopodobnie już usunięty
return false;
}
return true;
} | php | public static function rmdirRecursive($dirName)
{
//próba zbadania czy jest plikiem
try {
$isFile = is_file($dirName);
} catch (\Exception $e) {
return false;
}
//zwykły plik
if ($isFile) {
//próba usunięcia
try {
unlink($dirName);
} catch (\Exception $e) {
//prawdopodobnie już usunięty
return false;
}
return true;
}
//próba otwarcia katalogu
try {
$directoryIterator = new \DirectoryIterator($dirName);
} catch (\Exception $e) {
//prawdopodobnie już usunięty
return false;
}
//iteracja po katalogu
foreach ($directoryIterator as $dir) {
//katalog .
if ($dir->isDot()) {
continue;
}
//usunięcie rekurencyjne
self::rmdirRecursive($dir->getPathname());
}
//próba usunięcia pustego katalogu
try {
rmdir($dirName);
} catch (\Exception $e) {
//prawdopodobnie już usunięty
return false;
}
return true;
} | [
"public",
"static",
"function",
"rmdirRecursive",
"(",
"$",
"dirName",
")",
"{",
"//próba zbadania czy jest plikiem",
"try",
"{",
"$",
"isFile",
"=",
"is_file",
"(",
"$",
"dirName",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"//zwykły plik",
"if",
"(",
"$",
"isFile",
")",
"{",
"//próba usunięcia",
"try",
"{",
"unlink",
"(",
"$",
"dirName",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//prawdopodobnie już usunięty",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"//próba otwarcia katalogu",
"try",
"{",
"$",
"directoryIterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"dirName",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//prawdopodobnie już usunięty",
"return",
"false",
";",
"}",
"//iteracja po katalogu",
"foreach",
"(",
"$",
"directoryIterator",
"as",
"$",
"dir",
")",
"{",
"//katalog .",
"if",
"(",
"$",
"dir",
"->",
"isDot",
"(",
")",
")",
"{",
"continue",
";",
"}",
"//usunięcie rekurencyjne",
"self",
"::",
"rmdirRecursive",
"(",
"$",
"dir",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"//próba usunięcia pustego katalogu",
"try",
"{",
"rmdir",
"(",
"$",
"dirName",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//prawdopodobnie już usunięty",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Usuwa katalog rekurencyjnie
@param string $dirName nazwa katalogu
@return boolean | [
"Usuwa",
"katalog",
"rekurencyjnie"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/FileSystem.php#L99-L142 |
28,219 | peakphp/framework | src/Di/Container.php | Container.create | public function create(string $class, $args = [], $explicit = null)
{
// check first for definition even if auto wiring is on
$def = $this->getDefinition($class);
if ($def === null && !$this->auto_wiring) {
throw new ClassDefinitionNotFoundException($class);
} elseif ($def !== null) {
return $this->binding_resolver->resolve(
$this->getDefinition($class),
$this,
$args,
$explicit
);
}
// process class dependencies with reflection
$args = $this->resolver->resolve($class, $this, $args, $explicit);
// instantiate class with resolved dependencies and args if apply
return $this->instantiator->instantiate($class, $args);
} | php | public function create(string $class, $args = [], $explicit = null)
{
// check first for definition even if auto wiring is on
$def = $this->getDefinition($class);
if ($def === null && !$this->auto_wiring) {
throw new ClassDefinitionNotFoundException($class);
} elseif ($def !== null) {
return $this->binding_resolver->resolve(
$this->getDefinition($class),
$this,
$args,
$explicit
);
}
// process class dependencies with reflection
$args = $this->resolver->resolve($class, $this, $args, $explicit);
// instantiate class with resolved dependencies and args if apply
return $this->instantiator->instantiate($class, $args);
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"class",
",",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"explicit",
"=",
"null",
")",
"{",
"// check first for definition even if auto wiring is on",
"$",
"def",
"=",
"$",
"this",
"->",
"getDefinition",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"def",
"===",
"null",
"&&",
"!",
"$",
"this",
"->",
"auto_wiring",
")",
"{",
"throw",
"new",
"ClassDefinitionNotFoundException",
"(",
"$",
"class",
")",
";",
"}",
"elseif",
"(",
"$",
"def",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"binding_resolver",
"->",
"resolve",
"(",
"$",
"this",
"->",
"getDefinition",
"(",
"$",
"class",
")",
",",
"$",
"this",
",",
"$",
"args",
",",
"$",
"explicit",
")",
";",
"}",
"// process class dependencies with reflection",
"$",
"args",
"=",
"$",
"this",
"->",
"resolver",
"->",
"resolve",
"(",
"$",
"class",
",",
"$",
"this",
",",
"$",
"args",
",",
"$",
"explicit",
")",
";",
"// instantiate class with resolved dependencies and args if apply",
"return",
"$",
"this",
"->",
"instantiator",
"->",
"instantiate",
"(",
"$",
"class",
",",
"$",
"args",
")",
";",
"}"
] | Instantiate a class
The generated instance is not stored, but may use stored
instance(s) as dependency when needed
@param string $class
@param array $args
@param null $explicit
@return mixed|object
@throws ClassDefinitionNotFoundException
@throws Exception\AmbiguousResolutionException
@throws Exception\InterfaceNotFoundException
@throws \ReflectionException | [
"Instantiate",
"a",
"class"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L95-L115 |
28,220 | peakphp/framework | src/Di/Container.php | Container.resolve | public function resolve(string $definition, array $args = [])
{
$def = $this->getDefinition($definition);
if ($def === null) {
throw new ClassDefinitionNotFoundException($definition);
}
return $this->binding_resolver->resolve($def, $this, $args);
} | php | public function resolve(string $definition, array $args = [])
{
$def = $this->getDefinition($definition);
if ($def === null) {
throw new ClassDefinitionNotFoundException($definition);
}
return $this->binding_resolver->resolve($def, $this, $args);
} | [
"public",
"function",
"resolve",
"(",
"string",
"$",
"definition",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"def",
"=",
"$",
"this",
"->",
"getDefinition",
"(",
"$",
"definition",
")",
";",
"if",
"(",
"$",
"def",
"===",
"null",
")",
"{",
"throw",
"new",
"ClassDefinitionNotFoundException",
"(",
"$",
"definition",
")",
";",
"}",
"return",
"$",
"this",
"->",
"binding_resolver",
"->",
"resolve",
"(",
"$",
"def",
",",
"$",
"this",
",",
"$",
"args",
")",
";",
"}"
] | Resolve a stored definition
@param string $definition
@param array $args
@return mixed
@throws ClassDefinitionNotFoundException | [
"Resolve",
"a",
"stored",
"definition"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L164-L172 |
28,221 | peakphp/framework | src/Di/Container.php | Container.get | public function get($id)
{
if ($this->has($id)) {
return $this->instances[$id];
} elseif ($this->hasAlias($id) && $this->has($this->aliases[$id])) {
return $this->instances[$this->aliases[$id]];
}
return $this->create($id);
} | php | public function get($id)
{
if ($this->has($id)) {
return $this->instances[$id];
} elseif ($this->hasAlias($id) && $this->has($this->aliases[$id])) {
return $this->instances[$this->aliases[$id]];
}
return $this->create($id);
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"id",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"hasAlias",
"(",
"$",
"id",
")",
"&&",
"$",
"this",
"->",
"has",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"this",
"->",
"aliases",
"[",
"$",
"id",
"]",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"id",
")",
";",
"}"
] | Get an instance if exists, otherwise try to create it return null
@param string $id
@return mixed|object
@throws ClassDefinitionNotFoundException
@throws Exception\AmbiguousResolutionException
@throws Exception\InterfaceNotFoundException
@throws \ReflectionException | [
"Get",
"an",
"instance",
"if",
"exists",
"otherwise",
"try",
"to",
"create",
"it",
"return",
"null"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L195-L204 |
28,222 | peakphp/framework | src/Di/Container.php | Container.set | public function set(object $object, string $alias = null)
{
$class = get_class($object);
$this->instances[$class] = $object;
if (isset($alias)) {
$this->addAlias($alias, $class);
}
$interfaces = class_implements($object);
if (is_array($interfaces)) {
foreach ($interfaces as $i) {
$this->addInterface($i, $class);
}
}
return $this;
} | php | public function set(object $object, string $alias = null)
{
$class = get_class($object);
$this->instances[$class] = $object;
if (isset($alias)) {
$this->addAlias($alias, $class);
}
$interfaces = class_implements($object);
if (is_array($interfaces)) {
foreach ($interfaces as $i) {
$this->addInterface($i, $class);
}
}
return $this;
} | [
"public",
"function",
"set",
"(",
"object",
"$",
"object",
",",
"string",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"instances",
"[",
"$",
"class",
"]",
"=",
"$",
"object",
";",
"if",
"(",
"isset",
"(",
"$",
"alias",
")",
")",
"{",
"$",
"this",
"->",
"addAlias",
"(",
"$",
"alias",
",",
"$",
"class",
")",
";",
"}",
"$",
"interfaces",
"=",
"class_implements",
"(",
"$",
"object",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"interfaces",
")",
")",
"{",
"foreach",
"(",
"$",
"interfaces",
"as",
"$",
"i",
")",
"{",
"$",
"this",
"->",
"addInterface",
"(",
"$",
"i",
",",
"$",
"class",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set an object instance. Chainable
@param object $object
@param string|null $alias
@return Container | [
"Set",
"an",
"object",
"instance",
".",
"Chainable"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L213-L230 |
28,223 | peakphp/framework | src/Di/Container.php | Container.delete | public function delete($id)
{
if ($this->has($id)) {
//remove instance
unset($this->instances[$id]);
//remove interface reference if exists
foreach ($this->interfaces as $int => $classes) {
$key = array_search($id, $classes);
if ($key !== false) {
unset($classes[$key]);
$this->interfaces[$int] = $classes;
}
}
//remove instance from singleton binding
if ($this->hasDefinition($id)) {
$definition = $this->getDefinition($id);
if ($definition instanceof Singleton) {
$definition->deleteStoredInstance();
}
}
}
return $this;
} | php | public function delete($id)
{
if ($this->has($id)) {
//remove instance
unset($this->instances[$id]);
//remove interface reference if exists
foreach ($this->interfaces as $int => $classes) {
$key = array_search($id, $classes);
if ($key !== false) {
unset($classes[$key]);
$this->interfaces[$int] = $classes;
}
}
//remove instance from singleton binding
if ($this->hasDefinition($id)) {
$definition = $this->getDefinition($id);
if ($definition instanceof Singleton) {
$definition->deleteStoredInstance();
}
}
}
return $this;
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"//remove instance",
"unset",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"id",
"]",
")",
";",
"//remove interface reference if exists",
"foreach",
"(",
"$",
"this",
"->",
"interfaces",
"as",
"$",
"int",
"=>",
"$",
"classes",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"id",
",",
"$",
"classes",
")",
";",
"if",
"(",
"$",
"key",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"classes",
"[",
"$",
"key",
"]",
")",
";",
"$",
"this",
"->",
"interfaces",
"[",
"$",
"int",
"]",
"=",
"$",
"classes",
";",
"}",
"}",
"//remove instance from singleton binding",
"if",
"(",
"$",
"this",
"->",
"hasDefinition",
"(",
"$",
"id",
")",
")",
"{",
"$",
"definition",
"=",
"$",
"this",
"->",
"getDefinition",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"definition",
"instanceof",
"Singleton",
")",
"{",
"$",
"definition",
"->",
"deleteStoredInstance",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Delete an instance if exists.
@param string $id
@return Container | [
"Delete",
"an",
"instance",
"if",
"exists",
"."
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L238-L262 |
28,224 | peakphp/framework | src/Di/Container.php | Container.addAlias | public function addAlias(string $name, string $className)
{
$this->aliases[$name] = $className;
return $this;
} | php | public function addAlias(string $name, string $className)
{
$this->aliases[$name] = $className;
return $this;
} | [
"public",
"function",
"addAlias",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"className",
")",
"{",
"$",
"this",
"->",
"aliases",
"[",
"$",
"name",
"]",
"=",
"$",
"className",
";",
"return",
"$",
"this",
";",
"}"
] | Add a class alias
@param string $name
@param string $className
@return $this | [
"Add",
"a",
"class",
"alias"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L271-L275 |
28,225 | peakphp/framework | src/Di/Container.php | Container.addInterface | protected function addInterface(string $name, string $class)
{
if (!$this->hasInterface($name)) {
$this->interfaces[$name] = $class;
return;
}
$interfaces = $this->getInterface($name);
if (!is_array($interfaces)) {
$interfaces = [$interfaces];
}
if (!in_array($class, $interfaces)) {
$interfaces[] = $class;
$this->interfaces[$name] = $interfaces;
}
} | php | protected function addInterface(string $name, string $class)
{
if (!$this->hasInterface($name)) {
$this->interfaces[$name] = $class;
return;
}
$interfaces = $this->getInterface($name);
if (!is_array($interfaces)) {
$interfaces = [$interfaces];
}
if (!in_array($class, $interfaces)) {
$interfaces[] = $class;
$this->interfaces[$name] = $interfaces;
}
} | [
"protected",
"function",
"addInterface",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasInterface",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"interfaces",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"return",
";",
"}",
"$",
"interfaces",
"=",
"$",
"this",
"->",
"getInterface",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"interfaces",
")",
")",
"{",
"$",
"interfaces",
"=",
"[",
"$",
"interfaces",
"]",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"class",
",",
"$",
"interfaces",
")",
")",
"{",
"$",
"interfaces",
"[",
"]",
"=",
"$",
"class",
";",
"$",
"this",
"->",
"interfaces",
"[",
"$",
"name",
"]",
"=",
"$",
"interfaces",
";",
"}",
"}"
] | Catalogue also class interface when using add
@param string $name
@param string $class | [
"Catalogue",
"also",
"class",
"interface",
"when",
"using",
"add"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L314-L330 |
28,226 | peakphp/framework | src/Di/Container.php | Container.getInterface | public function getInterface(string $name)
{
if ($this->hasInterface($name)) {
return $this->interfaces[$name];
}
return null;
} | php | public function getInterface(string $name)
{
if ($this->hasInterface($name)) {
return $this->interfaces[$name];
}
return null;
} | [
"public",
"function",
"getInterface",
"(",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasInterface",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"interfaces",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get an interface
@param string $name
@return mixed|null | [
"Get",
"an",
"interface"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L349-L355 |
28,227 | peakphp/framework | src/Di/Container.php | Container.getDefinition | public function getDefinition(string $name)
{
if ($this->hasDefinition($name)) {
return $this->definitions[$name];
}
return null;
} | php | public function getDefinition(string $name)
{
if ($this->hasDefinition($name)) {
return $this->definitions[$name];
}
return null;
} | [
"public",
"function",
"getDefinition",
"(",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasDefinition",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"definitions",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get a definition
@param string $name
@return mixed | [
"Get",
"a",
"definition"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L409-L415 |
28,228 | peakphp/framework | src/Di/Container.php | Container.bind | public function bind(string $name, $definition)
{
$this->definitions[$name] = new Singleton($name, $definition);
return $this;
} | php | public function bind(string $name, $definition)
{
$this->definitions[$name] = new Singleton($name, $definition);
return $this;
} | [
"public",
"function",
"bind",
"(",
"string",
"$",
"name",
",",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"definitions",
"[",
"$",
"name",
"]",
"=",
"new",
"Singleton",
"(",
"$",
"name",
",",
"$",
"definition",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a singleton definition
@param string $name
@param mixed $definition
@return $this | [
"Add",
"a",
"singleton",
"definition"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L432-L436 |
28,229 | peakphp/framework | src/Di/Container.php | Container.bindPrototype | public function bindPrototype(string $name, $definition)
{
$this->definitions[$name] = new Prototype($name, $definition);
return $this;
} | php | public function bindPrototype(string $name, $definition)
{
$this->definitions[$name] = new Prototype($name, $definition);
return $this;
} | [
"public",
"function",
"bindPrototype",
"(",
"string",
"$",
"name",
",",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"definitions",
"[",
"$",
"name",
"]",
"=",
"new",
"Prototype",
"(",
"$",
"name",
",",
"$",
"definition",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a prototype definition
@param string $name
@param mixed $definition
@return $this | [
"Add",
"a",
"prototype",
"definition"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L445-L449 |
28,230 | peakphp/framework | src/Di/Container.php | Container.bindFactory | public function bindFactory(string $name, $definition)
{
$this->definitions[$name] = new Factory($name, $definition);
return $this;
} | php | public function bindFactory(string $name, $definition)
{
$this->definitions[$name] = new Factory($name, $definition);
return $this;
} | [
"public",
"function",
"bindFactory",
"(",
"string",
"$",
"name",
",",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"definitions",
"[",
"$",
"name",
"]",
"=",
"new",
"Factory",
"(",
"$",
"name",
",",
"$",
"definition",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a factory definition
@param string $name
@param mixed $definition
@return $this | [
"Add",
"a",
"factory",
"definition"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/Container.php#L458-L462 |
28,231 | ScriptFUSION/Mapper | src/Mapper.php | Mapper.map | public function map(array $record, $expression, $context = null, $key = null)
{
// Null or scalar values.
if (null === $expression || is_scalar($expression)) {
return $expression;
}
// Strategy.
if ($expression instanceof Strategy) {
return $this->mapStrategy($record, $expression, $context, $key);
}
// Mapping.
if ($expression instanceof Mapping) {
return $this->mapMapping($record, $expression, $context, $key);
}
// Mapping fragment.
if (is_array($expression)) {
return $this->mapFragment($record, $expression, $context, $key);
}
throw new InvalidExpressionException('Invalid strategy or mapping: "' . get_class($expression) . '".');
} | php | public function map(array $record, $expression, $context = null, $key = null)
{
// Null or scalar values.
if (null === $expression || is_scalar($expression)) {
return $expression;
}
// Strategy.
if ($expression instanceof Strategy) {
return $this->mapStrategy($record, $expression, $context, $key);
}
// Mapping.
if ($expression instanceof Mapping) {
return $this->mapMapping($record, $expression, $context, $key);
}
// Mapping fragment.
if (is_array($expression)) {
return $this->mapFragment($record, $expression, $context, $key);
}
throw new InvalidExpressionException('Invalid strategy or mapping: "' . get_class($expression) . '".');
} | [
"public",
"function",
"map",
"(",
"array",
"$",
"record",
",",
"$",
"expression",
",",
"$",
"context",
"=",
"null",
",",
"$",
"key",
"=",
"null",
")",
"{",
"// Null or scalar values.",
"if",
"(",
"null",
"===",
"$",
"expression",
"||",
"is_scalar",
"(",
"$",
"expression",
")",
")",
"{",
"return",
"$",
"expression",
";",
"}",
"// Strategy.",
"if",
"(",
"$",
"expression",
"instanceof",
"Strategy",
")",
"{",
"return",
"$",
"this",
"->",
"mapStrategy",
"(",
"$",
"record",
",",
"$",
"expression",
",",
"$",
"context",
",",
"$",
"key",
")",
";",
"}",
"// Mapping.",
"if",
"(",
"$",
"expression",
"instanceof",
"Mapping",
")",
"{",
"return",
"$",
"this",
"->",
"mapMapping",
"(",
"$",
"record",
",",
"$",
"expression",
",",
"$",
"context",
",",
"$",
"key",
")",
";",
"}",
"// Mapping fragment.",
"if",
"(",
"is_array",
"(",
"$",
"expression",
")",
")",
"{",
"return",
"$",
"this",
"->",
"mapFragment",
"(",
"$",
"record",
",",
"$",
"expression",
",",
"$",
"context",
",",
"$",
"key",
")",
";",
"}",
"throw",
"new",
"InvalidExpressionException",
"(",
"'Invalid strategy or mapping: \"'",
".",
"get_class",
"(",
"$",
"expression",
")",
".",
"'\".'",
")",
";",
"}"
] | Maps the specified record according to the specified expression type. Optionally, used-defined contextual data
may be passed to the expression. The record key is for internal use only and represents the current array key.
May be called recursively if the expression embeds more expressions.
@param array $record Record.
@param Strategy|Mapping|array|mixed $expression Expression.
@param mixed $context Optional. Contextual data.
@param string|int|null $key Internal. Record key.
@return mixed
@throws InvalidExpressionException An invalid strategy or mapping object was specified. | [
"Maps",
"the",
"specified",
"record",
"according",
"to",
"the",
"specified",
"expression",
"type",
".",
"Optionally",
"used",
"-",
"defined",
"contextual",
"data",
"may",
"be",
"passed",
"to",
"the",
"expression",
".",
"The",
"record",
"key",
"is",
"for",
"internal",
"use",
"only",
"and",
"represents",
"the",
"current",
"array",
"key",
"."
] | 1b8326e238876db9e5f86533ef924f003316a433 | https://github.com/ScriptFUSION/Mapper/blob/1b8326e238876db9e5f86533ef924f003316a433/src/Mapper.php#L26-L49 |
28,232 | quazardous/ImageStack | src/ImageStack/ImageBackend/CacheImageBackend.php | CacheImageBackend.getCacheId | protected function getCacheId(ImagePathInterface $path) {
if ($cid = $this->getOption('cache_prefix')) {
$cid .= DIRECTORY_SEPARATOR;
}
$cid .= $path->getPath();
if ($sanitizer = $this->getOption('cache_id_sanitizer')) {
$cid = call_user_func($sanitizer, $cid);
}
return $cid;
} | php | protected function getCacheId(ImagePathInterface $path) {
if ($cid = $this->getOption('cache_prefix')) {
$cid .= DIRECTORY_SEPARATOR;
}
$cid .= $path->getPath();
if ($sanitizer = $this->getOption('cache_id_sanitizer')) {
$cid = call_user_func($sanitizer, $cid);
}
return $cid;
} | [
"protected",
"function",
"getCacheId",
"(",
"ImagePathInterface",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"cid",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'cache_prefix'",
")",
")",
"{",
"$",
"cid",
".=",
"DIRECTORY_SEPARATOR",
";",
"}",
"$",
"cid",
".=",
"$",
"path",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"sanitizer",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'cache_id_sanitizer'",
")",
")",
"{",
"$",
"cid",
"=",
"call_user_func",
"(",
"$",
"sanitizer",
",",
"$",
"cid",
")",
";",
"}",
"return",
"$",
"cid",
";",
"}"
] | Get the cache ID from the path and can do sanitize stuff.
@param ImagePathInterface $path
@return string | [
"Get",
"the",
"cache",
"ID",
"from",
"the",
"path",
"and",
"can",
"do",
"sanitize",
"stuff",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageBackend/CacheImageBackend.php#L50-L59 |
28,233 | quazardous/ImageStack | src/ImageStack/OptionnableTrait.php | OptionnableTrait.setOptions | public function setOptions(array $options, $merge = true)
{
if ($merge) {
$this->options = array_replace($this->options, $options);
} else {
$this->options = $options;
}
} | php | public function setOptions(array $options, $merge = true)
{
if ($merge) {
$this->options = array_replace($this->options, $options);
} else {
$this->options = $options;
}
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
",",
"$",
"merge",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"merge",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"array_replace",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"options",
";",
"}",
"}"
] | Set all options.
@param array $options | [
"Set",
"all",
"options",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/OptionnableTrait.php#L15-L22 |
28,234 | quazardous/ImageStack | src/ImageStack/OptionnableTrait.php | OptionnableTrait.getOption | public function getOption($name, $default = null)
{
if (!isset($this->options[$name])) {
if (is_callable($default)) {
$default = call_user_func($default);
} if ($default instanceof \Exception) {
throw $default;
}
return $default;
}
return $this->options[$name];
} | php | public function getOption($name, $default = null)
{
if (!isset($this->options[$name])) {
if (is_callable($default)) {
$default = call_user_func($default);
} if ($default instanceof \Exception) {
throw $default;
}
return $default;
}
return $this->options[$name];
} | [
"public",
"function",
"getOption",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"default",
")",
")",
"{",
"$",
"default",
"=",
"call_user_func",
"(",
"$",
"default",
")",
";",
"}",
"if",
"(",
"$",
"default",
"instanceof",
"\\",
"Exception",
")",
"{",
"throw",
"$",
"default",
";",
"}",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
";",
"}"
] | Get option value or default or throws exception.
@param string $name
@param mixed|callable|\Exception $default
@throws \Exception
@return mixed | [
"Get",
"option",
"value",
"or",
"default",
"or",
"throws",
"exception",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/OptionnableTrait.php#L50-L61 |
28,235 | CVO-Technologies/cakephp-gearman | src/JobAwareTrait.php | JobAwareTrait.gearmanClient | public function gearmanClient()
{
$client = new GearmanClient();
$servers = static::_getGearmanServers();
$client->addServers(implode(',', $servers));
return $client;
} | php | public function gearmanClient()
{
$client = new GearmanClient();
$servers = static::_getGearmanServers();
$client->addServers(implode(',', $servers));
return $client;
} | [
"public",
"function",
"gearmanClient",
"(",
")",
"{",
"$",
"client",
"=",
"new",
"GearmanClient",
"(",
")",
";",
"$",
"servers",
"=",
"static",
"::",
"_getGearmanServers",
"(",
")",
";",
"$",
"client",
"->",
"addServers",
"(",
"implode",
"(",
"','",
",",
"$",
"servers",
")",
")",
";",
"return",
"$",
"client",
";",
"}"
] | Setup a GearmanClient object configured
with the servers from the configuration.
@return GearmanClient | [
"Setup",
"a",
"GearmanClient",
"object",
"configured",
"with",
"the",
"servers",
"from",
"the",
"configuration",
"."
] | 538f060a617165482159c4f5f42d4b0562a14194 | https://github.com/CVO-Technologies/cakephp-gearman/blob/538f060a617165482159c4f5f42d4b0562a14194/src/JobAwareTrait.php#L17-L26 |
28,236 | CVO-Technologies/cakephp-gearman | src/JobAwareTrait.php | JobAwareTrait.gearmanWorker | public function gearmanWorker()
{
$client = new GearmanWorker();
$servers = static::_getGearmanServers();
$client->addServers(implode(',', $servers));
return $client;
} | php | public function gearmanWorker()
{
$client = new GearmanWorker();
$servers = static::_getGearmanServers();
$client->addServers(implode(',', $servers));
return $client;
} | [
"public",
"function",
"gearmanWorker",
"(",
")",
"{",
"$",
"client",
"=",
"new",
"GearmanWorker",
"(",
")",
";",
"$",
"servers",
"=",
"static",
"::",
"_getGearmanServers",
"(",
")",
";",
"$",
"client",
"->",
"addServers",
"(",
"implode",
"(",
"','",
",",
"$",
"servers",
")",
")",
";",
"return",
"$",
"client",
";",
"}"
] | Setup a GearmanWorker object configured
with the servers from the configuration.
@return GearmanWorker | [
"Setup",
"a",
"GearmanWorker",
"object",
"configured",
"with",
"the",
"servers",
"from",
"the",
"configuration",
"."
] | 538f060a617165482159c4f5f42d4b0562a14194 | https://github.com/CVO-Technologies/cakephp-gearman/blob/538f060a617165482159c4f5f42d4b0562a14194/src/JobAwareTrait.php#L34-L43 |
28,237 | CVO-Technologies/cakephp-gearman | src/JobAwareTrait.php | JobAwareTrait.execute | public function execute($name, $workload, $background = true, $priority = Gearman::PRIORITY_NORMAL)
{
$func = 'do';
switch ($priority) {
case Gearman::PRIORITY_LOW:
$func .= 'Low';
break;
case Gearman::PRIORITY_HIGH:
$func .= 'High';
break;
case Gearman::PRIORITY_NORMAL:
if (!$background) {
$func .= 'Normal';
}
break;
}
$func .= ($background) ? 'Background' : '';
if (is_array($workload) || is_object($workload)) {
$workload = serialize($workload);
}
$response = $this->gearmanClient()->{$func}($name, $workload);
DebugJob::add($name, $workload, $background, $priority);
if ($background) {
return $response;
}
$serializedResponse = unserialize($response);
if ($serializedResponse !== false) {
$response = $serializedResponse;
}
return $response;
} | php | public function execute($name, $workload, $background = true, $priority = Gearman::PRIORITY_NORMAL)
{
$func = 'do';
switch ($priority) {
case Gearman::PRIORITY_LOW:
$func .= 'Low';
break;
case Gearman::PRIORITY_HIGH:
$func .= 'High';
break;
case Gearman::PRIORITY_NORMAL:
if (!$background) {
$func .= 'Normal';
}
break;
}
$func .= ($background) ? 'Background' : '';
if (is_array($workload) || is_object($workload)) {
$workload = serialize($workload);
}
$response = $this->gearmanClient()->{$func}($name, $workload);
DebugJob::add($name, $workload, $background, $priority);
if ($background) {
return $response;
}
$serializedResponse = unserialize($response);
if ($serializedResponse !== false) {
$response = $serializedResponse;
}
return $response;
} | [
"public",
"function",
"execute",
"(",
"$",
"name",
",",
"$",
"workload",
",",
"$",
"background",
"=",
"true",
",",
"$",
"priority",
"=",
"Gearman",
"::",
"PRIORITY_NORMAL",
")",
"{",
"$",
"func",
"=",
"'do'",
";",
"switch",
"(",
"$",
"priority",
")",
"{",
"case",
"Gearman",
"::",
"PRIORITY_LOW",
":",
"$",
"func",
".=",
"'Low'",
";",
"break",
";",
"case",
"Gearman",
"::",
"PRIORITY_HIGH",
":",
"$",
"func",
".=",
"'High'",
";",
"break",
";",
"case",
"Gearman",
"::",
"PRIORITY_NORMAL",
":",
"if",
"(",
"!",
"$",
"background",
")",
"{",
"$",
"func",
".=",
"'Normal'",
";",
"}",
"break",
";",
"}",
"$",
"func",
".=",
"(",
"$",
"background",
")",
"?",
"'Background'",
":",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"workload",
")",
"||",
"is_object",
"(",
"$",
"workload",
")",
")",
"{",
"$",
"workload",
"=",
"serialize",
"(",
"$",
"workload",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"gearmanClient",
"(",
")",
"->",
"{",
"$",
"func",
"}",
"(",
"$",
"name",
",",
"$",
"workload",
")",
";",
"DebugJob",
"::",
"add",
"(",
"$",
"name",
",",
"$",
"workload",
",",
"$",
"background",
",",
"$",
"priority",
")",
";",
"if",
"(",
"$",
"background",
")",
"{",
"return",
"$",
"response",
";",
"}",
"$",
"serializedResponse",
"=",
"unserialize",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"serializedResponse",
"!==",
"false",
")",
"{",
"$",
"response",
"=",
"$",
"serializedResponse",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Execute a job by sending it to the
Gearman server using the GearmanClient.
Example for a background job with normal priority:
$this->execute('sleep', ['seconds' => 60]);
Example for a background job with HIGH priority:
$this->execute('sleep', ['seconds' => 60], true, Gearman::PRIORITY_HIGH);
Example for a normal job with HIGH priority:
$this->execute('sleep', ['seconds' => 60], false, Gearman::PRIORITY_HIGH);
@param string $name Name of the job to execute
@param mixed $workload Any type of workload is supported (as long as it's serializable)
@param bool $background If it's a background job
@param int $priority A priority level from Gearman::PRIORTIY_*
@return mixed The response from the job or the job id in case of a background job | [
"Execute",
"a",
"job",
"by",
"sending",
"it",
"to",
"the",
"Gearman",
"server",
"using",
"the",
"GearmanClient",
"."
] | 538f060a617165482159c4f5f42d4b0562a14194 | https://github.com/CVO-Technologies/cakephp-gearman/blob/538f060a617165482159c4f5f42d4b0562a14194/src/JobAwareTrait.php#L64-L101 |
28,238 | peakphp/framework | src/Di/ClassInspector.php | ClassInspector.inspect | public function inspect($class, $method = '__construct')
{
if (is_string($class) && !class_exists($class)) {
throw new ClassNotFoundException($class);
}
$dependencies = [];
$r = new ReflectionClass($class);
if (!$r->hasMethod($method)) {
if ($method === '__construct') {
return $dependencies;
}
throw new MethodNotFoundException($r->getName(), $method);
}
$rp = $r->getMethod($method)->getParameters();
foreach ($rp as $p) {
$prop = $p->name;
$dependencies[$prop] = [];
$dependencies[$prop]['optional'] = $p->isOptional();
try {
$class = $p->getClass();
if (isset($class)) {
$dependencies[$prop]['class'] = $class->name;
}
} catch (\Exception $e) {
$dependencies[$prop]['error'] = $e->getMessage();
}
}
return $dependencies;
} | php | public function inspect($class, $method = '__construct')
{
if (is_string($class) && !class_exists($class)) {
throw new ClassNotFoundException($class);
}
$dependencies = [];
$r = new ReflectionClass($class);
if (!$r->hasMethod($method)) {
if ($method === '__construct') {
return $dependencies;
}
throw new MethodNotFoundException($r->getName(), $method);
}
$rp = $r->getMethod($method)->getParameters();
foreach ($rp as $p) {
$prop = $p->name;
$dependencies[$prop] = [];
$dependencies[$prop]['optional'] = $p->isOptional();
try {
$class = $p->getClass();
if (isset($class)) {
$dependencies[$prop]['class'] = $class->name;
}
} catch (\Exception $e) {
$dependencies[$prop]['error'] = $e->getMessage();
}
}
return $dependencies;
} | [
"public",
"function",
"inspect",
"(",
"$",
"class",
",",
"$",
"method",
"=",
"'__construct'",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"class",
")",
"&&",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"$",
"class",
")",
";",
"}",
"$",
"dependencies",
"=",
"[",
"]",
";",
"$",
"r",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"$",
"r",
"->",
"hasMethod",
"(",
"$",
"method",
")",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"'__construct'",
")",
"{",
"return",
"$",
"dependencies",
";",
"}",
"throw",
"new",
"MethodNotFoundException",
"(",
"$",
"r",
"->",
"getName",
"(",
")",
",",
"$",
"method",
")",
";",
"}",
"$",
"rp",
"=",
"$",
"r",
"->",
"getMethod",
"(",
"$",
"method",
")",
"->",
"getParameters",
"(",
")",
";",
"foreach",
"(",
"$",
"rp",
"as",
"$",
"p",
")",
"{",
"$",
"prop",
"=",
"$",
"p",
"->",
"name",
";",
"$",
"dependencies",
"[",
"$",
"prop",
"]",
"=",
"[",
"]",
";",
"$",
"dependencies",
"[",
"$",
"prop",
"]",
"[",
"'optional'",
"]",
"=",
"$",
"p",
"->",
"isOptional",
"(",
")",
";",
"try",
"{",
"$",
"class",
"=",
"$",
"p",
"->",
"getClass",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"class",
")",
")",
"{",
"$",
"dependencies",
"[",
"$",
"prop",
"]",
"[",
"'class'",
"]",
"=",
"$",
"class",
"->",
"name",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"dependencies",
"[",
"$",
"prop",
"]",
"[",
"'error'",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"return",
"$",
"dependencies",
";",
"}"
] | Get class dependencies method.
By default, method is the constructor itself
@param mixed $class
@param string $method
@return array
@throws Exception | [
"Get",
"class",
"dependencies",
"method",
".",
"By",
"default",
"method",
"is",
"the",
"constructor",
"itself"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Di/ClassInspector.php#L26-L61 |
28,239 | milejko/mmi | src/Mmi/Http/Response.php | Response.setCode | public function setCode($code, $replace = false)
{
//kod nie istnieje
if (!($message = ResponseTypes::getMessageByCode($code))) {
//wyjątek o nieistniejącym kodzie HTTP
throw new HttpException('HTTP code not found');
}
//zapis kodu
$this->_code = $code;
//wysłanie nagłówka z kodem
return $this->setHeader('HTTP/1.1 ' . $code . ' ' . $message, null, $replace);
} | php | public function setCode($code, $replace = false)
{
//kod nie istnieje
if (!($message = ResponseTypes::getMessageByCode($code))) {
//wyjątek o nieistniejącym kodzie HTTP
throw new HttpException('HTTP code not found');
}
//zapis kodu
$this->_code = $code;
//wysłanie nagłówka z kodem
return $this->setHeader('HTTP/1.1 ' . $code . ' ' . $message, null, $replace);
} | [
"public",
"function",
"setCode",
"(",
"$",
"code",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"//kod nie istnieje",
"if",
"(",
"!",
"(",
"$",
"message",
"=",
"ResponseTypes",
"::",
"getMessageByCode",
"(",
"$",
"code",
")",
")",
")",
"{",
"//wyjątek o nieistniejącym kodzie HTTP",
"throw",
"new",
"HttpException",
"(",
"'HTTP code not found'",
")",
";",
"}",
"//zapis kodu",
"$",
"this",
"->",
"_code",
"=",
"$",
"code",
";",
"//wysłanie nagłówka z kodem",
"return",
"$",
"this",
"->",
"setHeader",
"(",
"'HTTP/1.1 '",
".",
"$",
"code",
".",
"' '",
".",
"$",
"message",
",",
"null",
",",
"$",
"replace",
")",
";",
"}"
] | Ustawia kod odpowiedzi
@param int $code kod
@param boolean $replace zastąpienie
@return \Mmi\Http\Response | [
"Ustawia",
"kod",
"odpowiedzi"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/Response.php#L96-L107 |
28,240 | milejko/mmi | src/Mmi/Http/Response.php | Response.setType | public function setType($type, $replace = false)
{
//usuwanie typu odpowiedzi
$this->_type = ResponseTypes::searchType($type);
//wysłanie nagłówka
return $this->setHeader('Content-type', $this->_type, $replace);
} | php | public function setType($type, $replace = false)
{
//usuwanie typu odpowiedzi
$this->_type = ResponseTypes::searchType($type);
//wysłanie nagłówka
return $this->setHeader('Content-type', $this->_type, $replace);
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"//usuwanie typu odpowiedzi",
"$",
"this",
"->",
"_type",
"=",
"ResponseTypes",
"::",
"searchType",
"(",
"$",
"type",
")",
";",
"//wysłanie nagłówka",
"return",
"$",
"this",
"->",
"setHeader",
"(",
"'Content-type'",
",",
"$",
"this",
"->",
"_type",
",",
"$",
"replace",
")",
";",
"}"
] | Ustawia typ kontentu odpowiedzi (content-type
@param string $type nazwa typu np. jpg, gif, html, lub text/html
@param boolean $replace zastąpienie
@return \Mmi\Http\Response | [
"Ustawia",
"typ",
"kontentu",
"odpowiedzi",
"(",
"content",
"-",
"type"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/Response.php#L170-L176 |
28,241 | peakphp/framework | src/Bedrock/AbstractApplication.php | AbstractApplication.bootstrap | public function bootstrap(array $processes)
{
$bootstrap = new Bootstrap($processes, $this->getContainer());
$bootstrap->boot();
return $this;
} | php | public function bootstrap(array $processes)
{
$bootstrap = new Bootstrap($processes, $this->getContainer());
$bootstrap->boot();
return $this;
} | [
"public",
"function",
"bootstrap",
"(",
"array",
"$",
"processes",
")",
"{",
"$",
"bootstrap",
"=",
"new",
"Bootstrap",
"(",
"$",
"processes",
",",
"$",
"this",
"->",
"getContainer",
"(",
")",
")",
";",
"$",
"bootstrap",
"->",
"boot",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Bootstrap bootable processes
@param array $processes
@return $this
@throws \Peak\Bedrock\Bootstrap\Exception\InvalidBootableProcessException
@throws \ReflectionException | [
"Bootstrap",
"bootable",
"processes"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/AbstractApplication.php#L83-L88 |
28,242 | milejko/mmi | src/Mmi/Paginator/Paginator.php | Paginator.getPage | public function getPage()
{
if ($this->getOption('page')) {
return $this->getOption('page');
}
$requestPage = $this->getRequest()->__get($this->getOption('pageVariable'));
$page = ($requestPage > 0) ? $requestPage : 1;
$this->setPage($page);
return $page;
} | php | public function getPage()
{
if ($this->getOption('page')) {
return $this->getOption('page');
}
$requestPage = $this->getRequest()->__get($this->getOption('pageVariable'));
$page = ($requestPage > 0) ? $requestPage : 1;
$this->setPage($page);
return $page;
} | [
"public",
"function",
"getPage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'page'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getOption",
"(",
"'page'",
")",
";",
"}",
"$",
"requestPage",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"__get",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'pageVariable'",
")",
")",
";",
"$",
"page",
"=",
"(",
"$",
"requestPage",
">",
"0",
")",
"?",
"$",
"requestPage",
":",
"1",
";",
"$",
"this",
"->",
"setPage",
"(",
"$",
"page",
")",
";",
"return",
"$",
"page",
";",
"}"
] | Pobiera numer aktualnej strony
@return integer | [
"Pobiera",
"numer",
"aktualnej",
"strony"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Paginator/Paginator.php#L62-L71 |
28,243 | milejko/mmi | src/Mmi/Orm/QueryData.php | QueryData._prepareFields | protected final function _prepareFields()
{
//jeśli pusty schemat połączeń
if (empty($this->_query->getQueryCompile()->joinSchema)) {
return '*';
}
$fields = '';
//pobranie struktury tabeli
$mainStructure = DbConnector::getTableStructure($this->_query->getTableName());
//przygotowanie tabeli
$table = DbConnector::getAdapter()->prepareTable($this->_query->getTableName());
//iteracja po polach tabeli głównej
foreach ($mainStructure as $fieldName => $info) {
//dodawanie pola
$fields .= $table . '.' . DbConnector::getAdapter()->prepareField($fieldName) . ', ';
}
//pola z tabel dołączonych
foreach ($this->_query->getQueryCompile()->joinSchema as $schema) {
//pobranie struktury tabeli dołączonej
$structure = DbConnector::getTableStructure($schema[0]);
//alias połączenia
$joinAlias = isset($schema[5]) ? $schema[5] : $schema[0];
//pola tabeli dołączonej
foreach ($structure as $fieldName => $info) {
$fields .= DbConnector::getAdapter()->prepareTable($joinAlias) . '.' . DbConnector::getAdapter()->prepareField($fieldName) . ' AS ' . DbConnector::getAdapter()->prepareField($joinAlias . '__' . $schema[0] . '__' . $fieldName) . ', ';
}
}
return rtrim($fields, ', ');
} | php | protected final function _prepareFields()
{
//jeśli pusty schemat połączeń
if (empty($this->_query->getQueryCompile()->joinSchema)) {
return '*';
}
$fields = '';
//pobranie struktury tabeli
$mainStructure = DbConnector::getTableStructure($this->_query->getTableName());
//przygotowanie tabeli
$table = DbConnector::getAdapter()->prepareTable($this->_query->getTableName());
//iteracja po polach tabeli głównej
foreach ($mainStructure as $fieldName => $info) {
//dodawanie pola
$fields .= $table . '.' . DbConnector::getAdapter()->prepareField($fieldName) . ', ';
}
//pola z tabel dołączonych
foreach ($this->_query->getQueryCompile()->joinSchema as $schema) {
//pobranie struktury tabeli dołączonej
$structure = DbConnector::getTableStructure($schema[0]);
//alias połączenia
$joinAlias = isset($schema[5]) ? $schema[5] : $schema[0];
//pola tabeli dołączonej
foreach ($structure as $fieldName => $info) {
$fields .= DbConnector::getAdapter()->prepareTable($joinAlias) . '.' . DbConnector::getAdapter()->prepareField($fieldName) . ' AS ' . DbConnector::getAdapter()->prepareField($joinAlias . '__' . $schema[0] . '__' . $fieldName) . ', ';
}
}
return rtrim($fields, ', ');
} | [
"protected",
"final",
"function",
"_prepareFields",
"(",
")",
"{",
"//jeśli pusty schemat połączeń",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_query",
"->",
"getQueryCompile",
"(",
")",
"->",
"joinSchema",
")",
")",
"{",
"return",
"'*'",
";",
"}",
"$",
"fields",
"=",
"''",
";",
"//pobranie struktury tabeli",
"$",
"mainStructure",
"=",
"DbConnector",
"::",
"getTableStructure",
"(",
"$",
"this",
"->",
"_query",
"->",
"getTableName",
"(",
")",
")",
";",
"//przygotowanie tabeli",
"$",
"table",
"=",
"DbConnector",
"::",
"getAdapter",
"(",
")",
"->",
"prepareTable",
"(",
"$",
"this",
"->",
"_query",
"->",
"getTableName",
"(",
")",
")",
";",
"//iteracja po polach tabeli głównej",
"foreach",
"(",
"$",
"mainStructure",
"as",
"$",
"fieldName",
"=>",
"$",
"info",
")",
"{",
"//dodawanie pola",
"$",
"fields",
".=",
"$",
"table",
".",
"'.'",
".",
"DbConnector",
"::",
"getAdapter",
"(",
")",
"->",
"prepareField",
"(",
"$",
"fieldName",
")",
".",
"', '",
";",
"}",
"//pola z tabel dołączonych",
"foreach",
"(",
"$",
"this",
"->",
"_query",
"->",
"getQueryCompile",
"(",
")",
"->",
"joinSchema",
"as",
"$",
"schema",
")",
"{",
"//pobranie struktury tabeli dołączonej",
"$",
"structure",
"=",
"DbConnector",
"::",
"getTableStructure",
"(",
"$",
"schema",
"[",
"0",
"]",
")",
";",
"//alias połączenia",
"$",
"joinAlias",
"=",
"isset",
"(",
"$",
"schema",
"[",
"5",
"]",
")",
"?",
"$",
"schema",
"[",
"5",
"]",
":",
"$",
"schema",
"[",
"0",
"]",
";",
"//pola tabeli dołączonej",
"foreach",
"(",
"$",
"structure",
"as",
"$",
"fieldName",
"=>",
"$",
"info",
")",
"{",
"$",
"fields",
".=",
"DbConnector",
"::",
"getAdapter",
"(",
")",
"->",
"prepareTable",
"(",
"$",
"joinAlias",
")",
".",
"'.'",
".",
"DbConnector",
"::",
"getAdapter",
"(",
")",
"->",
"prepareField",
"(",
"$",
"fieldName",
")",
".",
"' AS '",
".",
"DbConnector",
"::",
"getAdapter",
"(",
")",
"->",
"prepareField",
"(",
"$",
"joinAlias",
".",
"'__'",
".",
"$",
"schema",
"[",
"0",
"]",
".",
"'__'",
".",
"$",
"fieldName",
")",
".",
"', '",
";",
"}",
"}",
"return",
"rtrim",
"(",
"$",
"fields",
",",
"', '",
")",
";",
"}"
] | Przygotowuje pola do selecta
@return string | [
"Przygotowuje",
"pola",
"do",
"selecta"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/QueryData.php#L172-L200 |
28,244 | honeybee/honeybee | src/Model/Aggregate/AggregateRootType.php | AggregateRootType.getDefaultAttributes | public function getDefaultAttributes()
{
$default_attributes = [
new TextAttribute('identifier', $this),
new IntegerAttribute('revision', $this, [ 'default_value' => 0 ]),
new UuidAttribute('uuid', $this, [ 'default_value' => 'auto_gen' ]),
new TextAttribute('language', $this, [ 'default_value' => 'de_DE' ]),
new IntegerAttribute('version', $this, [ 'default_value' => 1 ]),
new TextAttribute('workflow_state', $this),
new KeyValueListAttribute('workflow_parameters', $this)
];
if ($this->isHierarchical()) {
$default_attributes[] = new TextAttribute('parent_node_id', $this);
}
$default_attributes_map = new AttributeMap($default_attributes);
return parent::getDefaultAttributes()->append($default_attributes_map);
} | php | public function getDefaultAttributes()
{
$default_attributes = [
new TextAttribute('identifier', $this),
new IntegerAttribute('revision', $this, [ 'default_value' => 0 ]),
new UuidAttribute('uuid', $this, [ 'default_value' => 'auto_gen' ]),
new TextAttribute('language', $this, [ 'default_value' => 'de_DE' ]),
new IntegerAttribute('version', $this, [ 'default_value' => 1 ]),
new TextAttribute('workflow_state', $this),
new KeyValueListAttribute('workflow_parameters', $this)
];
if ($this->isHierarchical()) {
$default_attributes[] = new TextAttribute('parent_node_id', $this);
}
$default_attributes_map = new AttributeMap($default_attributes);
return parent::getDefaultAttributes()->append($default_attributes_map);
} | [
"public",
"function",
"getDefaultAttributes",
"(",
")",
"{",
"$",
"default_attributes",
"=",
"[",
"new",
"TextAttribute",
"(",
"'identifier'",
",",
"$",
"this",
")",
",",
"new",
"IntegerAttribute",
"(",
"'revision'",
",",
"$",
"this",
",",
"[",
"'default_value'",
"=>",
"0",
"]",
")",
",",
"new",
"UuidAttribute",
"(",
"'uuid'",
",",
"$",
"this",
",",
"[",
"'default_value'",
"=>",
"'auto_gen'",
"]",
")",
",",
"new",
"TextAttribute",
"(",
"'language'",
",",
"$",
"this",
",",
"[",
"'default_value'",
"=>",
"'de_DE'",
"]",
")",
",",
"new",
"IntegerAttribute",
"(",
"'version'",
",",
"$",
"this",
",",
"[",
"'default_value'",
"=>",
"1",
"]",
")",
",",
"new",
"TextAttribute",
"(",
"'workflow_state'",
",",
"$",
"this",
")",
",",
"new",
"KeyValueListAttribute",
"(",
"'workflow_parameters'",
",",
"$",
"this",
")",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isHierarchical",
"(",
")",
")",
"{",
"$",
"default_attributes",
"[",
"]",
"=",
"new",
"TextAttribute",
"(",
"'parent_node_id'",
",",
"$",
"this",
")",
";",
"}",
"$",
"default_attributes_map",
"=",
"new",
"AttributeMap",
"(",
"$",
"default_attributes",
")",
";",
"return",
"parent",
"::",
"getDefaultAttributes",
"(",
")",
"->",
"append",
"(",
"$",
"default_attributes_map",
")",
";",
"}"
] | Returns the default attributes that are initially added to a aggregate_root_type upon creation.
@return array A list of AttributeInterface implementations. | [
"Returns",
"the",
"default",
"attributes",
"that",
"are",
"initially",
"added",
"to",
"a",
"aggregate_root_type",
"upon",
"creation",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRootType.php#L85-L103 |
28,245 | milejko/mmi | src/Mmi/Mvc/ViewHelper/HeadScript.php | HeadScript.appendFile | public function appendFile($src, $type = 'text/javascript', array $params = [], $conditional = '')
{
return $this->setFile($src, $type, $params, false, $conditional);
} | php | public function appendFile($src, $type = 'text/javascript', array $params = [], $conditional = '')
{
return $this->setFile($src, $type, $params, false, $conditional);
} | [
"public",
"function",
"appendFile",
"(",
"$",
"src",
",",
"$",
"type",
"=",
"'text/javascript'",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"conditional",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"setFile",
"(",
"$",
"src",
",",
"$",
"type",
",",
"$",
"params",
",",
"false",
",",
"$",
"conditional",
")",
";",
"}"
] | Dodaje na koniec stosu skrypt z pliku
@param string $src źródło
@param string $type typ
@param array $params dodatkowe parametry
@param string $conditional warunek np. ie6
@return \Mmi\Mvc\ViewHelper\HeadScript | [
"Dodaje",
"na",
"koniec",
"stosu",
"skrypt",
"z",
"pliku"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadScript.php#L92-L95 |
28,246 | milejko/mmi | src/Mmi/Mvc/ViewHelper/HeadScript.php | HeadScript.setFile | public function setFile($src, $type = 'text/javascript', array $params = [], $prepend = false, $conditional = '')
{
//pobieranie timestampu
$ts = $this->_getLocationTimestamp($src);
return $this->headScript(array_merge($params, ['type' => $type, 'src' => $ts > 0 ? $this->_getPublicSrc($src) : $src, 'ts' => $ts]), $prepend, $conditional);
} | php | public function setFile($src, $type = 'text/javascript', array $params = [], $prepend = false, $conditional = '')
{
//pobieranie timestampu
$ts = $this->_getLocationTimestamp($src);
return $this->headScript(array_merge($params, ['type' => $type, 'src' => $ts > 0 ? $this->_getPublicSrc($src) : $src, 'ts' => $ts]), $prepend, $conditional);
} | [
"public",
"function",
"setFile",
"(",
"$",
"src",
",",
"$",
"type",
"=",
"'text/javascript'",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"prepend",
"=",
"false",
",",
"$",
"conditional",
"=",
"''",
")",
"{",
"//pobieranie timestampu",
"$",
"ts",
"=",
"$",
"this",
"->",
"_getLocationTimestamp",
"(",
"$",
"src",
")",
";",
"return",
"$",
"this",
"->",
"headScript",
"(",
"array_merge",
"(",
"$",
"params",
",",
"[",
"'type'",
"=>",
"$",
"type",
",",
"'src'",
"=>",
"$",
"ts",
">",
"0",
"?",
"$",
"this",
"->",
"_getPublicSrc",
"(",
"$",
"src",
")",
":",
"$",
"src",
",",
"'ts'",
"=>",
"$",
"ts",
"]",
")",
",",
"$",
"prepend",
",",
"$",
"conditional",
")",
";",
"}"
] | Dodaje do stosu skrypt z pliku
@param string $src źródło
@param string $type typ
@param array $params dodatkowe parametry
@param boolean $prepend dodaj na początek stosu
@param string $conditional warunek np. ie6
@return \Mmi\Mvc\ViewHelper\HeadScript | [
"Dodaje",
"do",
"stosu",
"skrypt",
"z",
"pliku"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadScript.php#L119-L124 |
28,247 | peakphp/framework | src/Backpack/Bootstrap/Session.php | Session.boot | public function boot()
{
if ((php_sapi_name() === 'cli' || defined('STDIN'))) {
return;
}
if (session_status() == PHP_SESSION_ACTIVE) {
throw new Exception('Session is already started');
}
// save path
if ($this->app->hasProp($this->sessionPropName.'.save_path')) {
session_save_path($this->app->getProp($this->sessionPropName.'.save_path'));
}
// save handler class
if ($this->app->hasProp($this->sessionPropName.'.save_handler')) {
session_set_save_handler($this->app->getProp($this->sessionPropName.'.save_handler'));
}
// name the session
if ($this->app->hasProp($this->sessionPropName.'.name')) {
session_name($this->app->getProp($this->sessionPropName.'.name'));
}
// session options
$options = [];
if ($this->app->hasProp($this->sessionPropName.'.options')) {
$options = $this->app->getProp($this->sessionPropName.'.options');
}
// start the session
session_start($options);
} | php | public function boot()
{
if ((php_sapi_name() === 'cli' || defined('STDIN'))) {
return;
}
if (session_status() == PHP_SESSION_ACTIVE) {
throw new Exception('Session is already started');
}
// save path
if ($this->app->hasProp($this->sessionPropName.'.save_path')) {
session_save_path($this->app->getProp($this->sessionPropName.'.save_path'));
}
// save handler class
if ($this->app->hasProp($this->sessionPropName.'.save_handler')) {
session_set_save_handler($this->app->getProp($this->sessionPropName.'.save_handler'));
}
// name the session
if ($this->app->hasProp($this->sessionPropName.'.name')) {
session_name($this->app->getProp($this->sessionPropName.'.name'));
}
// session options
$options = [];
if ($this->app->hasProp($this->sessionPropName.'.options')) {
$options = $this->app->getProp($this->sessionPropName.'.options');
}
// start the session
session_start($options);
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"(",
"php_sapi_name",
"(",
")",
"===",
"'cli'",
"||",
"defined",
"(",
"'STDIN'",
")",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"session_status",
"(",
")",
"==",
"PHP_SESSION_ACTIVE",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Session is already started'",
")",
";",
"}",
"// save path",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"hasProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.save_path'",
")",
")",
"{",
"session_save_path",
"(",
"$",
"this",
"->",
"app",
"->",
"getProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.save_path'",
")",
")",
";",
"}",
"// save handler class",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"hasProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.save_handler'",
")",
")",
"{",
"session_set_save_handler",
"(",
"$",
"this",
"->",
"app",
"->",
"getProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.save_handler'",
")",
")",
";",
"}",
"// name the session",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"hasProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.name'",
")",
")",
"{",
"session_name",
"(",
"$",
"this",
"->",
"app",
"->",
"getProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.name'",
")",
")",
";",
"}",
"// session options",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"hasProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.options'",
")",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"app",
"->",
"getProp",
"(",
"$",
"this",
"->",
"sessionPropName",
".",
"'.options'",
")",
";",
"}",
"// start the session",
"session_start",
"(",
"$",
"options",
")",
";",
"}"
] | Setup and start session from app props
@throws Exception | [
"Setup",
"and",
"start",
"session",
"from",
"app",
"props"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Backpack/Bootstrap/Session.php#L45-L78 |
28,248 | milejko/mmi | src/Mmi/Mvc/Router.php | Router.encodeUrl | public function encodeUrl(array $params = [])
{
//pusty url
$url = '';
//aplikacja rout
foreach ($this->getRoutes() as $route) {
/* @var $route \Mmi\Mvc\RouterConfigRoute */
$result = (new RouterMatcher)->tryRouteForParams($route, array_merge($route->default, $params));
//dopasowano routę
if ($result['applied']) {
$url = '/' . $result['url'];
$matched = $result['matched'];
break;
}
}
//czyszczenie dopasowanych z routy
foreach (isset($matched) ? $matched : [] as $match => $value) {
unset($params[$match]);
}
//usuwanie kontrolera jeśli index
if (isset($params['controller']) && $params['controller'] == 'index') {
unset($params['controller']);
}
//usuwanie akcji jeśli index
if (isset($params['action']) && $params['action'] == 'index') {
unset($params['action']);
}
//jeśli puste parametry
if (empty($params)) {
return $url;
}
//budowanie zapytania
return $url . ($url == '/' ? '?' : '/?') . http_build_query($params);
} | php | public function encodeUrl(array $params = [])
{
//pusty url
$url = '';
//aplikacja rout
foreach ($this->getRoutes() as $route) {
/* @var $route \Mmi\Mvc\RouterConfigRoute */
$result = (new RouterMatcher)->tryRouteForParams($route, array_merge($route->default, $params));
//dopasowano routę
if ($result['applied']) {
$url = '/' . $result['url'];
$matched = $result['matched'];
break;
}
}
//czyszczenie dopasowanych z routy
foreach (isset($matched) ? $matched : [] as $match => $value) {
unset($params[$match]);
}
//usuwanie kontrolera jeśli index
if (isset($params['controller']) && $params['controller'] == 'index') {
unset($params['controller']);
}
//usuwanie akcji jeśli index
if (isset($params['action']) && $params['action'] == 'index') {
unset($params['action']);
}
//jeśli puste parametry
if (empty($params)) {
return $url;
}
//budowanie zapytania
return $url . ($url == '/' ? '?' : '/?') . http_build_query($params);
} | [
"public",
"function",
"encodeUrl",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"//pusty url",
"$",
"url",
"=",
"''",
";",
"//aplikacja rout",
"foreach",
"(",
"$",
"this",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"route",
")",
"{",
"/* @var $route \\Mmi\\Mvc\\RouterConfigRoute */",
"$",
"result",
"=",
"(",
"new",
"RouterMatcher",
")",
"->",
"tryRouteForParams",
"(",
"$",
"route",
",",
"array_merge",
"(",
"$",
"route",
"->",
"default",
",",
"$",
"params",
")",
")",
";",
"//dopasowano routę",
"if",
"(",
"$",
"result",
"[",
"'applied'",
"]",
")",
"{",
"$",
"url",
"=",
"'/'",
".",
"$",
"result",
"[",
"'url'",
"]",
";",
"$",
"matched",
"=",
"$",
"result",
"[",
"'matched'",
"]",
";",
"break",
";",
"}",
"}",
"//czyszczenie dopasowanych z routy",
"foreach",
"(",
"isset",
"(",
"$",
"matched",
")",
"?",
"$",
"matched",
":",
"[",
"]",
"as",
"$",
"match",
"=>",
"$",
"value",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"$",
"match",
"]",
")",
";",
"}",
"//usuwanie kontrolera jeśli index",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'controller'",
"]",
")",
"&&",
"$",
"params",
"[",
"'controller'",
"]",
"==",
"'index'",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'controller'",
"]",
")",
";",
"}",
"//usuwanie akcji jeśli index",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'action'",
"]",
")",
"&&",
"$",
"params",
"[",
"'action'",
"]",
"==",
"'index'",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'action'",
"]",
")",
";",
"}",
"//jeśli puste parametry",
"if",
"(",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"return",
"$",
"url",
";",
"}",
"//budowanie zapytania",
"return",
"$",
"url",
".",
"(",
"$",
"url",
"==",
"'/'",
"?",
"'?'",
":",
"'/?'",
")",
".",
"http_build_query",
"(",
"$",
"params",
")",
";",
"}"
] | Koduje parametry na URL zgodnie z wczytanymi trasami
@param array $params parametry
@return string | [
"Koduje",
"parametry",
"na",
"URL",
"zgodnie",
"z",
"wczytanymi",
"trasami"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/Router.php#L105-L138 |
28,249 | honeybee/honeybee | src/Common/Util/FileToolkit.php | FileToolkit.guessExtensionForLocalFile | public static function guessExtensionForLocalFile($file_path, $fallback_extension = '')
{
// FILEINFO_MIME would return the mime encoding as well
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime_type = $finfo->file($file_path);
return static::guessExtensionByMimeType($mime_type, $fallback_extension);
} | php | public static function guessExtensionForLocalFile($file_path, $fallback_extension = '')
{
// FILEINFO_MIME would return the mime encoding as well
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime_type = $finfo->file($file_path);
return static::guessExtensionByMimeType($mime_type, $fallback_extension);
} | [
"public",
"static",
"function",
"guessExtensionForLocalFile",
"(",
"$",
"file_path",
",",
"$",
"fallback_extension",
"=",
"''",
")",
"{",
"// FILEINFO_MIME would return the mime encoding as well",
"$",
"finfo",
"=",
"new",
"finfo",
"(",
"FILEINFO_MIME_TYPE",
")",
";",
"$",
"mime_type",
"=",
"$",
"finfo",
"->",
"file",
"(",
"$",
"file_path",
")",
";",
"return",
"static",
"::",
"guessExtensionByMimeType",
"(",
"$",
"mime_type",
",",
"$",
"fallback_extension",
")",
";",
"}"
] | Returns a file extension guessed for the given local file.
@param string $file_path path to file
@param string $fallback_extension extension to return on failed guess
@return string default file extension for given mime type or fallback extension provided | [
"Returns",
"a",
"file",
"extension",
"guessed",
"for",
"the",
"given",
"local",
"file",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Common/Util/FileToolkit.php#L20-L27 |
28,250 | milejko/mmi | src/Mmi/Session/SessionSpace.php | SessionSpace.toArray | public function toArray()
{
return (isset($_SESSION[$this->_namespace]) && is_array($_SESSION[$this->_namespace])) ? $_SESSION[$this->_namespace] : [];
} | php | public function toArray()
{
return (isset($_SESSION[$this->_namespace]) && is_array($_SESSION[$this->_namespace])) ? $_SESSION[$this->_namespace] : [];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_namespace",
"]",
")",
"&&",
"is_array",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_namespace",
"]",
")",
")",
"?",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_namespace",
"]",
":",
"[",
"]",
";",
"}"
] | Zrzuca namespace do tabeli
@return string | [
"Zrzuca",
"namespace",
"do",
"tabeli"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Session/SessionSpace.php#L106-L109 |
28,251 | milejko/mmi | src/Mmi/Navigation/NavigationConfigElement.php | NavigationConfigElement.addChild | public function addChild(\Mmi\Navigation\NavigationConfigElement $element)
{
$this->_options['children'][$element->getId()] = $element;
return $this;
} | php | public function addChild(\Mmi\Navigation\NavigationConfigElement $element)
{
$this->_options['children'][$element->getId()] = $element;
return $this;
} | [
"public",
"function",
"addChild",
"(",
"\\",
"Mmi",
"\\",
"Navigation",
"\\",
"NavigationConfigElement",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"_options",
"[",
"'children'",
"]",
"[",
"$",
"element",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"element",
";",
"return",
"$",
"this",
";",
"}"
] | Dodaje element potomny
@param \Mmi\Navigation\NavigationConfigElement $element
@return \Mmi\Navigation\NavigationConfigElement | [
"Dodaje",
"element",
"potomny"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfigElement.php#L163-L167 |
28,252 | peakphp/framework | src/Backpack/BlackMagic.php | BlackMagic.createApp | public static function createApp(string $environment = 'dev', Dictionary $props = null)
{
$container = new Container();
$kernel = new Kernel($environment, $container);
$handlerResolver = new HandlerResolver($container);
$props = $props ?? new PropertiesBag();
return new Application(
$kernel,
$handlerResolver,
$props
);
} | php | public static function createApp(string $environment = 'dev', Dictionary $props = null)
{
$container = new Container();
$kernel = new Kernel($environment, $container);
$handlerResolver = new HandlerResolver($container);
$props = $props ?? new PropertiesBag();
return new Application(
$kernel,
$handlerResolver,
$props
);
} | [
"public",
"static",
"function",
"createApp",
"(",
"string",
"$",
"environment",
"=",
"'dev'",
",",
"Dictionary",
"$",
"props",
"=",
"null",
")",
"{",
"$",
"container",
"=",
"new",
"Container",
"(",
")",
";",
"$",
"kernel",
"=",
"new",
"Kernel",
"(",
"$",
"environment",
",",
"$",
"container",
")",
";",
"$",
"handlerResolver",
"=",
"new",
"HandlerResolver",
"(",
"$",
"container",
")",
";",
"$",
"props",
"=",
"$",
"props",
"??",
"new",
"PropertiesBag",
"(",
")",
";",
"return",
"new",
"Application",
"(",
"$",
"kernel",
",",
"$",
"handlerResolver",
",",
"$",
"props",
")",
";",
"}"
] | Create an app!
@param string $environment
@param Dictionary|null $props
@return Application | [
"Create",
"an",
"app!"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Backpack/BlackMagic.php#L35-L46 |
28,253 | peakphp/framework | src/Backpack/BlackMagic.php | BlackMagic.runThis | public static function runThis(Application $app, array $handlers, ServerRequestInterface $request)
{
return $app->set($handlers)
->run($request, new Emitter());
} | php | public static function runThis(Application $app, array $handlers, ServerRequestInterface $request)
{
return $app->set($handlers)
->run($request, new Emitter());
} | [
"public",
"static",
"function",
"runThis",
"(",
"Application",
"$",
"app",
",",
"array",
"$",
"handlers",
",",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"return",
"$",
"app",
"->",
"set",
"(",
"$",
"handlers",
")",
"->",
"run",
"(",
"$",
"request",
",",
"new",
"Emitter",
"(",
")",
")",
";",
"}"
] | Handle And Emit !
@param Application $app
@param array $handlers
@param ServerRequestInterface $request
@return mixed | [
"Handle",
"And",
"Emit",
"!"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Backpack/BlackMagic.php#L91-L95 |
28,254 | quazardous/ImageStack | src/ImageStack/StorageBackend/FileStorageBackend.php | FileStorageBackend.writeImageFile | protected function writeImageFile(ImageInterface $image, ImagePathInterface $path) {
$filename = sanitize_path(implode(DIRECTORY_SEPARATOR, [
$this->getOption('root'),
/**
* The stack prefix is the part of the URL that is used to detect wich stack to trigger.
* This implementation aims to store a file at the exact same URL so next requests could be served statically.
*/
$this->getOption('use_prefix', false) ? $path->getPrefix() : null,
$path->getPath(),
]));
$dirname = dirname($filename);
if (!is_dir($dirname)) {
@mkdir($dirname, $this->getOption('mode', 0755), true);
if (!is_dir($dirname)) {
throw new StorageBackendException(sprintf('Cannot create dir %s', $dirname), StorageBackendException::CANNOT_CREATE_DIR);
}
}
if (!file_put_contents($filename, $image->getBinaryContent())) {
throw new StorageBackendException(sprintf('Cannot write file %s', $filename), StorageBackendException::CANNOT_WRITE_FILE);
}
} | php | protected function writeImageFile(ImageInterface $image, ImagePathInterface $path) {
$filename = sanitize_path(implode(DIRECTORY_SEPARATOR, [
$this->getOption('root'),
/**
* The stack prefix is the part of the URL that is used to detect wich stack to trigger.
* This implementation aims to store a file at the exact same URL so next requests could be served statically.
*/
$this->getOption('use_prefix', false) ? $path->getPrefix() : null,
$path->getPath(),
]));
$dirname = dirname($filename);
if (!is_dir($dirname)) {
@mkdir($dirname, $this->getOption('mode', 0755), true);
if (!is_dir($dirname)) {
throw new StorageBackendException(sprintf('Cannot create dir %s', $dirname), StorageBackendException::CANNOT_CREATE_DIR);
}
}
if (!file_put_contents($filename, $image->getBinaryContent())) {
throw new StorageBackendException(sprintf('Cannot write file %s', $filename), StorageBackendException::CANNOT_WRITE_FILE);
}
} | [
"protected",
"function",
"writeImageFile",
"(",
"ImageInterface",
"$",
"image",
",",
"ImagePathInterface",
"$",
"path",
")",
"{",
"$",
"filename",
"=",
"sanitize_path",
"(",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"this",
"->",
"getOption",
"(",
"'root'",
")",
",",
"/**\n \t\t * The stack prefix is the part of the URL that is used to detect wich stack to trigger.\n \t\t * This implementation aims to store a file at the exact same URL so next requests could be served statically.\n \t\t */",
"$",
"this",
"->",
"getOption",
"(",
"'use_prefix'",
",",
"false",
")",
"?",
"$",
"path",
"->",
"getPrefix",
"(",
")",
":",
"null",
",",
"$",
"path",
"->",
"getPath",
"(",
")",
",",
"]",
")",
")",
";",
"$",
"dirname",
"=",
"dirname",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"@",
"mkdir",
"(",
"$",
"dirname",
",",
"$",
"this",
"->",
"getOption",
"(",
"'mode'",
",",
"0755",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"throw",
"new",
"StorageBackendException",
"(",
"sprintf",
"(",
"'Cannot create dir %s'",
",",
"$",
"dirname",
")",
",",
"StorageBackendException",
"::",
"CANNOT_CREATE_DIR",
")",
";",
"}",
"}",
"if",
"(",
"!",
"file_put_contents",
"(",
"$",
"filename",
",",
"$",
"image",
"->",
"getBinaryContent",
"(",
")",
")",
")",
"{",
"throw",
"new",
"StorageBackendException",
"(",
"sprintf",
"(",
"'Cannot write file %s'",
",",
"$",
"filename",
")",
",",
"StorageBackendException",
"::",
"CANNOT_WRITE_FILE",
")",
";",
"}",
"}"
] | Write image to FS.
@param string $binaryContent
@param ImagePathInterface $path
@throws StorageBackendException | [
"Write",
"image",
"to",
"FS",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/StorageBackend/FileStorageBackend.php#L49-L69 |
28,255 | honeybee/honeybee | src/Infrastructure/DataAccess/UnitOfWork/UnitOfWork.php | UnitOfWork.checkout | public function checkout($aggregate_root_id)
{
$aggregate_root = $this->create();
$event_stream = $this->event_reader->read($aggregate_root_id);
if ($event_stream) {
$aggregate_root->reconstituteFrom($event_stream->getEvents());
} else {
$this->logger->debug(__METHOD__ . ' - ' . get_class($this->event_reader));
throw new RuntimeError(
sprintf('Unable to load event stream for given AR identifier: %s', $aggregate_root_id)
);
}
return $aggregate_root;
} | php | public function checkout($aggregate_root_id)
{
$aggregate_root = $this->create();
$event_stream = $this->event_reader->read($aggregate_root_id);
if ($event_stream) {
$aggregate_root->reconstituteFrom($event_stream->getEvents());
} else {
$this->logger->debug(__METHOD__ . ' - ' . get_class($this->event_reader));
throw new RuntimeError(
sprintf('Unable to load event stream for given AR identifier: %s', $aggregate_root_id)
);
}
return $aggregate_root;
} | [
"public",
"function",
"checkout",
"(",
"$",
"aggregate_root_id",
")",
"{",
"$",
"aggregate_root",
"=",
"$",
"this",
"->",
"create",
"(",
")",
";",
"$",
"event_stream",
"=",
"$",
"this",
"->",
"event_reader",
"->",
"read",
"(",
"$",
"aggregate_root_id",
")",
";",
"if",
"(",
"$",
"event_stream",
")",
"{",
"$",
"aggregate_root",
"->",
"reconstituteFrom",
"(",
"$",
"event_stream",
"->",
"getEvents",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__METHOD__",
".",
"' - '",
".",
"get_class",
"(",
"$",
"this",
"->",
"event_reader",
")",
")",
";",
"throw",
"new",
"RuntimeError",
"(",
"sprintf",
"(",
"'Unable to load event stream for given AR identifier: %s'",
",",
"$",
"aggregate_root_id",
")",
")",
";",
"}",
"return",
"$",
"aggregate_root",
";",
"}"
] | Checkout the aggregate-root for a given identifier.
@param string $aggregate_root_id
@return AggregateRootInterface | [
"Checkout",
"the",
"aggregate",
"-",
"root",
"for",
"a",
"given",
"identifier",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/DataAccess/UnitOfWork/UnitOfWork.php#L99-L113 |
28,256 | honeybee/honeybee | src/Infrastructure/DataAccess/UnitOfWork/UnitOfWork.php | UnitOfWork.commit | public function commit()
{
$committed_events_map = new AggregateRootEventListMap;
$comitted_ars = [];
foreach ($this->tracked_aggregate_roots as $aggregate_root) {
$event_stream = $this->tracked_aggregate_roots[$aggregate_root];
$committed_events_list = new AggregateRootEventList;
foreach ($aggregate_root->getUncomittedEvents() as $uncomitted_event) {
$event_stream->push($uncomitted_event);
$this->event_writer->write($uncomitted_event);
$committed_events_list->push($uncomitted_event);
}
$aggregate_root->markAsComitted();
$committed_events_map->setItem($aggregate_root->getIdentifier(), $committed_events_list);
$comitted_ars[] = $aggregate_root;
}
foreach ($comitted_ars as $comitted_ar) {
$this->tracked_aggregate_roots->offsetUnset($aggregate_root);
}
return $committed_events_map;
} | php | public function commit()
{
$committed_events_map = new AggregateRootEventListMap;
$comitted_ars = [];
foreach ($this->tracked_aggregate_roots as $aggregate_root) {
$event_stream = $this->tracked_aggregate_roots[$aggregate_root];
$committed_events_list = new AggregateRootEventList;
foreach ($aggregate_root->getUncomittedEvents() as $uncomitted_event) {
$event_stream->push($uncomitted_event);
$this->event_writer->write($uncomitted_event);
$committed_events_list->push($uncomitted_event);
}
$aggregate_root->markAsComitted();
$committed_events_map->setItem($aggregate_root->getIdentifier(), $committed_events_list);
$comitted_ars[] = $aggregate_root;
}
foreach ($comitted_ars as $comitted_ar) {
$this->tracked_aggregate_roots->offsetUnset($aggregate_root);
}
return $committed_events_map;
} | [
"public",
"function",
"commit",
"(",
")",
"{",
"$",
"committed_events_map",
"=",
"new",
"AggregateRootEventListMap",
";",
"$",
"comitted_ars",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"tracked_aggregate_roots",
"as",
"$",
"aggregate_root",
")",
"{",
"$",
"event_stream",
"=",
"$",
"this",
"->",
"tracked_aggregate_roots",
"[",
"$",
"aggregate_root",
"]",
";",
"$",
"committed_events_list",
"=",
"new",
"AggregateRootEventList",
";",
"foreach",
"(",
"$",
"aggregate_root",
"->",
"getUncomittedEvents",
"(",
")",
"as",
"$",
"uncomitted_event",
")",
"{",
"$",
"event_stream",
"->",
"push",
"(",
"$",
"uncomitted_event",
")",
";",
"$",
"this",
"->",
"event_writer",
"->",
"write",
"(",
"$",
"uncomitted_event",
")",
";",
"$",
"committed_events_list",
"->",
"push",
"(",
"$",
"uncomitted_event",
")",
";",
"}",
"$",
"aggregate_root",
"->",
"markAsComitted",
"(",
")",
";",
"$",
"committed_events_map",
"->",
"setItem",
"(",
"$",
"aggregate_root",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"committed_events_list",
")",
";",
"$",
"comitted_ars",
"[",
"]",
"=",
"$",
"aggregate_root",
";",
"}",
"foreach",
"(",
"$",
"comitted_ars",
"as",
"$",
"comitted_ar",
")",
"{",
"$",
"this",
"->",
"tracked_aggregate_roots",
"->",
"offsetUnset",
"(",
"$",
"aggregate_root",
")",
";",
"}",
"return",
"$",
"committed_events_map",
";",
"}"
] | Commit all changes that are pending for our tracked aggregate-roots.
@return AggregateRootEventList Returns a list of events that were actually committed. | [
"Commit",
"all",
"changes",
"that",
"are",
"pending",
"for",
"our",
"tracked",
"aggregate",
"-",
"roots",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/DataAccess/UnitOfWork/UnitOfWork.php#L120-L142 |
28,257 | honeybee/honeybee | src/Infrastructure/DataAccess/UnitOfWork/UnitOfWork.php | UnitOfWork.startTracking | protected function startTracking(AggregateRootInterface $aggregate_root)
{
if ($this->tracked_aggregate_roots->contains($aggregate_root)) {
throw new RuntimeError("Trying to checkout aggregate that already has a session open.");
}
$aggregate_root_id = $aggregate_root->getIdentifier();
$this->tracked_aggregate_roots[$aggregate_root] = new EventStream([ 'identifier' => $aggregate_root_id ]);
} | php | protected function startTracking(AggregateRootInterface $aggregate_root)
{
if ($this->tracked_aggregate_roots->contains($aggregate_root)) {
throw new RuntimeError("Trying to checkout aggregate that already has a session open.");
}
$aggregate_root_id = $aggregate_root->getIdentifier();
$this->tracked_aggregate_roots[$aggregate_root] = new EventStream([ 'identifier' => $aggregate_root_id ]);
} | [
"protected",
"function",
"startTracking",
"(",
"AggregateRootInterface",
"$",
"aggregate_root",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tracked_aggregate_roots",
"->",
"contains",
"(",
"$",
"aggregate_root",
")",
")",
"{",
"throw",
"new",
"RuntimeError",
"(",
"\"Trying to checkout aggregate that already has a session open.\"",
")",
";",
"}",
"$",
"aggregate_root_id",
"=",
"$",
"aggregate_root",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"this",
"->",
"tracked_aggregate_roots",
"[",
"$",
"aggregate_root",
"]",
"=",
"new",
"EventStream",
"(",
"[",
"'identifier'",
"=>",
"$",
"aggregate_root_id",
"]",
")",
";",
"}"
] | Register the given aggregate-root to our event stream map.
@param AggregateRootInterface $aggregate_root | [
"Register",
"the",
"given",
"aggregate",
"-",
"root",
"to",
"our",
"event",
"stream",
"map",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/DataAccess/UnitOfWork/UnitOfWork.php#L154-L162 |
28,258 | milejko/mmi | src/Mmi/Orm/Builder.php | Builder.buildFromTableName | public static function buildFromTableName($tableName)
{
//pomijanie modułów z vendorów
foreach (\Mmi\Mvc\StructureParser::getModules() as $module) {
if (strtolower(basename($module)) == explode('_', $tableName)[0] && false !== strpos($module, 'vendor')) {
return;
}
}
//aktualizacja QUERY-FIELD
self::_updateQueryField($tableName);
//aktualizacja QUERY-JOIN
self::_updateQueryJoin($tableName);
//aktualizacja QUERY
self::_updateQuery($tableName);
//aktualizacja RECORD
self::_updateRecord($tableName);
} | php | public static function buildFromTableName($tableName)
{
//pomijanie modułów z vendorów
foreach (\Mmi\Mvc\StructureParser::getModules() as $module) {
if (strtolower(basename($module)) == explode('_', $tableName)[0] && false !== strpos($module, 'vendor')) {
return;
}
}
//aktualizacja QUERY-FIELD
self::_updateQueryField($tableName);
//aktualizacja QUERY-JOIN
self::_updateQueryJoin($tableName);
//aktualizacja QUERY
self::_updateQuery($tableName);
//aktualizacja RECORD
self::_updateRecord($tableName);
} | [
"public",
"static",
"function",
"buildFromTableName",
"(",
"$",
"tableName",
")",
"{",
"//pomijanie modułów z vendorów",
"foreach",
"(",
"\\",
"Mmi",
"\\",
"Mvc",
"\\",
"StructureParser",
"::",
"getModules",
"(",
")",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"strtolower",
"(",
"basename",
"(",
"$",
"module",
")",
")",
"==",
"explode",
"(",
"'_'",
",",
"$",
"tableName",
")",
"[",
"0",
"]",
"&&",
"false",
"!==",
"strpos",
"(",
"$",
"module",
",",
"'vendor'",
")",
")",
"{",
"return",
";",
"}",
"}",
"//aktualizacja QUERY-FIELD",
"self",
"::",
"_updateQueryField",
"(",
"$",
"tableName",
")",
";",
"//aktualizacja QUERY-JOIN",
"self",
"::",
"_updateQueryJoin",
"(",
"$",
"tableName",
")",
";",
"//aktualizacja QUERY",
"self",
"::",
"_updateQuery",
"(",
"$",
"tableName",
")",
";",
"//aktualizacja RECORD",
"self",
"::",
"_updateRecord",
"(",
"$",
"tableName",
")",
";",
"}"
] | Renderuje DAO, Record i Query dla podanej nazwy tabeli
@param string $tableName
@throws \Mmi\Orm\OrmException | [
"Renderuje",
"DAO",
"Record",
"i",
"Query",
"dla",
"podanej",
"nazwy",
"tabeli"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Builder.php#L26-L42 |
28,259 | milejko/mmi | src/Mmi/Orm/Builder.php | Builder._updateRecord | protected static function _updateRecord($tableName)
{
//kod rekordu
$recordCode = '<?php' . "\n\n" .
'namespace ' . self::_getNamespace($tableName) . ";\n\n" .
'class ' . ($className = self::_getNamePrefix($tableName) . 'Record') . ' extends \Mmi\Orm\Record' .
"\n{" .
"\n\n" .
'}' . "\n";
//ścieżka do pliku
$path = self::_mkdirRecursive(self::_getPathPrefix($tableName)) . '/' . $className . '.php';
//wczytanie istniejącego rekordu
if (file_exists($path)) {
$recordCode = file_get_contents($path);
}
//odczyt struktury tabeli
$structure = DbConnector::getTableStructure($tableName);
//błędna struktrura lub brak
if (empty($structure)) {
throw new rmException('\Mmi\Orm\Builder: no table found, or table invalid: ' . $tableName);
}
$variableString = "\n";
//generowanie pól rekordu
foreach ($structure as $fieldName => $fieldDetails) {
$variables[] = Convert::underscoreToCamelcase($fieldName);
$variableString .= self::INDENT . 'public $' . Convert::underscoreToCamelcase($fieldName) . ";\n";
}
//sprawdzanie istnienia pól rekordu
if (preg_match_all('/' . self::INDENT . 'public \$([a-zA-Z0-9\_]+)[\;|\s\=]/', $recordCode, $codeVariables) && isset($codeVariables[1])) {
//za dużo względem bazy
$diffRecord = array_diff($codeVariables[1], $variables);
//brakujące względem DB
$diffDb = array_diff($variables, $codeVariables[1]);
//pola się nie zgadzają
if (!empty($diffRecord) || !empty($diffDb)) {
throw new OrmException('RECORD for: "' . $tableName . '" has invalid fields: ' . implode(', ', $diffRecord) . ', and missing: ' . implode(',', $diffDb));
}
return;
}
$recordCode = preg_replace('/(class ' . $className . ' extends [\\a-zA-Z0-9]+\n\{?\r?\n?)/', '$1' . $variableString, $recordCode);
//zapis pliku
file_put_contents($path, $recordCode);
} | php | protected static function _updateRecord($tableName)
{
//kod rekordu
$recordCode = '<?php' . "\n\n" .
'namespace ' . self::_getNamespace($tableName) . ";\n\n" .
'class ' . ($className = self::_getNamePrefix($tableName) . 'Record') . ' extends \Mmi\Orm\Record' .
"\n{" .
"\n\n" .
'}' . "\n";
//ścieżka do pliku
$path = self::_mkdirRecursive(self::_getPathPrefix($tableName)) . '/' . $className . '.php';
//wczytanie istniejącego rekordu
if (file_exists($path)) {
$recordCode = file_get_contents($path);
}
//odczyt struktury tabeli
$structure = DbConnector::getTableStructure($tableName);
//błędna struktrura lub brak
if (empty($structure)) {
throw new rmException('\Mmi\Orm\Builder: no table found, or table invalid: ' . $tableName);
}
$variableString = "\n";
//generowanie pól rekordu
foreach ($structure as $fieldName => $fieldDetails) {
$variables[] = Convert::underscoreToCamelcase($fieldName);
$variableString .= self::INDENT . 'public $' . Convert::underscoreToCamelcase($fieldName) . ";\n";
}
//sprawdzanie istnienia pól rekordu
if (preg_match_all('/' . self::INDENT . 'public \$([a-zA-Z0-9\_]+)[\;|\s\=]/', $recordCode, $codeVariables) && isset($codeVariables[1])) {
//za dużo względem bazy
$diffRecord = array_diff($codeVariables[1], $variables);
//brakujące względem DB
$diffDb = array_diff($variables, $codeVariables[1]);
//pola się nie zgadzają
if (!empty($diffRecord) || !empty($diffDb)) {
throw new OrmException('RECORD for: "' . $tableName . '" has invalid fields: ' . implode(', ', $diffRecord) . ', and missing: ' . implode(',', $diffDb));
}
return;
}
$recordCode = preg_replace('/(class ' . $className . ' extends [\\a-zA-Z0-9]+\n\{?\r?\n?)/', '$1' . $variableString, $recordCode);
//zapis pliku
file_put_contents($path, $recordCode);
} | [
"protected",
"static",
"function",
"_updateRecord",
"(",
"$",
"tableName",
")",
"{",
"//kod rekordu",
"$",
"recordCode",
"=",
"'<?php'",
".",
"\"\\n\\n\"",
".",
"'namespace '",
".",
"self",
"::",
"_getNamespace",
"(",
"$",
"tableName",
")",
".",
"\";\\n\\n\"",
".",
"'class '",
".",
"(",
"$",
"className",
"=",
"self",
"::",
"_getNamePrefix",
"(",
"$",
"tableName",
")",
".",
"'Record'",
")",
".",
"' extends \\Mmi\\Orm\\Record'",
".",
"\"\\n{\"",
".",
"\"\\n\\n\"",
".",
"'}'",
".",
"\"\\n\"",
";",
"//ścieżka do pliku",
"$",
"path",
"=",
"self",
"::",
"_mkdirRecursive",
"(",
"self",
"::",
"_getPathPrefix",
"(",
"$",
"tableName",
")",
")",
".",
"'/'",
".",
"$",
"className",
".",
"'.php'",
";",
"//wczytanie istniejącego rekordu",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"recordCode",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"}",
"//odczyt struktury tabeli",
"$",
"structure",
"=",
"DbConnector",
"::",
"getTableStructure",
"(",
"$",
"tableName",
")",
";",
"//błędna struktrura lub brak",
"if",
"(",
"empty",
"(",
"$",
"structure",
")",
")",
"{",
"throw",
"new",
"rmException",
"(",
"'\\Mmi\\Orm\\Builder: no table found, or table invalid: '",
".",
"$",
"tableName",
")",
";",
"}",
"$",
"variableString",
"=",
"\"\\n\"",
";",
"//generowanie pól rekordu",
"foreach",
"(",
"$",
"structure",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldDetails",
")",
"{",
"$",
"variables",
"[",
"]",
"=",
"Convert",
"::",
"underscoreToCamelcase",
"(",
"$",
"fieldName",
")",
";",
"$",
"variableString",
".=",
"self",
"::",
"INDENT",
".",
"'public $'",
".",
"Convert",
"::",
"underscoreToCamelcase",
"(",
"$",
"fieldName",
")",
".",
"\";\\n\"",
";",
"}",
"//sprawdzanie istnienia pól rekordu",
"if",
"(",
"preg_match_all",
"(",
"'/'",
".",
"self",
"::",
"INDENT",
".",
"'public \\$([a-zA-Z0-9\\_]+)[\\;|\\s\\=]/'",
",",
"$",
"recordCode",
",",
"$",
"codeVariables",
")",
"&&",
"isset",
"(",
"$",
"codeVariables",
"[",
"1",
"]",
")",
")",
"{",
"//za dużo względem bazy",
"$",
"diffRecord",
"=",
"array_diff",
"(",
"$",
"codeVariables",
"[",
"1",
"]",
",",
"$",
"variables",
")",
";",
"//brakujące względem DB",
"$",
"diffDb",
"=",
"array_diff",
"(",
"$",
"variables",
",",
"$",
"codeVariables",
"[",
"1",
"]",
")",
";",
"//pola się nie zgadzają",
"if",
"(",
"!",
"empty",
"(",
"$",
"diffRecord",
")",
"||",
"!",
"empty",
"(",
"$",
"diffDb",
")",
")",
"{",
"throw",
"new",
"OrmException",
"(",
"'RECORD for: \"'",
".",
"$",
"tableName",
".",
"'\" has invalid fields: '",
".",
"implode",
"(",
"', '",
",",
"$",
"diffRecord",
")",
".",
"', and missing: '",
".",
"implode",
"(",
"','",
",",
"$",
"diffDb",
")",
")",
";",
"}",
"return",
";",
"}",
"$",
"recordCode",
"=",
"preg_replace",
"(",
"'/(class '",
".",
"$",
"className",
".",
"' extends [\\\\a-zA-Z0-9]+\\n\\{?\\r?\\n?)/'",
",",
"'$1'",
".",
"$",
"variableString",
",",
"$",
"recordCode",
")",
";",
"//zapis pliku",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"recordCode",
")",
";",
"}"
] | Tworzy, lub aktualizuje rekord
@param string $tableName | [
"Tworzy",
"lub",
"aktualizuje",
"rekord"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Builder.php#L48-L90 |
28,260 | milejko/mmi | src/Mmi/Orm/Builder.php | Builder._updateQueryField | protected static function _updateQueryField($tableName)
{
//prefixy nazw
$queryClassName = self::_getNamespace($tableName) . '\\' . self::_getNamePrefix($tableName) . 'Query';
//odczyt struktury
$structure = DbConnector::getTableStructure($tableName);
$methods = '';
//budowanie komentarzy do metod
foreach ($structure as $fieldName => $fieldDetails) {
$fieldName = ucfirst(Convert::underscoreToCamelcase($fieldName));
//metody equalsColumn... np. equalsColumnActive()
$methods .= ' * @method \\' . $queryClassName . ' equalsColumn' . $fieldName . '()' . "\n";
//notEqualsColumn
$methods .= ' * @method \\' . $queryClassName . ' notEqualsColumn' . $fieldName . '()' . "\n";
//greaterThanColumn
$methods .= ' * @method \\' . $queryClassName . ' greaterThanColumn' . $fieldName . '()' . "\n";
//lessThanColumn
$methods .= ' * @method \\' . $queryClassName . ' lessThanColumn' . $fieldName . '()' . "\n";
//greaterOrEqualsColumn
$methods .= ' * @method \\' . $queryClassName . ' greaterOrEqualsColumn' . $fieldName . '()' . "\n";
//lessOrEqualsColumn
$methods .= ' * @method \\' . $queryClassName . ' lessOrEqualsColumn' . $fieldName . '()' . "\n";
}
//anotacje dla metod porównujących (equals itp.)
$queryCode = '<?php' . "\n\n" .
'namespace ' . self::_getNamespace($tableName) . '\QueryHelper' . ";\n\n" .
'/**' . "\n" .
' * @method \\' . $queryClassName . ' equals($value)' . "\n" .
' * @method \\' . $queryClassName . ' notEquals($value)' . "\n" .
' * @method \\' . $queryClassName . ' greater($value)' . "\n" .
' * @method \\' . $queryClassName . ' less($value)' . "\n" .
' * @method \\' . $queryClassName . ' greaterOrEquals($value)' . "\n" .
' * @method \\' . $queryClassName . ' lessOrEquals($value)' . "\n" .
' * @method \\' . $queryClassName . ' like($value)' . "\n" .
' * @method \\' . $queryClassName . ' notLike($value)' . "\n" .
' * @method \\' . $queryClassName . ' between($from, $to)' . "\n" .
$methods .
' */' . "\n" .
'class ' . ($className = self::_getNamePrefix($tableName) . 'QueryField') . ' extends \Mmi\Orm\QueryHelper\QueryField' .
"\n{" .
"\n\n" .
'}' . "\n";
//zapis pliku
file_put_contents(self::_mkdirRecursive(self::_getPathPrefix($tableName) . '/QueryHelper') . '/' . $className . '.php', $queryCode);
} | php | protected static function _updateQueryField($tableName)
{
//prefixy nazw
$queryClassName = self::_getNamespace($tableName) . '\\' . self::_getNamePrefix($tableName) . 'Query';
//odczyt struktury
$structure = DbConnector::getTableStructure($tableName);
$methods = '';
//budowanie komentarzy do metod
foreach ($structure as $fieldName => $fieldDetails) {
$fieldName = ucfirst(Convert::underscoreToCamelcase($fieldName));
//metody equalsColumn... np. equalsColumnActive()
$methods .= ' * @method \\' . $queryClassName . ' equalsColumn' . $fieldName . '()' . "\n";
//notEqualsColumn
$methods .= ' * @method \\' . $queryClassName . ' notEqualsColumn' . $fieldName . '()' . "\n";
//greaterThanColumn
$methods .= ' * @method \\' . $queryClassName . ' greaterThanColumn' . $fieldName . '()' . "\n";
//lessThanColumn
$methods .= ' * @method \\' . $queryClassName . ' lessThanColumn' . $fieldName . '()' . "\n";
//greaterOrEqualsColumn
$methods .= ' * @method \\' . $queryClassName . ' greaterOrEqualsColumn' . $fieldName . '()' . "\n";
//lessOrEqualsColumn
$methods .= ' * @method \\' . $queryClassName . ' lessOrEqualsColumn' . $fieldName . '()' . "\n";
}
//anotacje dla metod porównujących (equals itp.)
$queryCode = '<?php' . "\n\n" .
'namespace ' . self::_getNamespace($tableName) . '\QueryHelper' . ";\n\n" .
'/**' . "\n" .
' * @method \\' . $queryClassName . ' equals($value)' . "\n" .
' * @method \\' . $queryClassName . ' notEquals($value)' . "\n" .
' * @method \\' . $queryClassName . ' greater($value)' . "\n" .
' * @method \\' . $queryClassName . ' less($value)' . "\n" .
' * @method \\' . $queryClassName . ' greaterOrEquals($value)' . "\n" .
' * @method \\' . $queryClassName . ' lessOrEquals($value)' . "\n" .
' * @method \\' . $queryClassName . ' like($value)' . "\n" .
' * @method \\' . $queryClassName . ' notLike($value)' . "\n" .
' * @method \\' . $queryClassName . ' between($from, $to)' . "\n" .
$methods .
' */' . "\n" .
'class ' . ($className = self::_getNamePrefix($tableName) . 'QueryField') . ' extends \Mmi\Orm\QueryHelper\QueryField' .
"\n{" .
"\n\n" .
'}' . "\n";
//zapis pliku
file_put_contents(self::_mkdirRecursive(self::_getPathPrefix($tableName) . '/QueryHelper') . '/' . $className . '.php', $queryCode);
} | [
"protected",
"static",
"function",
"_updateQueryField",
"(",
"$",
"tableName",
")",
"{",
"//prefixy nazw",
"$",
"queryClassName",
"=",
"self",
"::",
"_getNamespace",
"(",
"$",
"tableName",
")",
".",
"'\\\\'",
".",
"self",
"::",
"_getNamePrefix",
"(",
"$",
"tableName",
")",
".",
"'Query'",
";",
"//odczyt struktury",
"$",
"structure",
"=",
"DbConnector",
"::",
"getTableStructure",
"(",
"$",
"tableName",
")",
";",
"$",
"methods",
"=",
"''",
";",
"//budowanie komentarzy do metod",
"foreach",
"(",
"$",
"structure",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldDetails",
")",
"{",
"$",
"fieldName",
"=",
"ucfirst",
"(",
"Convert",
"::",
"underscoreToCamelcase",
"(",
"$",
"fieldName",
")",
")",
";",
"//metody equalsColumn... np. equalsColumnActive()",
"$",
"methods",
".=",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' equalsColumn'",
".",
"$",
"fieldName",
".",
"'()'",
".",
"\"\\n\"",
";",
"//notEqualsColumn",
"$",
"methods",
".=",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' notEqualsColumn'",
".",
"$",
"fieldName",
".",
"'()'",
".",
"\"\\n\"",
";",
"//greaterThanColumn",
"$",
"methods",
".=",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' greaterThanColumn'",
".",
"$",
"fieldName",
".",
"'()'",
".",
"\"\\n\"",
";",
"//lessThanColumn",
"$",
"methods",
".=",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' lessThanColumn'",
".",
"$",
"fieldName",
".",
"'()'",
".",
"\"\\n\"",
";",
"//greaterOrEqualsColumn",
"$",
"methods",
".=",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' greaterOrEqualsColumn'",
".",
"$",
"fieldName",
".",
"'()'",
".",
"\"\\n\"",
";",
"//lessOrEqualsColumn",
"$",
"methods",
".=",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' lessOrEqualsColumn'",
".",
"$",
"fieldName",
".",
"'()'",
".",
"\"\\n\"",
";",
"}",
"//anotacje dla metod porównujących (equals itp.)",
"$",
"queryCode",
"=",
"'<?php'",
".",
"\"\\n\\n\"",
".",
"'namespace '",
".",
"self",
"::",
"_getNamespace",
"(",
"$",
"tableName",
")",
".",
"'\\QueryHelper'",
".",
"\";\\n\\n\"",
".",
"'/**'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' equals($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' notEquals($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' greater($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' less($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' greaterOrEquals($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' lessOrEquals($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' like($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' notLike($value)'",
".",
"\"\\n\"",
".",
"' * @method \\\\'",
".",
"$",
"queryClassName",
".",
"' between($from, $to)'",
".",
"\"\\n\"",
".",
"$",
"methods",
".",
"' */'",
".",
"\"\\n\"",
".",
"'class '",
".",
"(",
"$",
"className",
"=",
"self",
"::",
"_getNamePrefix",
"(",
"$",
"tableName",
")",
".",
"'QueryField'",
")",
".",
"' extends \\Mmi\\Orm\\QueryHelper\\QueryField'",
".",
"\"\\n{\"",
".",
"\"\\n\\n\"",
".",
"'}'",
".",
"\"\\n\"",
";",
"//zapis pliku",
"file_put_contents",
"(",
"self",
"::",
"_mkdirRecursive",
"(",
"self",
"::",
"_getPathPrefix",
"(",
"$",
"tableName",
")",
".",
"'/QueryHelper'",
")",
".",
"'/'",
".",
"$",
"className",
".",
"'.php'",
",",
"$",
"queryCode",
")",
";",
"}"
] | Tworzy lub aktualizuje pole query
@param string $tableName | [
"Tworzy",
"lub",
"aktualizuje",
"pole",
"query"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Builder.php#L96-L140 |
28,261 | milejko/mmi | src/Mmi/Orm/Builder.php | Builder._getNamePrefix | protected static function _getNamePrefix($tableName)
{
$table = explode('_', $tableName);
$className = '';
//dodawanie kolejnych zagłębień
foreach ($table as $section) {
$className .= ucfirst($section);
}
return $className;
} | php | protected static function _getNamePrefix($tableName)
{
$table = explode('_', $tableName);
$className = '';
//dodawanie kolejnych zagłębień
foreach ($table as $section) {
$className .= ucfirst($section);
}
return $className;
} | [
"protected",
"static",
"function",
"_getNamePrefix",
"(",
"$",
"tableName",
")",
"{",
"$",
"table",
"=",
"explode",
"(",
"'_'",
",",
"$",
"tableName",
")",
";",
"$",
"className",
"=",
"''",
";",
"//dodawanie kolejnych zagłębień",
"foreach",
"(",
"$",
"table",
"as",
"$",
"section",
")",
"{",
"$",
"className",
".=",
"ucfirst",
"(",
"$",
"section",
")",
";",
"}",
"return",
"$",
"className",
";",
"}"
] | Pobiera prefix klasy obiektu
@param string $tableName
@return string
@throws \Mmi\Orm\OrmException | [
"Pobiera",
"prefix",
"klasy",
"obiektu"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Builder.php#L274-L283 |
28,262 | quazardous/ImageStack | src/ImageStack/ImageBackend/HttpImageBackend.php | HttpImageBackend.getImageUrl | protected function getImageUrl(ImagePathInterface $path) {
$url = $path->getPath();
if ($this->getOption('use_prefix', false)) {
$url = rtrim($path->getPrefix(), '/') . '/' . $url;
}
if ($this->getOption('root_url')) {
$url = rtrim($this->getOption('root_url'), '/') . '/' . $url;
}
return filter_var($url, FILTER_SANITIZE_URL);
} | php | protected function getImageUrl(ImagePathInterface $path) {
$url = $path->getPath();
if ($this->getOption('use_prefix', false)) {
$url = rtrim($path->getPrefix(), '/') . '/' . $url;
}
if ($this->getOption('root_url')) {
$url = rtrim($this->getOption('root_url'), '/') . '/' . $url;
}
return filter_var($url, FILTER_SANITIZE_URL);
} | [
"protected",
"function",
"getImageUrl",
"(",
"ImagePathInterface",
"$",
"path",
")",
"{",
"$",
"url",
"=",
"$",
"path",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'use_prefix'",
",",
"false",
")",
")",
"{",
"$",
"url",
"=",
"rtrim",
"(",
"$",
"path",
"->",
"getPrefix",
"(",
")",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"url",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'root_url'",
")",
")",
"{",
"$",
"url",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'root_url'",
")",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"url",
";",
"}",
"return",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_SANITIZE_URL",
")",
";",
"}"
] | Get the image URL.
@param ImagePathInterface $path
@return string | [
"Get",
"the",
"image",
"URL",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageBackend/HttpImageBackend.php#L51-L60 |
28,263 | quazardous/ImageStack | src/ImageStack/ImageBackend/HttpImageBackend.php | HttpImageBackend.httpRequest | protected function httpRequest($url, &$content)
{
$client = new Client([
'allow_redirects' => true,
'curl' => $this->getOption('curl', []),
]);
try {
$response = $client->request('GET', $url);
} catch (RequestException $e) {
if ($e->hasResponse()) {
if ($e->getResponse()->getStatusCode() == 404) {
throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
}
}
if ($this->getOption('intercept_exception', false)) {
throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
} else {
throw new ImageBackendException(sprintf("Cannot read file : %s", $url), ImageBackendException::CANNOT_READ_FILE, $e);
}
}
$content = (string)($response->getBody());
$contentType = $response->getHeader('content-type');
return isset($contentType[0]) ? $contentType[0] : null;
} | php | protected function httpRequest($url, &$content)
{
$client = new Client([
'allow_redirects' => true,
'curl' => $this->getOption('curl', []),
]);
try {
$response = $client->request('GET', $url);
} catch (RequestException $e) {
if ($e->hasResponse()) {
if ($e->getResponse()->getStatusCode() == 404) {
throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
}
}
if ($this->getOption('intercept_exception', false)) {
throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
} else {
throw new ImageBackendException(sprintf("Cannot read file : %s", $url), ImageBackendException::CANNOT_READ_FILE, $e);
}
}
$content = (string)($response->getBody());
$contentType = $response->getHeader('content-type');
return isset($contentType[0]) ? $contentType[0] : null;
} | [
"protected",
"function",
"httpRequest",
"(",
"$",
"url",
",",
"&",
"$",
"content",
")",
"{",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'allow_redirects'",
"=>",
"true",
",",
"'curl'",
"=>",
"$",
"this",
"->",
"getOption",
"(",
"'curl'",
",",
"[",
"]",
")",
",",
"]",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"client",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"RequestException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"hasResponse",
"(",
")",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getStatusCode",
"(",
")",
"==",
"404",
")",
"{",
"throw",
"new",
"ImageNotFoundException",
"(",
"sprintf",
"(",
"'Image Not Found : %s'",
",",
"$",
"url",
")",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'intercept_exception'",
",",
"false",
")",
")",
"{",
"throw",
"new",
"ImageNotFoundException",
"(",
"sprintf",
"(",
"'Image Not Found : %s'",
",",
"$",
"url",
")",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ImageBackendException",
"(",
"sprintf",
"(",
"\"Cannot read file : %s\"",
",",
"$",
"url",
")",
",",
"ImageBackendException",
"::",
"CANNOT_READ_FILE",
",",
"$",
"e",
")",
";",
"}",
"}",
"$",
"content",
"=",
"(",
"string",
")",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"$",
"contentType",
"=",
"$",
"response",
"->",
"getHeader",
"(",
"'content-type'",
")",
";",
"return",
"isset",
"(",
"$",
"contentType",
"[",
"0",
"]",
")",
"?",
"$",
"contentType",
"[",
"0",
"]",
":",
"null",
";",
"}"
] | Perform HTTP query.
@param string $url
@param string &$content
@return string|null MIME type | [
"Perform",
"HTTP",
"query",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageBackend/HttpImageBackend.php#L75-L98 |
28,264 | icewind1991/Streams | src/Path.php | Path.appendDefaultContent | protected function appendDefaultContent($values) {
if (!is_array(current($values))) {
$values = [$this->getProtocol() => $values];
}
$context = stream_context_get_default();
$defaults = stream_context_get_options($context);
foreach ($values as $key => $value) {
$defaults[$key] = $value;
}
stream_context_set_default($defaults);
} | php | protected function appendDefaultContent($values) {
if (!is_array(current($values))) {
$values = [$this->getProtocol() => $values];
}
$context = stream_context_get_default();
$defaults = stream_context_get_options($context);
foreach ($values as $key => $value) {
$defaults[$key] = $value;
}
stream_context_set_default($defaults);
} | [
"protected",
"function",
"appendDefaultContent",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"current",
"(",
"$",
"values",
")",
")",
")",
"{",
"$",
"values",
"=",
"[",
"$",
"this",
"->",
"getProtocol",
"(",
")",
"=>",
"$",
"values",
"]",
";",
"}",
"$",
"context",
"=",
"stream_context_get_default",
"(",
")",
";",
"$",
"defaults",
"=",
"stream_context_get_options",
"(",
"$",
"context",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"defaults",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"stream_context_set_default",
"(",
"$",
"defaults",
")",
";",
"}"
] | Add values to the default stream context
@param array $values | [
"Add",
"values",
"to",
"the",
"default",
"stream",
"context"
] | 6c91d3e390736d9c8c27527f9c5667bc21dca571 | https://github.com/icewind1991/Streams/blob/6c91d3e390736d9c8c27527f9c5667bc21dca571/src/Path.php#L76-L86 |
28,265 | icewind1991/Streams | src/Path.php | Path.unsetDefaultContent | protected function unsetDefaultContent($key) {
$context = stream_context_get_default();
$defaults = stream_context_get_options($context);
unset($defaults[$key]);
stream_context_set_default($defaults);
} | php | protected function unsetDefaultContent($key) {
$context = stream_context_get_default();
$defaults = stream_context_get_options($context);
unset($defaults[$key]);
stream_context_set_default($defaults);
} | [
"protected",
"function",
"unsetDefaultContent",
"(",
"$",
"key",
")",
"{",
"$",
"context",
"=",
"stream_context_get_default",
"(",
")",
";",
"$",
"defaults",
"=",
"stream_context_get_options",
"(",
"$",
"context",
")",
";",
"unset",
"(",
"$",
"defaults",
"[",
"$",
"key",
"]",
")",
";",
"stream_context_set_default",
"(",
"$",
"defaults",
")",
";",
"}"
] | Remove values from the default stream context
@param string $key | [
"Remove",
"values",
"from",
"the",
"default",
"stream",
"context"
] | 6c91d3e390736d9c8c27527f9c5667bc21dca571 | https://github.com/icewind1991/Streams/blob/6c91d3e390736d9c8c27527f9c5667bc21dca571/src/Path.php#L93-L98 |
28,266 | honeybee/honeybee | src/Projection/EntityType.php | EntityType.createMirroredEntity | public function createMirroredEntity(EntityInterface $source_entity, EntityInterface $reference_entity = null)
{
// compile non-list attribute values from the reference entity if available
if ($reference_entity) {
foreach ($this->getAttributes() as $attribute) {
$attribute_name = $attribute->getName();
$attribute_value = $reference_entity->getValue($attribute_name);
$mirrored_values[$attribute_name] = $attribute_value instanceof BaseObjectInterface
? $attribute_value->toArray()
: $attribute_value;
}
}
// override default mirrored values
$mirrored_values['@type'] = $source_entity->getType()->getPrefix();
$mirrored_values['identifier'] = $source_entity->getIdentifier();
if ($source_entity instanceof EntityReferenceInterface) {
$mirrored_values['referenced_identifier'] = $source_entity->getReferencedIdentifier();
}
// collate the required mirrored attributes map
$mirrored_attributes_map = $this->collateAttributes(
function (AttributeInterface $attribute) {
return (bool)$attribute->getOption('mirrored', false) === true;
}
);
// extract our reference path which may be aliased
$path_parts = explode('.', $this->getPrefix());
$type_prefix = end($path_parts);
// iterate the source attributes and extract the required mirrored values
foreach ($mirrored_attributes_map->getKeys() as $mirrored_attribute_path) {
// @todo possible risk of path name collision in greedy regex
$mirrored_attribute_path = preg_replace('#([\w-]+\.)+'.$type_prefix.'\.#', '', $mirrored_attribute_path);
$mirrored_attr_name = explode('.', $mirrored_attribute_path)[0];
$mirrored_attribute = $this->getAttribute($mirrored_attr_name);
$source_attribute_name = $mirrored_attribute->getOption('attribute_alias', $mirrored_attr_name);
$source_attribute_value = $source_entity->getValue($source_attribute_name);
if ($mirrored_attribute instanceof EmbeddedEntityListAttribute) {
foreach ($source_attribute_value as $position => $source_embedded_entity) {
// skip entity mirroring if values already exist since we may traverse over paths repeatedly
// if (!isset($mirrored_values[$mirrored_attr_name][$position])) {
// 2016-09-28 shrink0r: when would this happen. commenting out if check,
// as this seems to work fine without.
$source_embed_prefix = $source_embedded_entity->getType()->getPrefix();
$mirrored_embed_type = $mirrored_attribute instanceof EntityReferenceListAttribute
? $mirrored_attribute->getEmbeddedTypeByReferencedPrefix($source_embed_prefix)
: $mirrored_attribute->getEmbeddedTypeByPrefix($source_embed_prefix);
if ($mirrored_embed_type) {
$reference_embedded_entity = $reference_entity
? $reference_entity->getValue($mirrored_attr_name)
->getEntityByIdentifier($source_embedded_entity->getIdentifier())
: null;
$mirrored_embedded_entity = $mirrored_embed_type->createEntity(
$mirrored_embed_type->createMirroredEntity(
$source_embedded_entity,
$reference_embedded_entity
)->toArray(),
$reference_entity
);
$mirrored_values[$mirrored_attr_name][$position] = $mirrored_embedded_entity->toArray();
}
}
} else {
$mirrored_values[$mirrored_attr_name] = $source_attribute_value instanceof BaseObjectInterface
? $source_attribute_value->toArray()
: $source_attribute_value;
}
}
return $this->createEntity($mirrored_values, $source_entity->getParent());
} | php | public function createMirroredEntity(EntityInterface $source_entity, EntityInterface $reference_entity = null)
{
// compile non-list attribute values from the reference entity if available
if ($reference_entity) {
foreach ($this->getAttributes() as $attribute) {
$attribute_name = $attribute->getName();
$attribute_value = $reference_entity->getValue($attribute_name);
$mirrored_values[$attribute_name] = $attribute_value instanceof BaseObjectInterface
? $attribute_value->toArray()
: $attribute_value;
}
}
// override default mirrored values
$mirrored_values['@type'] = $source_entity->getType()->getPrefix();
$mirrored_values['identifier'] = $source_entity->getIdentifier();
if ($source_entity instanceof EntityReferenceInterface) {
$mirrored_values['referenced_identifier'] = $source_entity->getReferencedIdentifier();
}
// collate the required mirrored attributes map
$mirrored_attributes_map = $this->collateAttributes(
function (AttributeInterface $attribute) {
return (bool)$attribute->getOption('mirrored', false) === true;
}
);
// extract our reference path which may be aliased
$path_parts = explode('.', $this->getPrefix());
$type_prefix = end($path_parts);
// iterate the source attributes and extract the required mirrored values
foreach ($mirrored_attributes_map->getKeys() as $mirrored_attribute_path) {
// @todo possible risk of path name collision in greedy regex
$mirrored_attribute_path = preg_replace('#([\w-]+\.)+'.$type_prefix.'\.#', '', $mirrored_attribute_path);
$mirrored_attr_name = explode('.', $mirrored_attribute_path)[0];
$mirrored_attribute = $this->getAttribute($mirrored_attr_name);
$source_attribute_name = $mirrored_attribute->getOption('attribute_alias', $mirrored_attr_name);
$source_attribute_value = $source_entity->getValue($source_attribute_name);
if ($mirrored_attribute instanceof EmbeddedEntityListAttribute) {
foreach ($source_attribute_value as $position => $source_embedded_entity) {
// skip entity mirroring if values already exist since we may traverse over paths repeatedly
// if (!isset($mirrored_values[$mirrored_attr_name][$position])) {
// 2016-09-28 shrink0r: when would this happen. commenting out if check,
// as this seems to work fine without.
$source_embed_prefix = $source_embedded_entity->getType()->getPrefix();
$mirrored_embed_type = $mirrored_attribute instanceof EntityReferenceListAttribute
? $mirrored_attribute->getEmbeddedTypeByReferencedPrefix($source_embed_prefix)
: $mirrored_attribute->getEmbeddedTypeByPrefix($source_embed_prefix);
if ($mirrored_embed_type) {
$reference_embedded_entity = $reference_entity
? $reference_entity->getValue($mirrored_attr_name)
->getEntityByIdentifier($source_embedded_entity->getIdentifier())
: null;
$mirrored_embedded_entity = $mirrored_embed_type->createEntity(
$mirrored_embed_type->createMirroredEntity(
$source_embedded_entity,
$reference_embedded_entity
)->toArray(),
$reference_entity
);
$mirrored_values[$mirrored_attr_name][$position] = $mirrored_embedded_entity->toArray();
}
}
} else {
$mirrored_values[$mirrored_attr_name] = $source_attribute_value instanceof BaseObjectInterface
? $source_attribute_value->toArray()
: $source_attribute_value;
}
}
return $this->createEntity($mirrored_values, $source_entity->getParent());
} | [
"public",
"function",
"createMirroredEntity",
"(",
"EntityInterface",
"$",
"source_entity",
",",
"EntityInterface",
"$",
"reference_entity",
"=",
"null",
")",
"{",
"// compile non-list attribute values from the reference entity if available",
"if",
"(",
"$",
"reference_entity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attribute",
")",
"{",
"$",
"attribute_name",
"=",
"$",
"attribute",
"->",
"getName",
"(",
")",
";",
"$",
"attribute_value",
"=",
"$",
"reference_entity",
"->",
"getValue",
"(",
"$",
"attribute_name",
")",
";",
"$",
"mirrored_values",
"[",
"$",
"attribute_name",
"]",
"=",
"$",
"attribute_value",
"instanceof",
"BaseObjectInterface",
"?",
"$",
"attribute_value",
"->",
"toArray",
"(",
")",
":",
"$",
"attribute_value",
";",
"}",
"}",
"// override default mirrored values",
"$",
"mirrored_values",
"[",
"'@type'",
"]",
"=",
"$",
"source_entity",
"->",
"getType",
"(",
")",
"->",
"getPrefix",
"(",
")",
";",
"$",
"mirrored_values",
"[",
"'identifier'",
"]",
"=",
"$",
"source_entity",
"->",
"getIdentifier",
"(",
")",
";",
"if",
"(",
"$",
"source_entity",
"instanceof",
"EntityReferenceInterface",
")",
"{",
"$",
"mirrored_values",
"[",
"'referenced_identifier'",
"]",
"=",
"$",
"source_entity",
"->",
"getReferencedIdentifier",
"(",
")",
";",
"}",
"// collate the required mirrored attributes map",
"$",
"mirrored_attributes_map",
"=",
"$",
"this",
"->",
"collateAttributes",
"(",
"function",
"(",
"AttributeInterface",
"$",
"attribute",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"attribute",
"->",
"getOption",
"(",
"'mirrored'",
",",
"false",
")",
"===",
"true",
";",
"}",
")",
";",
"// extract our reference path which may be aliased",
"$",
"path_parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"this",
"->",
"getPrefix",
"(",
")",
")",
";",
"$",
"type_prefix",
"=",
"end",
"(",
"$",
"path_parts",
")",
";",
"// iterate the source attributes and extract the required mirrored values",
"foreach",
"(",
"$",
"mirrored_attributes_map",
"->",
"getKeys",
"(",
")",
"as",
"$",
"mirrored_attribute_path",
")",
"{",
"// @todo possible risk of path name collision in greedy regex",
"$",
"mirrored_attribute_path",
"=",
"preg_replace",
"(",
"'#([\\w-]+\\.)+'",
".",
"$",
"type_prefix",
".",
"'\\.#'",
",",
"''",
",",
"$",
"mirrored_attribute_path",
")",
";",
"$",
"mirrored_attr_name",
"=",
"explode",
"(",
"'.'",
",",
"$",
"mirrored_attribute_path",
")",
"[",
"0",
"]",
";",
"$",
"mirrored_attribute",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"mirrored_attr_name",
")",
";",
"$",
"source_attribute_name",
"=",
"$",
"mirrored_attribute",
"->",
"getOption",
"(",
"'attribute_alias'",
",",
"$",
"mirrored_attr_name",
")",
";",
"$",
"source_attribute_value",
"=",
"$",
"source_entity",
"->",
"getValue",
"(",
"$",
"source_attribute_name",
")",
";",
"if",
"(",
"$",
"mirrored_attribute",
"instanceof",
"EmbeddedEntityListAttribute",
")",
"{",
"foreach",
"(",
"$",
"source_attribute_value",
"as",
"$",
"position",
"=>",
"$",
"source_embedded_entity",
")",
"{",
"// skip entity mirroring if values already exist since we may traverse over paths repeatedly",
"// if (!isset($mirrored_values[$mirrored_attr_name][$position])) {",
"// 2016-09-28 shrink0r: when would this happen. commenting out if check,",
"// as this seems to work fine without.",
"$",
"source_embed_prefix",
"=",
"$",
"source_embedded_entity",
"->",
"getType",
"(",
")",
"->",
"getPrefix",
"(",
")",
";",
"$",
"mirrored_embed_type",
"=",
"$",
"mirrored_attribute",
"instanceof",
"EntityReferenceListAttribute",
"?",
"$",
"mirrored_attribute",
"->",
"getEmbeddedTypeByReferencedPrefix",
"(",
"$",
"source_embed_prefix",
")",
":",
"$",
"mirrored_attribute",
"->",
"getEmbeddedTypeByPrefix",
"(",
"$",
"source_embed_prefix",
")",
";",
"if",
"(",
"$",
"mirrored_embed_type",
")",
"{",
"$",
"reference_embedded_entity",
"=",
"$",
"reference_entity",
"?",
"$",
"reference_entity",
"->",
"getValue",
"(",
"$",
"mirrored_attr_name",
")",
"->",
"getEntityByIdentifier",
"(",
"$",
"source_embedded_entity",
"->",
"getIdentifier",
"(",
")",
")",
":",
"null",
";",
"$",
"mirrored_embedded_entity",
"=",
"$",
"mirrored_embed_type",
"->",
"createEntity",
"(",
"$",
"mirrored_embed_type",
"->",
"createMirroredEntity",
"(",
"$",
"source_embedded_entity",
",",
"$",
"reference_embedded_entity",
")",
"->",
"toArray",
"(",
")",
",",
"$",
"reference_entity",
")",
";",
"$",
"mirrored_values",
"[",
"$",
"mirrored_attr_name",
"]",
"[",
"$",
"position",
"]",
"=",
"$",
"mirrored_embedded_entity",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"mirrored_values",
"[",
"$",
"mirrored_attr_name",
"]",
"=",
"$",
"source_attribute_value",
"instanceof",
"BaseObjectInterface",
"?",
"$",
"source_attribute_value",
"->",
"toArray",
"(",
")",
":",
"$",
"source_attribute_value",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"createEntity",
"(",
"$",
"mirrored_values",
",",
"$",
"source_entity",
"->",
"getParent",
"(",
")",
")",
";",
"}"
] | Create a new entity from the recursively mirrorred values of a given source entity, while
optionally merging attribute values from a given reference entity.
@param EntityInterface $source_entity
@param EntityInterface $reference_entity
@return EntityInterface | [
"Create",
"a",
"new",
"entity",
"from",
"the",
"recursively",
"mirrorred",
"values",
"of",
"a",
"given",
"source",
"entity",
"while",
"optionally",
"merging",
"attribute",
"values",
"from",
"a",
"given",
"reference",
"entity",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Projection/EntityType.php#L24-L96 |
28,267 | peakphp/framework | src/Backpack/AppBuilder.php | AppBuilder.triggerKernelError | private function triggerKernelError()
{
$msgErrorSuffix = 'setting will be ignored because Kernel had been set previously.';
if (isset($this->container)) {
trigger_error('Container '.$msgErrorSuffix);
}
if (isset($this->env)) {
trigger_error('Env '.$msgErrorSuffix);
}
if (isset($this->kernelClass)) {
trigger_error('Kernel class '.$msgErrorSuffix);
}
} | php | private function triggerKernelError()
{
$msgErrorSuffix = 'setting will be ignored because Kernel had been set previously.';
if (isset($this->container)) {
trigger_error('Container '.$msgErrorSuffix);
}
if (isset($this->env)) {
trigger_error('Env '.$msgErrorSuffix);
}
if (isset($this->kernelClass)) {
trigger_error('Kernel class '.$msgErrorSuffix);
}
} | [
"private",
"function",
"triggerKernelError",
"(",
")",
"{",
"$",
"msgErrorSuffix",
"=",
"'setting will be ignored because Kernel had been set previously.'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"container",
")",
")",
"{",
"trigger_error",
"(",
"'Container '",
".",
"$",
"msgErrorSuffix",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"env",
")",
")",
"{",
"trigger_error",
"(",
"'Env '",
".",
"$",
"msgErrorSuffix",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"kernelClass",
")",
")",
"{",
"trigger_error",
"(",
"'Kernel class '",
".",
"$",
"msgErrorSuffix",
")",
";",
"}",
"}"
] | Trigger an error with arguments container and env when a kernel has been set previously | [
"Trigger",
"an",
"error",
"with",
"arguments",
"container",
"and",
"env",
"when",
"a",
"kernel",
"has",
"been",
"set",
"previously"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Backpack/AppBuilder.php#L220-L232 |
28,268 | peakphp/framework | src/Collection/CollectionFlattener.php | CollectionFlattener.separator | public function separator(string $sep): CollectionFlattener
{
if (mb_strlen($sep) != 1 || $sep === '*') {
throw new Exception(__CLASS__.': Separator must be 1 character and cannot be an asterisk (*)');
}
$this->separator = $sep;
return $this;
} | php | public function separator(string $sep): CollectionFlattener
{
if (mb_strlen($sep) != 1 || $sep === '*') {
throw new Exception(__CLASS__.': Separator must be 1 character and cannot be an asterisk (*)');
}
$this->separator = $sep;
return $this;
} | [
"public",
"function",
"separator",
"(",
"string",
"$",
"sep",
")",
":",
"CollectionFlattener",
"{",
"if",
"(",
"mb_strlen",
"(",
"$",
"sep",
")",
"!=",
"1",
"||",
"$",
"sep",
"===",
"'*'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__CLASS__",
".",
"': Separator must be 1 character and cannot be an asterisk (*)'",
")",
";",
"}",
"$",
"this",
"->",
"separator",
"=",
"$",
"sep",
";",
"return",
"$",
"this",
";",
"}"
] | Change keys separators
@param string $sep
@return $this
@throws Exception | [
"Change",
"keys",
"separators"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/CollectionFlattener.php#L47-L54 |
28,269 | peakphp/framework | src/Collection/CollectionFlattener.php | CollectionFlattener.flatKeys | public function flatKeys(array $keys): array
{
$this->search = $keys;
return $this->flatCollection($this->collection->toArray());
} | php | public function flatKeys(array $keys): array
{
$this->search = $keys;
return $this->flatCollection($this->collection->toArray());
} | [
"public",
"function",
"flatKeys",
"(",
"array",
"$",
"keys",
")",
":",
"array",
"{",
"$",
"this",
"->",
"search",
"=",
"$",
"keys",
";",
"return",
"$",
"this",
"->",
"flatCollection",
"(",
"$",
"this",
"->",
"collection",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] | Flat multiple keys names
@param array $keys
@return array | [
"Flat",
"multiple",
"keys",
"names"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/CollectionFlattener.php#L81-L85 |
28,270 | peakphp/framework | src/Collection/CollectionFlattener.php | CollectionFlattener.flatCollection | protected function flatCollection(array $data, string $prefix = null, array $flat_data = []): array
{
foreach ($data as $key => $val) {
if ($prefix !== null) {
$key = $prefix.$this->separator.$key;
}
$skip_key = $this->skipKey($key);
if (is_array($val)) {
$flat_data = array_merge(
$flat_data,
$this->flatCollection($val, (string) $key)
);
continue;
}
if ($skip_key) {
continue;
}
$flat_data[$key] = $val;
}
return $flat_data;
} | php | protected function flatCollection(array $data, string $prefix = null, array $flat_data = []): array
{
foreach ($data as $key => $val) {
if ($prefix !== null) {
$key = $prefix.$this->separator.$key;
}
$skip_key = $this->skipKey($key);
if (is_array($val)) {
$flat_data = array_merge(
$flat_data,
$this->flatCollection($val, (string) $key)
);
continue;
}
if ($skip_key) {
continue;
}
$flat_data[$key] = $val;
}
return $flat_data;
} | [
"protected",
"function",
"flatCollection",
"(",
"array",
"$",
"data",
",",
"string",
"$",
"prefix",
"=",
"null",
",",
"array",
"$",
"flat_data",
"=",
"[",
"]",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"prefix",
"!==",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"prefix",
".",
"$",
"this",
"->",
"separator",
".",
"$",
"key",
";",
"}",
"$",
"skip_key",
"=",
"$",
"this",
"->",
"skipKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"flat_data",
"=",
"array_merge",
"(",
"$",
"flat_data",
",",
"$",
"this",
"->",
"flatCollection",
"(",
"$",
"val",
",",
"(",
"string",
")",
"$",
"key",
")",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"skip_key",
")",
"{",
"continue",
";",
"}",
"$",
"flat_data",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"return",
"$",
"flat_data",
";",
"}"
] | Flat collection recursively to one level key,val array
@param array $data
@param string|null $prefix
@param array $flat_data
@return array | [
"Flat",
"collection",
"recursively",
"to",
"one",
"level",
"key",
"val",
"array"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/CollectionFlattener.php#L94-L119 |
28,271 | milejko/mmi | src/Mmi/OptionObject.php | OptionObject.setOptions | public function setOptions(array $options = [], $reset = false)
{
//jeśli reset
if ($reset) {
$this->_options = [];
}
//dopełnianie tabeli opcji
foreach ($options as $key => $value) {
$this->setOption($key, $value);
}
return $this;
} | php | public function setOptions(array $options = [], $reset = false)
{
//jeśli reset
if ($reset) {
$this->_options = [];
}
//dopełnianie tabeli opcji
foreach ($options as $key => $value) {
$this->setOption($key, $value);
}
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"reset",
"=",
"false",
")",
"{",
"//jeśli reset",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"this",
"->",
"_options",
"=",
"[",
"]",
";",
"}",
"//dopełnianie tabeli opcji",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Ustawia wszystkie opcje na podstawie tabeli
@param array $options tabela opcji
@param boolean $reset usuwa poprzednie wartości (domyślnie nie)
@return self | [
"Ustawia",
"wszystkie",
"opcje",
"na",
"podstawie",
"tabeli"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/OptionObject.php#L83-L94 |
28,272 | milejko/mmi | src/Mmi/Mvc/ViewHelper/Navigation.php | Navigation._modifyBreadcrumbData | protected function _modifyBreadcrumbData($index, $field, $value)
{
//brak wartości
if (!$value) {
return;
}
//ustawienie wartości
$this->_breadcrumbsData[$index][$field] = $value;
} | php | protected function _modifyBreadcrumbData($index, $field, $value)
{
//brak wartości
if (!$value) {
return;
}
//ustawienie wartości
$this->_breadcrumbsData[$index][$field] = $value;
} | [
"protected",
"function",
"_modifyBreadcrumbData",
"(",
"$",
"index",
",",
"$",
"field",
",",
"$",
"value",
")",
"{",
"//brak wartości",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
";",
"}",
"//ustawienie wartości",
"$",
"this",
"->",
"_breadcrumbsData",
"[",
"$",
"index",
"]",
"[",
"$",
"field",
"]",
"=",
"$",
"value",
";",
"}"
] | Ustawia pole w danych breadcrumba
@param string $index
@param string $field
@param string $value | [
"Ustawia",
"pole",
"w",
"danych",
"breadcrumba"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/Navigation.php#L151-L159 |
28,273 | milejko/mmi | src/Mmi/Mvc/ViewHelper/Navigation.php | Navigation.modifyLastBreadcrumb | public function modifyLastBreadcrumb($label, $uri = null, $title = null, $description = null)
{
//modyfikacja + przebudowa
return $this->modifyBreadcrumb(count($this->_breadcrumbsData) - 1, $label, $uri, $title, $description);
} | php | public function modifyLastBreadcrumb($label, $uri = null, $title = null, $description = null)
{
//modyfikacja + przebudowa
return $this->modifyBreadcrumb(count($this->_breadcrumbsData) - 1, $label, $uri, $title, $description);
} | [
"public",
"function",
"modifyLastBreadcrumb",
"(",
"$",
"label",
",",
"$",
"uri",
"=",
"null",
",",
"$",
"title",
"=",
"null",
",",
"$",
"description",
"=",
"null",
")",
"{",
"//modyfikacja + przebudowa",
"return",
"$",
"this",
"->",
"modifyBreadcrumb",
"(",
"count",
"(",
"$",
"this",
"->",
"_breadcrumbsData",
")",
"-",
"1",
",",
"$",
"label",
",",
"$",
"uri",
",",
"$",
"title",
",",
"$",
"description",
")",
";",
"}"
] | Modyfikuje ostatni breadcrumb
@param string $label etykieta
@param string $uri URL
@param string $title tytuł
@param string $description opis
@return \Mmi\Mvc\ViewHelper\Navigation | [
"Modyfikuje",
"ostatni",
"breadcrumb"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/Navigation.php#L521-L525 |
28,274 | milejko/mmi | src/Mmi/Mvc/ViewHelper/Navigation.php | Navigation.appendBreadcrumb | public function appendBreadcrumb($label, $uri = null, $title = null, $description = null)
{
//append, przebudowa, zwraca siebie
return $this->createBreadcrumb($label, $uri, $title, $description, false);
} | php | public function appendBreadcrumb($label, $uri = null, $title = null, $description = null)
{
//append, przebudowa, zwraca siebie
return $this->createBreadcrumb($label, $uri, $title, $description, false);
} | [
"public",
"function",
"appendBreadcrumb",
"(",
"$",
"label",
",",
"$",
"uri",
"=",
"null",
",",
"$",
"title",
"=",
"null",
",",
"$",
"description",
"=",
"null",
")",
"{",
"//append, przebudowa, zwraca siebie",
"return",
"$",
"this",
"->",
"createBreadcrumb",
"(",
"$",
"label",
",",
"$",
"uri",
",",
"$",
"title",
",",
"$",
"description",
",",
"false",
")",
";",
"}"
] | Dodaje breadcrumb na koniec
@param string $label etykieta
@param string $uri URL
@param string $title tytuł
@param string $description opis
@return \Mmi\Mvc\ViewHelper\Navigation | [
"Dodaje",
"breadcrumb",
"na",
"koniec"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/Navigation.php#L559-L563 |
28,275 | milejko/mmi | src/Mmi/Mvc/ViewHelper/Navigation.php | Navigation.removeLastBreadcrumb | public function removeLastBreadcrumb()
{
//obliczanie indeksu ostatniego breadcrumba
$index = count($this->_breadcrumbsData) - 1;
//brak breadcrumba
if (!isset($this->_breadcrumbsData[$index])) {
return $this;
}
//usuwanie
unset($this->_breadcrumbsData[$index]);
//przebudowa breadcrumbów
return $this->_buildBreadcrumbs();
} | php | public function removeLastBreadcrumb()
{
//obliczanie indeksu ostatniego breadcrumba
$index = count($this->_breadcrumbsData) - 1;
//brak breadcrumba
if (!isset($this->_breadcrumbsData[$index])) {
return $this;
}
//usuwanie
unset($this->_breadcrumbsData[$index]);
//przebudowa breadcrumbów
return $this->_buildBreadcrumbs();
} | [
"public",
"function",
"removeLastBreadcrumb",
"(",
")",
"{",
"//obliczanie indeksu ostatniego breadcrumba",
"$",
"index",
"=",
"count",
"(",
"$",
"this",
"->",
"_breadcrumbsData",
")",
"-",
"1",
";",
"//brak breadcrumba",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_breadcrumbsData",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"//usuwanie",
"unset",
"(",
"$",
"this",
"->",
"_breadcrumbsData",
"[",
"$",
"index",
"]",
")",
";",
"//przebudowa breadcrumbów",
"return",
"$",
"this",
"->",
"_buildBreadcrumbs",
"(",
")",
";",
"}"
] | Usuwa ostatni breadcrumb
@return \Mmi\Mvc\ViewHelper\Navigation | [
"Usuwa",
"ostatni",
"breadcrumb"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/Navigation.php#L583-L595 |
28,276 | peakphp/framework | src/Http/Stack.php | Stack.handleStack | protected function handleStack(\Peak\Blueprint\Http\Stack $stack, ServerRequestInterface $request): ResponseInterface
{
$stack->setParent($this);
return $stack->handle($request);
} | php | protected function handleStack(\Peak\Blueprint\Http\Stack $stack, ServerRequestInterface $request): ResponseInterface
{
$stack->setParent($this);
return $stack->handle($request);
} | [
"protected",
"function",
"handleStack",
"(",
"\\",
"Peak",
"\\",
"Blueprint",
"\\",
"Http",
"\\",
"Stack",
"$",
"stack",
",",
"ServerRequestInterface",
"$",
"request",
")",
":",
"ResponseInterface",
"{",
"$",
"stack",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"return",
"$",
"stack",
"->",
"handle",
"(",
"$",
"request",
")",
";",
"}"
] | Handle a child stack
@param \Peak\Blueprint\Http\Stack $stack
@param ServerRequestInterface $request
@return ResponseInterface | [
"Handle",
"a",
"child",
"stack"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Http/Stack.php#L135-L139 |
28,277 | peakphp/framework | src/Http/Stack.php | Stack.returnResponse | protected function returnResponse(ResponseInterface $response): ResponseInterface
{
$this->nextHandler = null;
reset($this->handlers);
return $response;
} | php | protected function returnResponse(ResponseInterface $response): ResponseInterface
{
$this->nextHandler = null;
reset($this->handlers);
return $response;
} | [
"protected",
"function",
"returnResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"ResponseInterface",
"{",
"$",
"this",
"->",
"nextHandler",
"=",
"null",
";",
"reset",
"(",
"$",
"this",
"->",
"handlers",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Reset the stack before returning the response,
This allow the stack to be re-handle without throwing exception
@param ResponseInterface $response
@return ResponseInterface | [
"Reset",
"the",
"stack",
"before",
"returning",
"the",
"response",
"This",
"allow",
"the",
"stack",
"to",
"be",
"re",
"-",
"handle",
"without",
"throwing",
"exception"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Http/Stack.php#L147-L152 |
28,278 | milejko/mmi | src/Mmi/Form/Element/ElementAbstract.php | ElementAbstract._getHtmlOptions | protected final function _getHtmlOptions()
{
$validators = $this->getValidators();
//jeśli istnieją validatory dodajemy klasę validate
if (!empty($validators)) {
$this->addClass('validate');
}
$html = '';
//iteracja po opcjach do HTML
foreach ($this->getOptions() as $key => $value) {
//ignorowanie niemożliwych do wypisania
if (!is_string($value) && !is_numeric($value)) {
continue;
}
$html .= $key . '="' . str_replace('"', '"', $value) . '" ';
}
//zwrot html
return $html;
} | php | protected final function _getHtmlOptions()
{
$validators = $this->getValidators();
//jeśli istnieją validatory dodajemy klasę validate
if (!empty($validators)) {
$this->addClass('validate');
}
$html = '';
//iteracja po opcjach do HTML
foreach ($this->getOptions() as $key => $value) {
//ignorowanie niemożliwych do wypisania
if (!is_string($value) && !is_numeric($value)) {
continue;
}
$html .= $key . '="' . str_replace('"', '"', $value) . '" ';
}
//zwrot html
return $html;
} | [
"protected",
"final",
"function",
"_getHtmlOptions",
"(",
")",
"{",
"$",
"validators",
"=",
"$",
"this",
"->",
"getValidators",
"(",
")",
";",
"//jeśli istnieją validatory dodajemy klasę validate",
"if",
"(",
"!",
"empty",
"(",
"$",
"validators",
")",
")",
"{",
"$",
"this",
"->",
"addClass",
"(",
"'validate'",
")",
";",
"}",
"$",
"html",
"=",
"''",
";",
"//iteracja po opcjach do HTML",
"foreach",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//ignorowanie niemożliwych do wypisania",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"continue",
";",
"}",
"$",
"html",
".=",
"$",
"key",
".",
"'=\"'",
".",
"str_replace",
"(",
"'\"'",
",",
"'"'",
",",
"$",
"value",
")",
".",
"'\" '",
";",
"}",
"//zwrot html",
"return",
"$",
"html",
";",
"}"
] | Buduje opcje HTML
@return string | [
"Buduje",
"opcje",
"HTML"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Form/Element/ElementAbstract.php#L391-L409 |
28,279 | milejko/mmi | src/Mmi/Form/Element/ElementAbstract.php | ElementAbstract.fetchDescription | public final function fetchDescription()
{
//brak opisu
if (!$this->getDescription()) {
return;
}
//element do widoku
\Mmi\App\FrontController::getInstance()->getView()->_element = $this;
//render szablonu
return \Mmi\App\FrontController::getInstance()->getView()->renderTemplate(static::TEMPLATE_DESCRIPTION);
} | php | public final function fetchDescription()
{
//brak opisu
if (!$this->getDescription()) {
return;
}
//element do widoku
\Mmi\App\FrontController::getInstance()->getView()->_element = $this;
//render szablonu
return \Mmi\App\FrontController::getInstance()->getView()->renderTemplate(static::TEMPLATE_DESCRIPTION);
} | [
"public",
"final",
"function",
"fetchDescription",
"(",
")",
"{",
"//brak opisu",
"if",
"(",
"!",
"$",
"this",
"->",
"getDescription",
"(",
")",
")",
"{",
"return",
";",
"}",
"//element do widoku",
"\\",
"Mmi",
"\\",
"App",
"\\",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getView",
"(",
")",
"->",
"_element",
"=",
"$",
"this",
";",
"//render szablonu",
"return",
"\\",
"Mmi",
"\\",
"App",
"\\",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getView",
"(",
")",
"->",
"renderTemplate",
"(",
"static",
"::",
"TEMPLATE_DESCRIPTION",
")",
";",
"}"
] | Buduje opis pola
@return string | [
"Buduje",
"opis",
"pola"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Form/Element/ElementAbstract.php#L479-L489 |
28,280 | honeybee/honeybee | src/Model/Aggregate/Entity.php | Entity.applyEmbeddedEntityEvent | protected function applyEmbeddedEntityEvent(
EmbeddedEntityEventInterface $embedded_entity_event,
$auto_commit = true
) {
$attribute_name = $embedded_entity_event->getParentAttributeName();
$embedded_entity_list = $this->getValue($attribute_name);
if ($embedded_entity_event instanceof EmbeddedEntityAddedEvent) {
$embedded_type = $this->getEmbeddedEntityTypeFor(
$attribute_name,
$embedded_entity_event->getEmbeddedEntityType()
);
$embedded_entity = $embedded_type->createEntity([], $this);
$embedded_entity_list->push($embedded_entity);
} elseif ($embedded_entity_event instanceof EmbeddedEntityRemovedEvent) {
$embedded_entity = $this->getEmbeddedEntityFor(
$attribute_name,
$embedded_entity_event->getEmbeddedEntityIdentifier()
);
$embedded_entity_list->removeItem($embedded_entity);
if (!$embedded_entity) {
error_log(__METHOD__ . " - Embedded entity already was removed.");
return $embedded_entity_event;
}
} elseif ($embedded_entity_event instanceof EmbeddedEntityModifiedEvent) {
$embedded_entity = $this->getEmbeddedEntityFor(
$attribute_name,
$embedded_entity_event->getEmbeddedEntityIdentifier()
);
if (!$embedded_entity) {
throw new RuntimeError(
'Unable to resolve embedded-entity for embed-event: ' .
json_encode($embedded_entity_event->toArray()) .
"\nAR-Id: " . $this->getIdentifier()
);
}
if ($embedded_entity_list->getKey($embedded_entity) !== $embedded_entity_event->getPosition()) {
$embedded_entity_list->moveTo($embedded_entity_event->getPosition(), $embedded_entity);
}
} else {
throw new RuntimeError('Cannot resolve embedded entity');
}
return $embedded_entity->applyEvent($embedded_entity_event, $auto_commit);
} | php | protected function applyEmbeddedEntityEvent(
EmbeddedEntityEventInterface $embedded_entity_event,
$auto_commit = true
) {
$attribute_name = $embedded_entity_event->getParentAttributeName();
$embedded_entity_list = $this->getValue($attribute_name);
if ($embedded_entity_event instanceof EmbeddedEntityAddedEvent) {
$embedded_type = $this->getEmbeddedEntityTypeFor(
$attribute_name,
$embedded_entity_event->getEmbeddedEntityType()
);
$embedded_entity = $embedded_type->createEntity([], $this);
$embedded_entity_list->push($embedded_entity);
} elseif ($embedded_entity_event instanceof EmbeddedEntityRemovedEvent) {
$embedded_entity = $this->getEmbeddedEntityFor(
$attribute_name,
$embedded_entity_event->getEmbeddedEntityIdentifier()
);
$embedded_entity_list->removeItem($embedded_entity);
if (!$embedded_entity) {
error_log(__METHOD__ . " - Embedded entity already was removed.");
return $embedded_entity_event;
}
} elseif ($embedded_entity_event instanceof EmbeddedEntityModifiedEvent) {
$embedded_entity = $this->getEmbeddedEntityFor(
$attribute_name,
$embedded_entity_event->getEmbeddedEntityIdentifier()
);
if (!$embedded_entity) {
throw new RuntimeError(
'Unable to resolve embedded-entity for embed-event: ' .
json_encode($embedded_entity_event->toArray()) .
"\nAR-Id: " . $this->getIdentifier()
);
}
if ($embedded_entity_list->getKey($embedded_entity) !== $embedded_entity_event->getPosition()) {
$embedded_entity_list->moveTo($embedded_entity_event->getPosition(), $embedded_entity);
}
} else {
throw new RuntimeError('Cannot resolve embedded entity');
}
return $embedded_entity->applyEvent($embedded_entity_event, $auto_commit);
} | [
"protected",
"function",
"applyEmbeddedEntityEvent",
"(",
"EmbeddedEntityEventInterface",
"$",
"embedded_entity_event",
",",
"$",
"auto_commit",
"=",
"true",
")",
"{",
"$",
"attribute_name",
"=",
"$",
"embedded_entity_event",
"->",
"getParentAttributeName",
"(",
")",
";",
"$",
"embedded_entity_list",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"attribute_name",
")",
";",
"if",
"(",
"$",
"embedded_entity_event",
"instanceof",
"EmbeddedEntityAddedEvent",
")",
"{",
"$",
"embedded_type",
"=",
"$",
"this",
"->",
"getEmbeddedEntityTypeFor",
"(",
"$",
"attribute_name",
",",
"$",
"embedded_entity_event",
"->",
"getEmbeddedEntityType",
"(",
")",
")",
";",
"$",
"embedded_entity",
"=",
"$",
"embedded_type",
"->",
"createEntity",
"(",
"[",
"]",
",",
"$",
"this",
")",
";",
"$",
"embedded_entity_list",
"->",
"push",
"(",
"$",
"embedded_entity",
")",
";",
"}",
"elseif",
"(",
"$",
"embedded_entity_event",
"instanceof",
"EmbeddedEntityRemovedEvent",
")",
"{",
"$",
"embedded_entity",
"=",
"$",
"this",
"->",
"getEmbeddedEntityFor",
"(",
"$",
"attribute_name",
",",
"$",
"embedded_entity_event",
"->",
"getEmbeddedEntityIdentifier",
"(",
")",
")",
";",
"$",
"embedded_entity_list",
"->",
"removeItem",
"(",
"$",
"embedded_entity",
")",
";",
"if",
"(",
"!",
"$",
"embedded_entity",
")",
"{",
"error_log",
"(",
"__METHOD__",
".",
"\" - Embedded entity already was removed.\"",
")",
";",
"return",
"$",
"embedded_entity_event",
";",
"}",
"}",
"elseif",
"(",
"$",
"embedded_entity_event",
"instanceof",
"EmbeddedEntityModifiedEvent",
")",
"{",
"$",
"embedded_entity",
"=",
"$",
"this",
"->",
"getEmbeddedEntityFor",
"(",
"$",
"attribute_name",
",",
"$",
"embedded_entity_event",
"->",
"getEmbeddedEntityIdentifier",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"embedded_entity",
")",
"{",
"throw",
"new",
"RuntimeError",
"(",
"'Unable to resolve embedded-entity for embed-event: '",
".",
"json_encode",
"(",
"$",
"embedded_entity_event",
"->",
"toArray",
"(",
")",
")",
".",
"\"\\nAR-Id: \"",
".",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"embedded_entity_list",
"->",
"getKey",
"(",
"$",
"embedded_entity",
")",
"!==",
"$",
"embedded_entity_event",
"->",
"getPosition",
"(",
")",
")",
"{",
"$",
"embedded_entity_list",
"->",
"moveTo",
"(",
"$",
"embedded_entity_event",
"->",
"getPosition",
"(",
")",
",",
"$",
"embedded_entity",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"RuntimeError",
"(",
"'Cannot resolve embedded entity'",
")",
";",
"}",
"return",
"$",
"embedded_entity",
"->",
"applyEvent",
"(",
"$",
"embedded_entity_event",
",",
"$",
"auto_commit",
")",
";",
"}"
] | Apply the given aggregate-event to it's corresponding aggregate and return the resulting source-event.
@param EmbeddedEntityEventInterface $embedded_entity_event
@param boolean $auto_commit
@return EmbeddedEntityEventInterface | [
"Apply",
"the",
"given",
"aggregate",
"-",
"event",
"to",
"it",
"s",
"corresponding",
"aggregate",
"and",
"return",
"the",
"resulting",
"source",
"-",
"event",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/Entity.php#L23-L67 |
28,281 | honeybee/honeybee | src/Model/Aggregate/Entity.php | Entity.getEmbeddedEntityTypeFor | protected function getEmbeddedEntityTypeFor($attribute_name, $embedded_type_prefix)
{
$attribute = $this->getType()->getAttribute($attribute_name);
return $attribute->getEmbeddedTypeByPrefix($embedded_type_prefix);
} | php | protected function getEmbeddedEntityTypeFor($attribute_name, $embedded_type_prefix)
{
$attribute = $this->getType()->getAttribute($attribute_name);
return $attribute->getEmbeddedTypeByPrefix($embedded_type_prefix);
} | [
"protected",
"function",
"getEmbeddedEntityTypeFor",
"(",
"$",
"attribute_name",
",",
"$",
"embedded_type_prefix",
")",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getAttribute",
"(",
"$",
"attribute_name",
")",
";",
"return",
"$",
"attribute",
"->",
"getEmbeddedTypeByPrefix",
"(",
"$",
"embedded_type_prefix",
")",
";",
"}"
] | Return the AggregateType that is referred to by the given command.
@param string $attribute_name
@param string $embedded_type_prefix
@return EntityTypeInterface | [
"Return",
"the",
"AggregateType",
"that",
"is",
"referred",
"to",
"by",
"the",
"given",
"command",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/Entity.php#L77-L82 |
28,282 | honeybee/honeybee | src/Model/Aggregate/Entity.php | Entity.getEmbeddedEntityFor | protected function getEmbeddedEntityFor($attribute_name, $embedded_entity_id)
{
$found_entity = null;
foreach ($this->getValue($attribute_name) as $embedded_entity) {
if ($embedded_entity->getIdentifier() === $embedded_entity_id) {
$found_entity = $embedded_entity;
break;
}
}
return $found_entity;
} | php | protected function getEmbeddedEntityFor($attribute_name, $embedded_entity_id)
{
$found_entity = null;
foreach ($this->getValue($attribute_name) as $embedded_entity) {
if ($embedded_entity->getIdentifier() === $embedded_entity_id) {
$found_entity = $embedded_entity;
break;
}
}
return $found_entity;
} | [
"protected",
"function",
"getEmbeddedEntityFor",
"(",
"$",
"attribute_name",
",",
"$",
"embedded_entity_id",
")",
"{",
"$",
"found_entity",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"getValue",
"(",
"$",
"attribute_name",
")",
"as",
"$",
"embedded_entity",
")",
"{",
"if",
"(",
"$",
"embedded_entity",
"->",
"getIdentifier",
"(",
")",
"===",
"$",
"embedded_entity_id",
")",
"{",
"$",
"found_entity",
"=",
"$",
"embedded_entity",
";",
"break",
";",
"}",
"}",
"return",
"$",
"found_entity",
";",
"}"
] | Return the Aggregate that is referred to by the given command.
@param string $attribute_name
@param string $embedded_entity_id
@return EntityInterface | [
"Return",
"the",
"Aggregate",
"that",
"is",
"referred",
"to",
"by",
"the",
"given",
"command",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/Entity.php#L92-L103 |
28,283 | honeybee/honeybee | src/Model/Aggregate/Entity.php | Entity.getRecordedChanges | protected function getRecordedChanges()
{
$recorded_changes = [];
foreach ($this->getChanges() as $value_changed_event) {
$attribute = $this->getType()->getAttribute($value_changed_event->getAttributeName());
if ($attribute instanceof EmbeddedEntityListAttribute) {
continue;
}
$recorded_changes[$attribute->getName()] = $value_changed_event->getNewValue();
}
return $recorded_changes;
} | php | protected function getRecordedChanges()
{
$recorded_changes = [];
foreach ($this->getChanges() as $value_changed_event) {
$attribute = $this->getType()->getAttribute($value_changed_event->getAttributeName());
if ($attribute instanceof EmbeddedEntityListAttribute) {
continue;
}
$recorded_changes[$attribute->getName()] = $value_changed_event->getNewValue();
}
return $recorded_changes;
} | [
"protected",
"function",
"getRecordedChanges",
"(",
")",
"{",
"$",
"recorded_changes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getChanges",
"(",
")",
"as",
"$",
"value_changed_event",
")",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getAttribute",
"(",
"$",
"value_changed_event",
"->",
"getAttributeName",
"(",
")",
")",
";",
"if",
"(",
"$",
"attribute",
"instanceof",
"EmbeddedEntityListAttribute",
")",
"{",
"continue",
";",
"}",
"$",
"recorded_changes",
"[",
"$",
"attribute",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"value_changed_event",
"->",
"getNewValue",
"(",
")",
";",
"}",
"return",
"$",
"recorded_changes",
";",
"}"
] | Returns a list of changes that actually took place, while processing a given event.
@return array | [
"Returns",
"a",
"list",
"of",
"changes",
"that",
"actually",
"took",
"place",
"while",
"processing",
"a",
"given",
"event",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/Entity.php#L110-L123 |
28,284 | honeybee/honeybee | src/Common/Util/ArrayToolkit.php | ArrayToolkit.mergeScalarSafe | public static function mergeScalarSafe(array &$first, array &$second)
{
$merged = $first;
foreach ($second as $key => &$value) {
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
$merged[$key] = self::mergeScalarSafe($merged[$key], $value);
} else {
$merged[$key] = $value;
}
}
return $merged;
} | php | public static function mergeScalarSafe(array &$first, array &$second)
{
$merged = $first;
foreach ($second as $key => &$value) {
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
$merged[$key] = self::mergeScalarSafe($merged[$key], $value);
} else {
$merged[$key] = $value;
}
}
return $merged;
} | [
"public",
"static",
"function",
"mergeScalarSafe",
"(",
"array",
"&",
"$",
"first",
",",
"array",
"&",
"$",
"second",
")",
"{",
"$",
"merged",
"=",
"$",
"first",
";",
"foreach",
"(",
"$",
"second",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"isset",
"(",
"$",
"merged",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"merged",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"merged",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"mergeScalarSafe",
"(",
"$",
"merged",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"merged",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"merged",
";",
"}"
] | Merges the given second array over the first one similar to the PHP internal
array_merge_recursive method, but does not change scalar values into arrays
when duplicate keys occur.
@param array $first first or default array
@param array $second array to merge over the first array
@return array merged result with scalar values still being scalar | [
"Merges",
"the",
"given",
"second",
"array",
"over",
"the",
"first",
"one",
"similar",
"to",
"the",
"PHP",
"internal",
"array_merge_recursive",
"method",
"but",
"does",
"not",
"change",
"scalar",
"values",
"into",
"arrays",
"when",
"duplicate",
"keys",
"occur",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Common/Util/ArrayToolkit.php#L62-L75 |
28,285 | honeybee/honeybee | src/Projection/EmbeddedEntityType.php | EmbeddedEntityType.getDefaultAttributes | public function getDefaultAttributes()
{
$default_attributes = [
new UuidAttribute('identifier', $this, [], $this->getParentAttribute())
];
$default_attributes_map = new AttributeMap($default_attributes);
return parent::getDefaultAttributes()->append($default_attributes_map);
} | php | public function getDefaultAttributes()
{
$default_attributes = [
new UuidAttribute('identifier', $this, [], $this->getParentAttribute())
];
$default_attributes_map = new AttributeMap($default_attributes);
return parent::getDefaultAttributes()->append($default_attributes_map);
} | [
"public",
"function",
"getDefaultAttributes",
"(",
")",
"{",
"$",
"default_attributes",
"=",
"[",
"new",
"UuidAttribute",
"(",
"'identifier'",
",",
"$",
"this",
",",
"[",
"]",
",",
"$",
"this",
"->",
"getParentAttribute",
"(",
")",
")",
"]",
";",
"$",
"default_attributes_map",
"=",
"new",
"AttributeMap",
"(",
"$",
"default_attributes",
")",
";",
"return",
"parent",
"::",
"getDefaultAttributes",
"(",
")",
"->",
"append",
"(",
"$",
"default_attributes_map",
")",
";",
"}"
] | Returns the default attributes that are initially added to a aggregate_type upon creation.
@return AttributeMap A map of AttributeInterface implementations. | [
"Returns",
"the",
"default",
"attributes",
"that",
"are",
"initially",
"added",
"to",
"a",
"aggregate_type",
"upon",
"creation",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Projection/EmbeddedEntityType.php#L15-L23 |
28,286 | milejko/mmi | src/Mmi/Mvc/ViewHelper/HeadAbstract.php | HeadAbstract._getLocationTimestamp | protected function _getLocationTimestamp($location)
{
$cacheKey = 'mmi-head-ts-' . md5($location);
$cache = $this->view->getCache();
if (null !== $cache && (null !== ($ts = $cache->load($cacheKey)))) {
return $ts;
}
//obliczanie timestampu
$ts = file_exists($path = BASE_PATH . '/web' . $location) ? filemtime($path) : 0;
if (null !== $cache) {
$cache->save($ts, $cacheKey, 0);
}
return $ts;
} | php | protected function _getLocationTimestamp($location)
{
$cacheKey = 'mmi-head-ts-' . md5($location);
$cache = $this->view->getCache();
if (null !== $cache && (null !== ($ts = $cache->load($cacheKey)))) {
return $ts;
}
//obliczanie timestampu
$ts = file_exists($path = BASE_PATH . '/web' . $location) ? filemtime($path) : 0;
if (null !== $cache) {
$cache->save($ts, $cacheKey, 0);
}
return $ts;
} | [
"protected",
"function",
"_getLocationTimestamp",
"(",
"$",
"location",
")",
"{",
"$",
"cacheKey",
"=",
"'mmi-head-ts-'",
".",
"md5",
"(",
"$",
"location",
")",
";",
"$",
"cache",
"=",
"$",
"this",
"->",
"view",
"->",
"getCache",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"cache",
"&&",
"(",
"null",
"!==",
"(",
"$",
"ts",
"=",
"$",
"cache",
"->",
"load",
"(",
"$",
"cacheKey",
")",
")",
")",
")",
"{",
"return",
"$",
"ts",
";",
"}",
"//obliczanie timestampu",
"$",
"ts",
"=",
"file_exists",
"(",
"$",
"path",
"=",
"BASE_PATH",
".",
"'/web'",
".",
"$",
"location",
")",
"?",
"filemtime",
"(",
"$",
"path",
")",
":",
"0",
";",
"if",
"(",
"null",
"!==",
"$",
"cache",
")",
"{",
"$",
"cache",
"->",
"save",
"(",
"$",
"ts",
",",
"$",
"cacheKey",
",",
"0",
")",
";",
"}",
"return",
"$",
"ts",
";",
"}"
] | Pobiera CRC dla danego zasobu lokalnego
@param string $location adres zasobu
@return string | [
"Pobiera",
"CRC",
"dla",
"danego",
"zasobu",
"lokalnego"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadAbstract.php#L21-L34 |
28,287 | milejko/mmi | src/Mmi/Mvc/ViewHelper/HeadAbstract.php | HeadAbstract._getPublicSrc | protected function _getPublicSrc($src)
{
return $this->view->cdn ? $this->view->cdn . $src : $this->view->baseUrl . $src;
} | php | protected function _getPublicSrc($src)
{
return $this->view->cdn ? $this->view->cdn . $src : $this->view->baseUrl . $src;
} | [
"protected",
"function",
"_getPublicSrc",
"(",
"$",
"src",
")",
"{",
"return",
"$",
"this",
"->",
"view",
"->",
"cdn",
"?",
"$",
"this",
"->",
"view",
"->",
"cdn",
".",
"$",
"src",
":",
"$",
"this",
"->",
"view",
"->",
"baseUrl",
".",
"$",
"src",
";",
"}"
] | Zwraca publiczny src z baseUrl i CDN
@param string $src
@return string | [
"Zwraca",
"publiczny",
"src",
"z",
"baseUrl",
"i",
"CDN"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadAbstract.php#L41-L44 |
28,288 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.reconstituteFrom | public function reconstituteFrom(AggregateRootEventList $history)
{
if (!$this->history->isEmpty()) {
throw new ReconstitutionError('Trying to reconstitute history on an already initialized aggregate-root.');
}
$first = true;
foreach ($history as $past_event) {
if ($first) {
$first = false;
if (!$past_event instanceof AggregateRootCreatedEvent) {
throw new ReconstitutionError(
sprintf(
'The first event given within a history to reconstitute from must be by the type of "%s".' .
' Instead "%s" was given for AR %s.',
AggregateRootCreatedEvent::CLASS,
get_class($past_event),
$past_event->getAggregateRootIdentifier()
)
);
}
}
$this->history->push($this->applyEvent($past_event, false));
}
return $this->isValid();
} | php | public function reconstituteFrom(AggregateRootEventList $history)
{
if (!$this->history->isEmpty()) {
throw new ReconstitutionError('Trying to reconstitute history on an already initialized aggregate-root.');
}
$first = true;
foreach ($history as $past_event) {
if ($first) {
$first = false;
if (!$past_event instanceof AggregateRootCreatedEvent) {
throw new ReconstitutionError(
sprintf(
'The first event given within a history to reconstitute from must be by the type of "%s".' .
' Instead "%s" was given for AR %s.',
AggregateRootCreatedEvent::CLASS,
get_class($past_event),
$past_event->getAggregateRootIdentifier()
)
);
}
}
$this->history->push($this->applyEvent($past_event, false));
}
return $this->isValid();
} | [
"public",
"function",
"reconstituteFrom",
"(",
"AggregateRootEventList",
"$",
"history",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"history",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"ReconstitutionError",
"(",
"'Trying to reconstitute history on an already initialized aggregate-root.'",
")",
";",
"}",
"$",
"first",
"=",
"true",
";",
"foreach",
"(",
"$",
"history",
"as",
"$",
"past_event",
")",
"{",
"if",
"(",
"$",
"first",
")",
"{",
"$",
"first",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"past_event",
"instanceof",
"AggregateRootCreatedEvent",
")",
"{",
"throw",
"new",
"ReconstitutionError",
"(",
"sprintf",
"(",
"'The first event given within a history to reconstitute from must be by the type of \"%s\".'",
".",
"' Instead \"%s\" was given for AR %s.'",
",",
"AggregateRootCreatedEvent",
"::",
"CLASS",
",",
"get_class",
"(",
"$",
"past_event",
")",
",",
"$",
"past_event",
"->",
"getAggregateRootIdentifier",
"(",
")",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"history",
"->",
"push",
"(",
"$",
"this",
"->",
"applyEvent",
"(",
"$",
"past_event",
",",
"false",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"isValid",
"(",
")",
";",
"}"
] | Rebuild an aggregate-root's latest state based on the given audit log.
@param AggregateRootEventList $history | [
"Rebuild",
"an",
"aggregate",
"-",
"root",
"s",
"latest",
"state",
"based",
"on",
"the",
"given",
"audit",
"log",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L184-L211 |
28,289 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.create | public function create(CreateAggregateRootCommand $create_command, StateMachineInterface $state_machine)
{
$initial_data = $this->createInitialData($create_command, $state_machine);
$created_event = $this->processCommand(
$create_command,
[ 'aggregate_root_identifier' => $initial_data['identifier'], 'data' => $initial_data ]
);
if (!$created_event instanceof AggregateRootCreatedEvent) {
throw new UnsupportedEventTypeError(
sprintf(
'Corrupt event type detected. Events that reflect entity creation must descend from %s.',
AggregateRootCreatedEvent::CLASS
)
);
}
$this->applyEvent($created_event);
} | php | public function create(CreateAggregateRootCommand $create_command, StateMachineInterface $state_machine)
{
$initial_data = $this->createInitialData($create_command, $state_machine);
$created_event = $this->processCommand(
$create_command,
[ 'aggregate_root_identifier' => $initial_data['identifier'], 'data' => $initial_data ]
);
if (!$created_event instanceof AggregateRootCreatedEvent) {
throw new UnsupportedEventTypeError(
sprintf(
'Corrupt event type detected. Events that reflect entity creation must descend from %s.',
AggregateRootCreatedEvent::CLASS
)
);
}
$this->applyEvent($created_event);
} | [
"public",
"function",
"create",
"(",
"CreateAggregateRootCommand",
"$",
"create_command",
",",
"StateMachineInterface",
"$",
"state_machine",
")",
"{",
"$",
"initial_data",
"=",
"$",
"this",
"->",
"createInitialData",
"(",
"$",
"create_command",
",",
"$",
"state_machine",
")",
";",
"$",
"created_event",
"=",
"$",
"this",
"->",
"processCommand",
"(",
"$",
"create_command",
",",
"[",
"'aggregate_root_identifier'",
"=>",
"$",
"initial_data",
"[",
"'identifier'",
"]",
",",
"'data'",
"=>",
"$",
"initial_data",
"]",
")",
";",
"if",
"(",
"!",
"$",
"created_event",
"instanceof",
"AggregateRootCreatedEvent",
")",
"{",
"throw",
"new",
"UnsupportedEventTypeError",
"(",
"sprintf",
"(",
"'Corrupt event type detected. Events that reflect entity creation must descend from %s.'",
",",
"AggregateRootCreatedEvent",
"::",
"CLASS",
")",
")",
";",
"}",
"$",
"this",
"->",
"applyEvent",
"(",
"$",
"created_event",
")",
";",
"}"
] | Start a new life-cycle for the current aggregate-root.
@param CreateAggregateRootCommand $create_command
@param StateMachineInterface $state_machine | [
"Start",
"a",
"new",
"life",
"-",
"cycle",
"for",
"the",
"current",
"aggregate",
"-",
"root",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L219-L238 |
28,290 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.modify | public function modify(ModifyAggregateRootCommand $modify_command)
{
$this->guardCommandPreConditions($modify_command);
$modified_event = $this->processCommand(
$modify_command,
[ 'data' => $modify_command->getValues() ]
);
if (!$modified_event instanceof AggregateRootModifiedEvent) {
throw new UnsupportedEventTypeError(
sprintf(
'Corrupt event type detected. Events that reflect entity modification must descend from %s.',
AggregateRootModifiedEvent::CLASS
)
);
}
$this->applyEvent($modified_event);
} | php | public function modify(ModifyAggregateRootCommand $modify_command)
{
$this->guardCommandPreConditions($modify_command);
$modified_event = $this->processCommand(
$modify_command,
[ 'data' => $modify_command->getValues() ]
);
if (!$modified_event instanceof AggregateRootModifiedEvent) {
throw new UnsupportedEventTypeError(
sprintf(
'Corrupt event type detected. Events that reflect entity modification must descend from %s.',
AggregateRootModifiedEvent::CLASS
)
);
}
$this->applyEvent($modified_event);
} | [
"public",
"function",
"modify",
"(",
"ModifyAggregateRootCommand",
"$",
"modify_command",
")",
"{",
"$",
"this",
"->",
"guardCommandPreConditions",
"(",
"$",
"modify_command",
")",
";",
"$",
"modified_event",
"=",
"$",
"this",
"->",
"processCommand",
"(",
"$",
"modify_command",
",",
"[",
"'data'",
"=>",
"$",
"modify_command",
"->",
"getValues",
"(",
")",
"]",
")",
";",
"if",
"(",
"!",
"$",
"modified_event",
"instanceof",
"AggregateRootModifiedEvent",
")",
"{",
"throw",
"new",
"UnsupportedEventTypeError",
"(",
"sprintf",
"(",
"'Corrupt event type detected. Events that reflect entity modification must descend from %s.'",
",",
"AggregateRootModifiedEvent",
"::",
"CLASS",
")",
")",
";",
"}",
"$",
"this",
"->",
"applyEvent",
"(",
"$",
"modified_event",
")",
";",
"}"
] | Modify the state of the current aggregate-root.
@param ModifyAggregateRootCommand $modify_command | [
"Modify",
"the",
"state",
"of",
"the",
"current",
"aggregate",
"-",
"root",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L245-L264 |
28,291 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.createInitialData | protected function createInitialData(
CreateAggregateRootCommand $create_command,
StateMachineInterface $state_machine
) {
$type = $this->getType();
$type_prefix = $type->getPrefix();
$create_data = $create_command->getValues();
$create_data[self::OBJECT_TYPE] = $type_prefix;
$value_or_default = function ($key, $default) use ($create_data) {
return isset($create_data[$key]) ? $create_data[$key] : $default;
};
$uuid = $value_or_default('uuid', $type->getAttribute('uuid')->getDefaultValue());
$language = $value_or_default('language', $type->getAttribute('language')->getDefaultValue());
$version = $value_or_default('version', 1);
$identifier = sprintf('%s-%s-%s-%s', $type_prefix, $uuid, $language, $version);
$default_attributes = $type->getDefaultAttributes();
$non_default_attributes = $type->getAttributes()->filter(
function (AttributeInterface $attribute) use ($default_attributes) {
return !$attribute instanceof EmbeddedEntityListAttribute
&& !array_key_exists($attribute->getName(), $default_attributes);
}
);
$default_values = [];
foreach ($non_default_attributes as $attribute_name => $attribute) {
if (!$attribute->createValueHolder(true)->isNull()) {
$default_values[$attribute_name] = $attribute->getDefaultValue();
}
}
return array_merge(
$default_values,
$create_data,
[
'identifier' => $identifier,
'uuid' => $uuid,
'language' => $language,
'version' => $version,
'workflow_state' => $state_machine->getInitialState()->getName(),
'workflow_parameters' => []
]
);
} | php | protected function createInitialData(
CreateAggregateRootCommand $create_command,
StateMachineInterface $state_machine
) {
$type = $this->getType();
$type_prefix = $type->getPrefix();
$create_data = $create_command->getValues();
$create_data[self::OBJECT_TYPE] = $type_prefix;
$value_or_default = function ($key, $default) use ($create_data) {
return isset($create_data[$key]) ? $create_data[$key] : $default;
};
$uuid = $value_or_default('uuid', $type->getAttribute('uuid')->getDefaultValue());
$language = $value_or_default('language', $type->getAttribute('language')->getDefaultValue());
$version = $value_or_default('version', 1);
$identifier = sprintf('%s-%s-%s-%s', $type_prefix, $uuid, $language, $version);
$default_attributes = $type->getDefaultAttributes();
$non_default_attributes = $type->getAttributes()->filter(
function (AttributeInterface $attribute) use ($default_attributes) {
return !$attribute instanceof EmbeddedEntityListAttribute
&& !array_key_exists($attribute->getName(), $default_attributes);
}
);
$default_values = [];
foreach ($non_default_attributes as $attribute_name => $attribute) {
if (!$attribute->createValueHolder(true)->isNull()) {
$default_values[$attribute_name] = $attribute->getDefaultValue();
}
}
return array_merge(
$default_values,
$create_data,
[
'identifier' => $identifier,
'uuid' => $uuid,
'language' => $language,
'version' => $version,
'workflow_state' => $state_machine->getInitialState()->getName(),
'workflow_parameters' => []
]
);
} | [
"protected",
"function",
"createInitialData",
"(",
"CreateAggregateRootCommand",
"$",
"create_command",
",",
"StateMachineInterface",
"$",
"state_machine",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"$",
"type_prefix",
"=",
"$",
"type",
"->",
"getPrefix",
"(",
")",
";",
"$",
"create_data",
"=",
"$",
"create_command",
"->",
"getValues",
"(",
")",
";",
"$",
"create_data",
"[",
"self",
"::",
"OBJECT_TYPE",
"]",
"=",
"$",
"type_prefix",
";",
"$",
"value_or_default",
"=",
"function",
"(",
"$",
"key",
",",
"$",
"default",
")",
"use",
"(",
"$",
"create_data",
")",
"{",
"return",
"isset",
"(",
"$",
"create_data",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"create_data",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}",
";",
"$",
"uuid",
"=",
"$",
"value_or_default",
"(",
"'uuid'",
",",
"$",
"type",
"->",
"getAttribute",
"(",
"'uuid'",
")",
"->",
"getDefaultValue",
"(",
")",
")",
";",
"$",
"language",
"=",
"$",
"value_or_default",
"(",
"'language'",
",",
"$",
"type",
"->",
"getAttribute",
"(",
"'language'",
")",
"->",
"getDefaultValue",
"(",
")",
")",
";",
"$",
"version",
"=",
"$",
"value_or_default",
"(",
"'version'",
",",
"1",
")",
";",
"$",
"identifier",
"=",
"sprintf",
"(",
"'%s-%s-%s-%s'",
",",
"$",
"type_prefix",
",",
"$",
"uuid",
",",
"$",
"language",
",",
"$",
"version",
")",
";",
"$",
"default_attributes",
"=",
"$",
"type",
"->",
"getDefaultAttributes",
"(",
")",
";",
"$",
"non_default_attributes",
"=",
"$",
"type",
"->",
"getAttributes",
"(",
")",
"->",
"filter",
"(",
"function",
"(",
"AttributeInterface",
"$",
"attribute",
")",
"use",
"(",
"$",
"default_attributes",
")",
"{",
"return",
"!",
"$",
"attribute",
"instanceof",
"EmbeddedEntityListAttribute",
"&&",
"!",
"array_key_exists",
"(",
"$",
"attribute",
"->",
"getName",
"(",
")",
",",
"$",
"default_attributes",
")",
";",
"}",
")",
";",
"$",
"default_values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"non_default_attributes",
"as",
"$",
"attribute_name",
"=>",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"$",
"attribute",
"->",
"createValueHolder",
"(",
"true",
")",
"->",
"isNull",
"(",
")",
")",
"{",
"$",
"default_values",
"[",
"$",
"attribute_name",
"]",
"=",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"}",
"return",
"array_merge",
"(",
"$",
"default_values",
",",
"$",
"create_data",
",",
"[",
"'identifier'",
"=>",
"$",
"identifier",
",",
"'uuid'",
"=>",
"$",
"uuid",
",",
"'language'",
"=>",
"$",
"language",
",",
"'version'",
"=>",
"$",
"version",
",",
"'workflow_state'",
"=>",
"$",
"state_machine",
"->",
"getInitialState",
"(",
")",
"->",
"getName",
"(",
")",
",",
"'workflow_parameters'",
"=>",
"[",
"]",
"]",
")",
";",
"}"
] | Create the data used to initialize a new aggregate-root.
@param CreateAggregateRootCommand $create_command
@param StateMachineInterface $state_machine
@return array | [
"Create",
"the",
"data",
"used",
"to",
"initialize",
"a",
"new",
"aggregate",
"-",
"root",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L350-L396 |
28,292 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.processCommand | protected function processCommand(AggregateRootTypeCommandInterface $command, array $custom_event_state = [])
{
$event_class = $command->getEventClass();
$default_event_state = [
'metadata' => $command->getMetadata(),
'uuid' => $command->getUuid(),
'seq_number' => $this->getRevision() + 1,
'aggregate_root_type' => $command->getAggregateRootType()
];
if ($command instanceof AggregateRootCommandInterface) {
$default_event_state['aggregate_root_identifier'] = $command->getAggregateRootIdentifier();
} elseif (!isset($custom_event_state['aggregate_root_identifier'])) {
throw new MissingIdentifierError(
'Missing required "aggregate_root_identifier" attribute for building domain-event.'
);
}
$embedded_entity_events = new EmbeddedEntityEventList();
foreach ($command->getEmbeddedEntityCommands() as $embedded_command) {
$embedded_entity_events->push($this->processEmbeddedEntityCommand($embedded_command));
}
$default_event_state['embedded_entity_events'] = $embedded_entity_events;
return new $event_class(array_merge($custom_event_state, $default_event_state));
} | php | protected function processCommand(AggregateRootTypeCommandInterface $command, array $custom_event_state = [])
{
$event_class = $command->getEventClass();
$default_event_state = [
'metadata' => $command->getMetadata(),
'uuid' => $command->getUuid(),
'seq_number' => $this->getRevision() + 1,
'aggregate_root_type' => $command->getAggregateRootType()
];
if ($command instanceof AggregateRootCommandInterface) {
$default_event_state['aggregate_root_identifier'] = $command->getAggregateRootIdentifier();
} elseif (!isset($custom_event_state['aggregate_root_identifier'])) {
throw new MissingIdentifierError(
'Missing required "aggregate_root_identifier" attribute for building domain-event.'
);
}
$embedded_entity_events = new EmbeddedEntityEventList();
foreach ($command->getEmbeddedEntityCommands() as $embedded_command) {
$embedded_entity_events->push($this->processEmbeddedEntityCommand($embedded_command));
}
$default_event_state['embedded_entity_events'] = $embedded_entity_events;
return new $event_class(array_merge($custom_event_state, $default_event_state));
} | [
"protected",
"function",
"processCommand",
"(",
"AggregateRootTypeCommandInterface",
"$",
"command",
",",
"array",
"$",
"custom_event_state",
"=",
"[",
"]",
")",
"{",
"$",
"event_class",
"=",
"$",
"command",
"->",
"getEventClass",
"(",
")",
";",
"$",
"default_event_state",
"=",
"[",
"'metadata'",
"=>",
"$",
"command",
"->",
"getMetadata",
"(",
")",
",",
"'uuid'",
"=>",
"$",
"command",
"->",
"getUuid",
"(",
")",
",",
"'seq_number'",
"=>",
"$",
"this",
"->",
"getRevision",
"(",
")",
"+",
"1",
",",
"'aggregate_root_type'",
"=>",
"$",
"command",
"->",
"getAggregateRootType",
"(",
")",
"]",
";",
"if",
"(",
"$",
"command",
"instanceof",
"AggregateRootCommandInterface",
")",
"{",
"$",
"default_event_state",
"[",
"'aggregate_root_identifier'",
"]",
"=",
"$",
"command",
"->",
"getAggregateRootIdentifier",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"custom_event_state",
"[",
"'aggregate_root_identifier'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingIdentifierError",
"(",
"'Missing required \"aggregate_root_identifier\" attribute for building domain-event.'",
")",
";",
"}",
"$",
"embedded_entity_events",
"=",
"new",
"EmbeddedEntityEventList",
"(",
")",
";",
"foreach",
"(",
"$",
"command",
"->",
"getEmbeddedEntityCommands",
"(",
")",
"as",
"$",
"embedded_command",
")",
"{",
"$",
"embedded_entity_events",
"->",
"push",
"(",
"$",
"this",
"->",
"processEmbeddedEntityCommand",
"(",
"$",
"embedded_command",
")",
")",
";",
"}",
"$",
"default_event_state",
"[",
"'embedded_entity_events'",
"]",
"=",
"$",
"embedded_entity_events",
";",
"return",
"new",
"$",
"event_class",
"(",
"array_merge",
"(",
"$",
"custom_event_state",
",",
"$",
"default_event_state",
")",
")",
";",
"}"
] | Process the given command, hence build the corresponding aggregate-root-event.
@param AggregateRootTypeCommandInterface $command
@param array $custom_event_state
@return AggregateRootEventInterface | [
"Process",
"the",
"given",
"command",
"hence",
"build",
"the",
"corresponding",
"aggregate",
"-",
"root",
"-",
"event",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L496-L520 |
28,293 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.processEmbeddedEntityCommand | protected function processEmbeddedEntityCommand(CommandInterface $command, array $custom_event_state = [])
{
$event_class = $command->getEventClass();
$attribute_name = $command->getParentAttributeName();
$event_state = [
'parent_attribute_name' => $attribute_name,
'embedded_entity_type' => $command->getEmbeddedEntityType()
];
if ($command instanceof RemoveEmbeddedEntityCommand) {
$event_state['embedded_entity_identifier'] = $command->getEmbeddedEntityIdentifier();
} elseif ($command instanceof AddEmbeddedEntityCommand) {
$create_data = $command->getValues();
if (!isset($create_data['identifier'])) {
$create_data['identifier'] = UuidAttribute::generateVersion4();
}
$event_state = array_merge(
$event_state,
[
'data' => $create_data,
'position' => $command->getPosition(),
'embedded_entity_identifier' => $create_data['identifier']
]
);
} elseif ($command instanceof ModifyEmbeddedEntityCommand) {
$event_state = array_merge(
$event_state,
[
'data' => $command->getValues(),
'position' => $command->getPosition(),
'embedded_entity_identifier' => $command->getEmbeddedEntityIdentifier()
]
);
}
$embedded_entity_events = new EmbeddedEntityEventList();
foreach ($command->getEmbeddedEntityCommands() as $embedded_command) {
$embedded_entity_events->push($this->processEmbeddedEntityCommand($embedded_command));
}
$event_state['embedded_entity_events'] = $embedded_entity_events;
return new $event_class($event_state);
} | php | protected function processEmbeddedEntityCommand(CommandInterface $command, array $custom_event_state = [])
{
$event_class = $command->getEventClass();
$attribute_name = $command->getParentAttributeName();
$event_state = [
'parent_attribute_name' => $attribute_name,
'embedded_entity_type' => $command->getEmbeddedEntityType()
];
if ($command instanceof RemoveEmbeddedEntityCommand) {
$event_state['embedded_entity_identifier'] = $command->getEmbeddedEntityIdentifier();
} elseif ($command instanceof AddEmbeddedEntityCommand) {
$create_data = $command->getValues();
if (!isset($create_data['identifier'])) {
$create_data['identifier'] = UuidAttribute::generateVersion4();
}
$event_state = array_merge(
$event_state,
[
'data' => $create_data,
'position' => $command->getPosition(),
'embedded_entity_identifier' => $create_data['identifier']
]
);
} elseif ($command instanceof ModifyEmbeddedEntityCommand) {
$event_state = array_merge(
$event_state,
[
'data' => $command->getValues(),
'position' => $command->getPosition(),
'embedded_entity_identifier' => $command->getEmbeddedEntityIdentifier()
]
);
}
$embedded_entity_events = new EmbeddedEntityEventList();
foreach ($command->getEmbeddedEntityCommands() as $embedded_command) {
$embedded_entity_events->push($this->processEmbeddedEntityCommand($embedded_command));
}
$event_state['embedded_entity_events'] = $embedded_entity_events;
return new $event_class($event_state);
} | [
"protected",
"function",
"processEmbeddedEntityCommand",
"(",
"CommandInterface",
"$",
"command",
",",
"array",
"$",
"custom_event_state",
"=",
"[",
"]",
")",
"{",
"$",
"event_class",
"=",
"$",
"command",
"->",
"getEventClass",
"(",
")",
";",
"$",
"attribute_name",
"=",
"$",
"command",
"->",
"getParentAttributeName",
"(",
")",
";",
"$",
"event_state",
"=",
"[",
"'parent_attribute_name'",
"=>",
"$",
"attribute_name",
",",
"'embedded_entity_type'",
"=>",
"$",
"command",
"->",
"getEmbeddedEntityType",
"(",
")",
"]",
";",
"if",
"(",
"$",
"command",
"instanceof",
"RemoveEmbeddedEntityCommand",
")",
"{",
"$",
"event_state",
"[",
"'embedded_entity_identifier'",
"]",
"=",
"$",
"command",
"->",
"getEmbeddedEntityIdentifier",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"command",
"instanceof",
"AddEmbeddedEntityCommand",
")",
"{",
"$",
"create_data",
"=",
"$",
"command",
"->",
"getValues",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"create_data",
"[",
"'identifier'",
"]",
")",
")",
"{",
"$",
"create_data",
"[",
"'identifier'",
"]",
"=",
"UuidAttribute",
"::",
"generateVersion4",
"(",
")",
";",
"}",
"$",
"event_state",
"=",
"array_merge",
"(",
"$",
"event_state",
",",
"[",
"'data'",
"=>",
"$",
"create_data",
",",
"'position'",
"=>",
"$",
"command",
"->",
"getPosition",
"(",
")",
",",
"'embedded_entity_identifier'",
"=>",
"$",
"create_data",
"[",
"'identifier'",
"]",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"command",
"instanceof",
"ModifyEmbeddedEntityCommand",
")",
"{",
"$",
"event_state",
"=",
"array_merge",
"(",
"$",
"event_state",
",",
"[",
"'data'",
"=>",
"$",
"command",
"->",
"getValues",
"(",
")",
",",
"'position'",
"=>",
"$",
"command",
"->",
"getPosition",
"(",
")",
",",
"'embedded_entity_identifier'",
"=>",
"$",
"command",
"->",
"getEmbeddedEntityIdentifier",
"(",
")",
"]",
")",
";",
"}",
"$",
"embedded_entity_events",
"=",
"new",
"EmbeddedEntityEventList",
"(",
")",
";",
"foreach",
"(",
"$",
"command",
"->",
"getEmbeddedEntityCommands",
"(",
")",
"as",
"$",
"embedded_command",
")",
"{",
"$",
"embedded_entity_events",
"->",
"push",
"(",
"$",
"this",
"->",
"processEmbeddedEntityCommand",
"(",
"$",
"embedded_command",
")",
")",
";",
"}",
"$",
"event_state",
"[",
"'embedded_entity_events'",
"]",
"=",
"$",
"embedded_entity_events",
";",
"return",
"new",
"$",
"event_class",
"(",
"$",
"event_state",
")",
";",
"}"
] | Process the given aggregate-command, hence build the corresponding aggregate-event.
@param CommandInterface $command
@param array $custom_event_state
@return EmbeddedEntityEventInterface | [
"Process",
"the",
"given",
"aggregate",
"-",
"command",
"hence",
"build",
"the",
"corresponding",
"aggregate",
"-",
"event",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L530-L572 |
28,294 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.applyEvent | protected function applyEvent(AggregateRootEventInterface $event, $auto_commit = true)
{
$this->guardEventPreConditions($event);
if (!$this->setValues($event->getData())) {
$errors = [];
foreach ($this->getValidationResults() as $validation_result) {
foreach ($validation_result->getViolatedRules() as $violated_rule) {
foreach ($violated_rule->getIncidents() as $incident) {
$errors[] = PHP_EOL . $validation_result->getSUbject()->getName() .
' - ' . $violated_rule->getName() .
' > ' . $incident->getName() . ': ' . print_r($incident->getParameters(), true);
}
}
}
throw new InvalidStateError(
sprintf(
"Aggregate-root is in an invalid state after applying %s.\nErrors:%s",
get_class($event),
implode(PHP_EOL, $errors)
)
);
}
$embedded_entity_events = new EmbeddedEntityEventList();
foreach ($event->getEmbeddedEntityEvents() as $embedded_entity_event) {
$embedded_entity_events->push($this->applyEmbeddedEntityEvent($embedded_entity_event));
}
$source_event = null;
if ($auto_commit) {
$recorded_changes = $this->getRecordedChanges();
if (!empty($recorded_changes) || !$embedded_entity_events->isEmpty()) {
$source_event = $event->createCopyWith(
[ 'data' => $recorded_changes, 'embedded_entity_events' => $embedded_entity_events ]
);
$this->uncomitted_events_list->push($source_event);
$this->history->push($source_event);
}
} else {
$source_event = $event;
}
if ($source_event) {
$this->setValue('revision', $source_event->getSeqNumber());
$this->markClean();
} else {
//$notice = 'Applied event %s for %s did not trigger any state changes, so it is being dropped ...';
//error_log(sprintf($notice, $event, $this));
}
return $source_event;
} | php | protected function applyEvent(AggregateRootEventInterface $event, $auto_commit = true)
{
$this->guardEventPreConditions($event);
if (!$this->setValues($event->getData())) {
$errors = [];
foreach ($this->getValidationResults() as $validation_result) {
foreach ($validation_result->getViolatedRules() as $violated_rule) {
foreach ($violated_rule->getIncidents() as $incident) {
$errors[] = PHP_EOL . $validation_result->getSUbject()->getName() .
' - ' . $violated_rule->getName() .
' > ' . $incident->getName() . ': ' . print_r($incident->getParameters(), true);
}
}
}
throw new InvalidStateError(
sprintf(
"Aggregate-root is in an invalid state after applying %s.\nErrors:%s",
get_class($event),
implode(PHP_EOL, $errors)
)
);
}
$embedded_entity_events = new EmbeddedEntityEventList();
foreach ($event->getEmbeddedEntityEvents() as $embedded_entity_event) {
$embedded_entity_events->push($this->applyEmbeddedEntityEvent($embedded_entity_event));
}
$source_event = null;
if ($auto_commit) {
$recorded_changes = $this->getRecordedChanges();
if (!empty($recorded_changes) || !$embedded_entity_events->isEmpty()) {
$source_event = $event->createCopyWith(
[ 'data' => $recorded_changes, 'embedded_entity_events' => $embedded_entity_events ]
);
$this->uncomitted_events_list->push($source_event);
$this->history->push($source_event);
}
} else {
$source_event = $event;
}
if ($source_event) {
$this->setValue('revision', $source_event->getSeqNumber());
$this->markClean();
} else {
//$notice = 'Applied event %s for %s did not trigger any state changes, so it is being dropped ...';
//error_log(sprintf($notice, $event, $this));
}
return $source_event;
} | [
"protected",
"function",
"applyEvent",
"(",
"AggregateRootEventInterface",
"$",
"event",
",",
"$",
"auto_commit",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"guardEventPreConditions",
"(",
"$",
"event",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"setValues",
"(",
"$",
"event",
"->",
"getData",
"(",
")",
")",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getValidationResults",
"(",
")",
"as",
"$",
"validation_result",
")",
"{",
"foreach",
"(",
"$",
"validation_result",
"->",
"getViolatedRules",
"(",
")",
"as",
"$",
"violated_rule",
")",
"{",
"foreach",
"(",
"$",
"violated_rule",
"->",
"getIncidents",
"(",
")",
"as",
"$",
"incident",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"PHP_EOL",
".",
"$",
"validation_result",
"->",
"getSUbject",
"(",
")",
"->",
"getName",
"(",
")",
".",
"' - '",
".",
"$",
"violated_rule",
"->",
"getName",
"(",
")",
".",
"' > '",
".",
"$",
"incident",
"->",
"getName",
"(",
")",
".",
"': '",
".",
"print_r",
"(",
"$",
"incident",
"->",
"getParameters",
"(",
")",
",",
"true",
")",
";",
"}",
"}",
"}",
"throw",
"new",
"InvalidStateError",
"(",
"sprintf",
"(",
"\"Aggregate-root is in an invalid state after applying %s.\\nErrors:%s\"",
",",
"get_class",
"(",
"$",
"event",
")",
",",
"implode",
"(",
"PHP_EOL",
",",
"$",
"errors",
")",
")",
")",
";",
"}",
"$",
"embedded_entity_events",
"=",
"new",
"EmbeddedEntityEventList",
"(",
")",
";",
"foreach",
"(",
"$",
"event",
"->",
"getEmbeddedEntityEvents",
"(",
")",
"as",
"$",
"embedded_entity_event",
")",
"{",
"$",
"embedded_entity_events",
"->",
"push",
"(",
"$",
"this",
"->",
"applyEmbeddedEntityEvent",
"(",
"$",
"embedded_entity_event",
")",
")",
";",
"}",
"$",
"source_event",
"=",
"null",
";",
"if",
"(",
"$",
"auto_commit",
")",
"{",
"$",
"recorded_changes",
"=",
"$",
"this",
"->",
"getRecordedChanges",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"recorded_changes",
")",
"||",
"!",
"$",
"embedded_entity_events",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"source_event",
"=",
"$",
"event",
"->",
"createCopyWith",
"(",
"[",
"'data'",
"=>",
"$",
"recorded_changes",
",",
"'embedded_entity_events'",
"=>",
"$",
"embedded_entity_events",
"]",
")",
";",
"$",
"this",
"->",
"uncomitted_events_list",
"->",
"push",
"(",
"$",
"source_event",
")",
";",
"$",
"this",
"->",
"history",
"->",
"push",
"(",
"$",
"source_event",
")",
";",
"}",
"}",
"else",
"{",
"$",
"source_event",
"=",
"$",
"event",
";",
"}",
"if",
"(",
"$",
"source_event",
")",
"{",
"$",
"this",
"->",
"setValue",
"(",
"'revision'",
",",
"$",
"source_event",
"->",
"getSeqNumber",
"(",
")",
")",
";",
"$",
"this",
"->",
"markClean",
"(",
")",
";",
"}",
"else",
"{",
"//$notice = 'Applied event %s for %s did not trigger any state changes, so it is being dropped ...';",
"//error_log(sprintf($notice, $event, $this));",
"}",
"return",
"$",
"source_event",
";",
"}"
] | Takes an event and applies the resulting state change to the aggregate-root's internal state.
@param AggregateRootEventInterface $event
@param bool $auto_commit Whether to directly add the given event to the uncomitted-events list.
@return AggregateRootEventInterface Event that is acutally applied and comitted or false if the AR is invalid. | [
"Takes",
"an",
"event",
"and",
"applies",
"the",
"resulting",
"state",
"change",
"to",
"the",
"aggregate",
"-",
"root",
"s",
"internal",
"state",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L582-L633 |
28,295 | honeybee/honeybee | src/Model/Aggregate/AggregateRoot.php | AggregateRoot.modifyAttributesThrough | protected function modifyAttributesThrough(AggregateRootCommandInterface $command, array $changing_attributes)
{
$this->guardCommandPreConditions($command);
$this->applyEvent($this->processCommand($command, [ 'data' => $changing_attributes ]));
} | php | protected function modifyAttributesThrough(AggregateRootCommandInterface $command, array $changing_attributes)
{
$this->guardCommandPreConditions($command);
$this->applyEvent($this->processCommand($command, [ 'data' => $changing_attributes ]));
} | [
"protected",
"function",
"modifyAttributesThrough",
"(",
"AggregateRootCommandInterface",
"$",
"command",
",",
"array",
"$",
"changing_attributes",
")",
"{",
"$",
"this",
"->",
"guardCommandPreConditions",
"(",
"$",
"command",
")",
";",
"$",
"this",
"->",
"applyEvent",
"(",
"$",
"this",
"->",
"processCommand",
"(",
"$",
"command",
",",
"[",
"'data'",
"=>",
"$",
"changing_attributes",
"]",
")",
")",
";",
"}"
] | Helper method, that makes it easier to apply a command in order to achieve a state transition,
that is "just" based on classical attribute changes.
@param AggregateRootCommandInterface $command
@param array $changing_attributes | [
"Helper",
"method",
"that",
"makes",
"it",
"easier",
"to",
"apply",
"a",
"command",
"in",
"order",
"to",
"achieve",
"a",
"state",
"transition",
"that",
"is",
"just",
"based",
"on",
"classical",
"attribute",
"changes",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Model/Aggregate/AggregateRoot.php#L642-L646 |
28,296 | milejko/mmi | src/Mmi/Console/Application.php | Application.doRun | public function doRun(InputInterface $input, OutputInterface $output)
{
$env = $input->getParameterOption(['--env', '-e'], 'DEV');
//powołanie aplikacji
$app = new \Mmi\App\Kernel('\Mmi\App\BootstrapCli', $env);
//ustawienie typu odpowiedzi na plain
\Mmi\App\FrontController::getInstance()->getResponse()->setTypePlain();
//uruchomienie aplikacji
$app->run();
return parent::doRun($input, $output);
} | php | public function doRun(InputInterface $input, OutputInterface $output)
{
$env = $input->getParameterOption(['--env', '-e'], 'DEV');
//powołanie aplikacji
$app = new \Mmi\App\Kernel('\Mmi\App\BootstrapCli', $env);
//ustawienie typu odpowiedzi na plain
\Mmi\App\FrontController::getInstance()->getResponse()->setTypePlain();
//uruchomienie aplikacji
$app->run();
return parent::doRun($input, $output);
} | [
"public",
"function",
"doRun",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"env",
"=",
"$",
"input",
"->",
"getParameterOption",
"(",
"[",
"'--env'",
",",
"'-e'",
"]",
",",
"'DEV'",
")",
";",
"//powołanie aplikacji",
"$",
"app",
"=",
"new",
"\\",
"Mmi",
"\\",
"App",
"\\",
"Kernel",
"(",
"'\\Mmi\\App\\BootstrapCli'",
",",
"$",
"env",
")",
";",
"//ustawienie typu odpowiedzi na plain",
"\\",
"Mmi",
"\\",
"App",
"\\",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getResponse",
"(",
")",
"->",
"setTypePlain",
"(",
")",
";",
"//uruchomienie aplikacji",
"$",
"app",
"->",
"run",
"(",
")",
";",
"return",
"parent",
"::",
"doRun",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}"
] | Bootstrap aplikacji przed wykonaniem komendy konsoli
@param InputInterface $input
@param OutputInterface $output
@return int | [
"Bootstrap",
"aplikacji",
"przed",
"wykonaniem",
"komendy",
"konsoli"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Console/Application.php#L31-L42 |
28,297 | milejko/mmi | src/Mmi/Console/Application.php | Application.getApplicationCommands | protected function getApplicationCommands()
{
$commands = [];
foreach (StructureParser::getModules() as $module) {
//namespace modułu
$moduleNamespace = substr($module, strrpos($module, DIRECTORY_SEPARATOR) + 1, strlen($module));
//iteracja po komendach konsolowych
foreach (glob($module . '/Console/*Command.php') as $command) {
$className = basename($command, '.php');
$class = '\\' . $moduleNamespace . '\\Console\\' . $className;
//reflection do sprawdzenia pochodzenia
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('Mmi\\Console\\CommandAbstract')
&& !$r->isAbstract()
&& !$r->getConstructor()->getNumberOfRequiredParameters()
) {
$commands[] = $r->newInstance();
}
}
}
return $commands;
} | php | protected function getApplicationCommands()
{
$commands = [];
foreach (StructureParser::getModules() as $module) {
//namespace modułu
$moduleNamespace = substr($module, strrpos($module, DIRECTORY_SEPARATOR) + 1, strlen($module));
//iteracja po komendach konsolowych
foreach (glob($module . '/Console/*Command.php') as $command) {
$className = basename($command, '.php');
$class = '\\' . $moduleNamespace . '\\Console\\' . $className;
//reflection do sprawdzenia pochodzenia
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('Mmi\\Console\\CommandAbstract')
&& !$r->isAbstract()
&& !$r->getConstructor()->getNumberOfRequiredParameters()
) {
$commands[] = $r->newInstance();
}
}
}
return $commands;
} | [
"protected",
"function",
"getApplicationCommands",
"(",
")",
"{",
"$",
"commands",
"=",
"[",
"]",
";",
"foreach",
"(",
"StructureParser",
"::",
"getModules",
"(",
")",
"as",
"$",
"module",
")",
"{",
"//namespace modułu",
"$",
"moduleNamespace",
"=",
"substr",
"(",
"$",
"module",
",",
"strrpos",
"(",
"$",
"module",
",",
"DIRECTORY_SEPARATOR",
")",
"+",
"1",
",",
"strlen",
"(",
"$",
"module",
")",
")",
";",
"//iteracja po komendach konsolowych",
"foreach",
"(",
"glob",
"(",
"$",
"module",
".",
"'/Console/*Command.php'",
")",
"as",
"$",
"command",
")",
"{",
"$",
"className",
"=",
"basename",
"(",
"$",
"command",
",",
"'.php'",
")",
";",
"$",
"class",
"=",
"'\\\\'",
".",
"$",
"moduleNamespace",
".",
"'\\\\Console\\\\'",
".",
"$",
"className",
";",
"//reflection do sprawdzenia pochodzenia",
"$",
"r",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"r",
"->",
"isSubclassOf",
"(",
"'Mmi\\\\Console\\\\CommandAbstract'",
")",
"&&",
"!",
"$",
"r",
"->",
"isAbstract",
"(",
")",
"&&",
"!",
"$",
"r",
"->",
"getConstructor",
"(",
")",
"->",
"getNumberOfRequiredParameters",
"(",
")",
")",
"{",
"$",
"commands",
"[",
"]",
"=",
"$",
"r",
"->",
"newInstance",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"commands",
";",
"}"
] | Pobieranie komend z aplikacji | [
"Pobieranie",
"komend",
"z",
"aplikacji"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Console/Application.php#L55-L77 |
28,298 | milejko/mmi | src/Mmi/Log/LoggerHelper.php | LoggerHelper.getLevel | public static function getLevel()
{
if (!self::$_config) {
throw new LoggerException('Configuration not loaded');
}
$minLevel = Logger::EMERGENCY;
//iteracja po configach
foreach (self::$_config as $config) {
if ($config->getLevel() < $minLevel) {
$minLevel = $config->getLevel();
}
}
return $minLevel;
} | php | public static function getLevel()
{
if (!self::$_config) {
throw new LoggerException('Configuration not loaded');
}
$minLevel = Logger::EMERGENCY;
//iteracja po configach
foreach (self::$_config as $config) {
if ($config->getLevel() < $minLevel) {
$minLevel = $config->getLevel();
}
}
return $minLevel;
} | [
"public",
"static",
"function",
"getLevel",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_config",
")",
"{",
"throw",
"new",
"LoggerException",
"(",
"'Configuration not loaded'",
")",
";",
"}",
"$",
"minLevel",
"=",
"Logger",
"::",
"EMERGENCY",
";",
"//iteracja po configach",
"foreach",
"(",
"self",
"::",
"$",
"_config",
"as",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"getLevel",
"(",
")",
"<",
"$",
"minLevel",
")",
"{",
"$",
"minLevel",
"=",
"$",
"config",
"->",
"getLevel",
"(",
")",
";",
"}",
"}",
"return",
"$",
"minLevel",
";",
"}"
] | Zwraca poziom logowania
@return integer | [
"Zwraca",
"poziom",
"logowania"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Log/LoggerHelper.php#L47-L60 |
28,299 | peakphp/framework | src/Collection/DotNotationCollection.php | DotNotationCollection.get | public function get(string $path, $default = null)
{
$array = $this->items;
if (!empty($path)) {
$keys = $this->explode($path);
foreach ($keys as $key) {
if (!array_key_exists($key, $array)) {
return $default;
}
$array = $array[$key];
}
}
return $array;
} | php | public function get(string $path, $default = null)
{
$array = $this->items;
if (!empty($path)) {
$keys = $this->explode($path);
foreach ($keys as $key) {
if (!array_key_exists($key, $array)) {
return $default;
}
$array = $array[$key];
}
}
return $array;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"path",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"array",
"=",
"$",
"this",
"->",
"items",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"explode",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"$",
"array",
"=",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] | Return a path value
@param string $path
@param mixed $default
@return mixed | [
"Return",
"a",
"path",
"value"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/DotNotationCollection.php#L29-L44 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.