repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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",
"... | 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 | train |
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",
"(",
")",
";",
... | 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 | train |
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",... | 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 | train |
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",
"'*'",
";",
"}",
"$",
... | 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 | train |
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... | 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 | train |
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",
",",
... | 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 | train |
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",
"$",
"... | 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 | train |
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",
")",
"... | 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 | train |
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 $ro... | 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 | train |
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",
")",
";",
... | 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 | train |
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",
"]",
")",
")",
"?",
"$",
"_S... | 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 | train |
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",
"(",
")",
"]",
"=",
"$",
"elemen... | 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 | train |
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",
"(",
"$... | 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 | train |
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",
"(",
"$",
"reque... | 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 | train |
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",
"(",
... | 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 | train |
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",
")"... | 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 | train |
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",
")",
"... | 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 | train |
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",
"(",
"... | 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 | train |
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",
"(",
... | 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 | train |
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\"",
... | 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 | train |
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",
"(",
"$",
"tab... | 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 | train |
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"... | 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 | train |
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",
")",
")",
"{",
"$",
... | 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 | train |
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'",
",",
"[",... | 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 | train |
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... | 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 | train |
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",
"[",
... | 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 | train |
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",... | 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 | train |
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 ... | 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 | train |
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__",
".",
... | 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 | train |
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 | train |
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",
... | 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 | train |
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 tab... | 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 | train |
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"... | 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 | train |
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",
"(",... | 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 | train |
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",
... | 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 | train |
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... | 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 | train |
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",
")"... | 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 | train |
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 | train |
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",
")",
")",
"{",
... | Buduje opcje HTML
@return string | [
"Buduje",
"opcje",
"HTML"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Form/Element/ElementAbstract.php#L391-L409 | train |
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",
"::",
"... | Buduje opis pola
@return string | [
"Buduje",
"opis",
"pola"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Form/Element/ElementAbstract.php#L479-L489 | train |
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",
"(",
")",
";... | 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 | train |
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",
"$... | 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 | train |
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_e... | 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 | train |
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",
"->",
"g... | 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 | train |
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",
")",
"{... | 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 | train |
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",
"(",
")",
")",
"]",
";",
"$",
"d... | 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 | train |
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",
"... | 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 | train |
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 | train |
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... | 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 | train |
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_mac... | 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 | train |
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 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 | train |
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",
"=",
"$",
"ty... | 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 | train |
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_ev... | 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 | train |
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_nam... | 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 | train |
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"... | 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 | train |
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",
"->",
"applyEven... | 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 | train |
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 apli... | 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 | train |
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",
... | Pobieranie komend z aplikacji | [
"Pobieranie",
"komend",
"z",
"aplikacji"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Console/Application.php#L55-L77 | train |
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",
";",
... | Zwraca poziom logowania
@return integer | [
"Zwraca",
"poziom",
"logowania"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Log/LoggerHelper.php#L47-L60 | train |
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",
... | 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 | train |
peakphp/framework | src/Collection/DotNotationCollection.php | DotNotationCollection.add | public function add(string $path, array $values): void
{
$get = (array)$this->get($path);
$this->set($path, $this->arrayMergeRecursiveDistinct($get, $values));
} | php | public function add(string $path, array $values): void
{
$get = (array)$this->get($path);
$this->set($path, $this->arrayMergeRecursiveDistinct($get, $values));
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"path",
",",
"array",
"$",
"values",
")",
":",
"void",
"{",
"$",
"get",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"path",
... | Merge a path with an array
@param string $path
@param array $values | [
"Merge",
"a",
"path",
"with",
"an",
"array"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/DotNotationCollection.php#L81-L85 | train |
peakphp/framework | src/Collection/DotNotationCollection.php | DotNotationCollection.has | public function has(string $path): bool
{
$keys = $this->explode($path);
$array = $this->items;
foreach ($keys as $key) {
if (!array_key_exists($key, $array)) {
return false;
}
$array = $array[$key];
}
return true;
} | php | public function has(string $path): bool
{
$keys = $this->explode($path);
$array = $this->items;
foreach ($keys as $key) {
if (!array_key_exists($key, $array)) {
return false;
}
$array = $array[$key];
}
return true;
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"explode",
"(",
"$",
"path",
")",
";",
"$",
"array",
"=",
"$",
"this",
"->",
"items",
";",
"foreach",
"(",
"$",
"keys",
"as",
"... | Check if we have path
@param string $path
@return bool | [
"Check",
"if",
"we",
"have",
"path"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/DotNotationCollection.php#L92-L103 | train |
milejko/mmi | src/Mmi/Cache/DistributedCacheHandlerAbstract.php | DistributedCacheHandlerAbstract._initDistributedStorage | protected final function _initDistributedStorage(Cache $cache)
{
//klonowanie konfiguracji bufora
$cacheConfigClone = clone $cache->getConfig();
$cacheConfigClone->distributed = false;
//nowy obiekt bufora lokalnego
$this->_undistributedCache = new Cache($cacheConfigClone);
//ustawienie bufora rozproszonego
$this->_distributedStorage = $this->_getDistributedStorage();
//jest informacja o czyszczeniu bufora
if ($this->_keyShouldBeDeleted(self::FLUSH_MESSAGE)) {
//wymuszenie czyszczenia bufora (bez rozgłaszania)
$this->_deleteAllNoBroadcasting();
//zapis lokalnie informacji o usunięciu
$this->_undistributedCache->save(time(), self::DEL_PREFIX . self::FLUSH_MESSAGE, 0);
}
//czyszczenie pojedynczych kluczy
foreach ($this->_distributedStorage->getOptions() as $key => $timestamp) {
//jeśli klucz powinien zostać usunięty usuwa bez dalszego rozgłaszania
$this->_keyShouldBeDeleted($key) &&
$this->_deleteNoBroadcasting($key);
}
} | php | protected final function _initDistributedStorage(Cache $cache)
{
//klonowanie konfiguracji bufora
$cacheConfigClone = clone $cache->getConfig();
$cacheConfigClone->distributed = false;
//nowy obiekt bufora lokalnego
$this->_undistributedCache = new Cache($cacheConfigClone);
//ustawienie bufora rozproszonego
$this->_distributedStorage = $this->_getDistributedStorage();
//jest informacja o czyszczeniu bufora
if ($this->_keyShouldBeDeleted(self::FLUSH_MESSAGE)) {
//wymuszenie czyszczenia bufora (bez rozgłaszania)
$this->_deleteAllNoBroadcasting();
//zapis lokalnie informacji o usunięciu
$this->_undistributedCache->save(time(), self::DEL_PREFIX . self::FLUSH_MESSAGE, 0);
}
//czyszczenie pojedynczych kluczy
foreach ($this->_distributedStorage->getOptions() as $key => $timestamp) {
//jeśli klucz powinien zostać usunięty usuwa bez dalszego rozgłaszania
$this->_keyShouldBeDeleted($key) &&
$this->_deleteNoBroadcasting($key);
}
} | [
"protected",
"final",
"function",
"_initDistributedStorage",
"(",
"Cache",
"$",
"cache",
")",
"{",
"//klonowanie konfiguracji bufora ",
"$",
"cacheConfigClone",
"=",
"clone",
"$",
"cache",
"->",
"getConfig",
"(",
")",
";",
"$",
"cacheConfigClone",
"->",
"distributed... | Inicjalizacja bufora rozproszonego
@param Cache $cache
@throws CacheException | [
"Inicjalizacja",
"bufora",
"rozproszonego"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/DistributedCacheHandlerAbstract.php#L123-L145 | train |
milejko/mmi | src/Mmi/Cache/DistributedCacheHandlerAbstract.php | DistributedCacheHandlerAbstract._getDistributedStorage | protected final function _getDistributedStorage()
{
//ładowanie rozproszonego bufora z bufora lokalnego
if (null === $distributedStorage = $this->_undistributedCache->load(self::STORAGE_KEY)) {
//zapis z krótkim, zdefiniowanym odświeżaniem
$this->_undistributedCache->save($distributedStorage = new DistributedStorage(), self::STORAGE_KEY, self::DISTRIBUTED_REFRESH_INTERVAL);
}
//zapis lokalnym buforze
return $distributedStorage;
} | php | protected final function _getDistributedStorage()
{
//ładowanie rozproszonego bufora z bufora lokalnego
if (null === $distributedStorage = $this->_undistributedCache->load(self::STORAGE_KEY)) {
//zapis z krótkim, zdefiniowanym odświeżaniem
$this->_undistributedCache->save($distributedStorage = new DistributedStorage(), self::STORAGE_KEY, self::DISTRIBUTED_REFRESH_INTERVAL);
}
//zapis lokalnym buforze
return $distributedStorage;
} | [
"protected",
"final",
"function",
"_getDistributedStorage",
"(",
")",
"{",
"//ładowanie rozproszonego bufora z bufora lokalnego",
"if",
"(",
"null",
"===",
"$",
"distributedStorage",
"=",
"$",
"this",
"->",
"_undistributedCache",
"->",
"load",
"(",
"self",
"::",
"STOR... | Ustawienie bufora rozproszonego
@return Cache
@throws CacheException | [
"Ustawienie",
"bufora",
"rozproszonego"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/DistributedCacheHandlerAbstract.php#L152-L161 | train |
milejko/mmi | src/Mmi/Orm/Query.php | Query.andField | public final function andField($fieldName, $tableName = null)
{
return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'AND');
} | php | public final function andField($fieldName, $tableName = null)
{
return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'AND');
} | [
"public",
"final",
"function",
"andField",
"(",
"$",
"fieldName",
",",
"$",
"tableName",
"=",
"null",
")",
"{",
"return",
"new",
"QueryHelper",
"\\",
"QueryField",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"_prepareField",
"(",
"$",
"fieldName",
",",
"$"... | Dodaje warunek na pole AND
@param string $fieldName nazwa pola
@param string $tableName opcjonalna nazwa tabeli źródłowej
@return QueryHelper\QueryField | [
"Dodaje",
"warunek",
"na",
"pole",
"AND"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Query.php#L157-L160 | train |
milejko/mmi | src/Mmi/Orm/Query.php | Query.orField | public final function orField($fieldName, $tableName = null)
{
return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'OR');
} | php | public final function orField($fieldName, $tableName = null)
{
return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'OR');
} | [
"public",
"final",
"function",
"orField",
"(",
"$",
"fieldName",
",",
"$",
"tableName",
"=",
"null",
")",
"{",
"return",
"new",
"QueryHelper",
"\\",
"QueryField",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"_prepareField",
"(",
"$",
"fieldName",
",",
"$",... | Dodaje warunek na pole OR
@param string $fieldName nazwa pola
@param string $tableName opcjonalna nazwa tabeli źródłowej
@return QueryHelper\QueryField | [
"Dodaje",
"warunek",
"na",
"pole",
"OR"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Query.php#L179-L182 | train |
cedx/lcov.php | RoboFile.php | RoboFile.clean | function clean(): Result {
return $this->collectionBuilder()
->addTask($this->taskCleanDir('var'))
->addTask($this->taskDeleteDir(['build', 'doc/api', 'web']))
->run();
} | php | function clean(): Result {
return $this->collectionBuilder()
->addTask($this->taskCleanDir('var'))
->addTask($this->taskDeleteDir(['build', 'doc/api', 'web']))
->run();
} | [
"function",
"clean",
"(",
")",
":",
"Result",
"{",
"return",
"$",
"this",
"->",
"collectionBuilder",
"(",
")",
"->",
"addTask",
"(",
"$",
"this",
"->",
"taskCleanDir",
"(",
"'var'",
")",
")",
"->",
"addTask",
"(",
"$",
"this",
"->",
"taskDeleteDir",
"(... | Deletes all generated files and reset any saved state.
@return Result The task result. | [
"Deletes",
"all",
"generated",
"files",
"and",
"reset",
"any",
"saved",
"state",
"."
] | ae0129ec01f3e77e3598b82971383c334b213afe | https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/RoboFile.php#L27-L32 | train |
cedx/lcov.php | RoboFile.php | RoboFile.coverage | function coverage(): Result {
$path = (string) getenv('PATH');
$vendor = (string) realpath(trim(`{$this->composer} global config bin-dir --absolute`));
if (strpos($path, $vendor) === false) putenv("PATH=$vendor".PATH_SEPARATOR.$path);
return $this->_exec('coveralls var/coverage.xml');
} | php | function coverage(): Result {
$path = (string) getenv('PATH');
$vendor = (string) realpath(trim(`{$this->composer} global config bin-dir --absolute`));
if (strpos($path, $vendor) === false) putenv("PATH=$vendor".PATH_SEPARATOR.$path);
return $this->_exec('coveralls var/coverage.xml');
} | [
"function",
"coverage",
"(",
")",
":",
"Result",
"{",
"$",
"path",
"=",
"(",
"string",
")",
"getenv",
"(",
"'PATH'",
")",
";",
"$",
"vendor",
"=",
"(",
"string",
")",
"realpath",
"(",
"trim",
"(",
"`{$this->composer} global config bin-dir --absolute`",
")",
... | Uploads the results of the code coverage.
@return Result The task result. | [
"Uploads",
"the",
"results",
"of",
"the",
"code",
"coverage",
"."
] | ae0129ec01f3e77e3598b82971383c334b213afe | https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/RoboFile.php#L38-L43 | train |
cedx/lcov.php | RoboFile.php | RoboFile.doc | function doc(): Result {
return $this->collectionBuilder()
->addTask($this->taskFilesystemStack()
->copy('CHANGELOG.md', 'doc/about/changelog.md')
->copy('LICENSE.md', 'doc/about/license.md'))
->addTask($this->taskExec('mkdocs build --config-file=etc/mkdocs.yaml'))
->addTask($this->taskFilesystemStack()
->remove(['doc/about/changelog.md', 'doc/about/license.md']))
->run();
} | php | function doc(): Result {
return $this->collectionBuilder()
->addTask($this->taskFilesystemStack()
->copy('CHANGELOG.md', 'doc/about/changelog.md')
->copy('LICENSE.md', 'doc/about/license.md'))
->addTask($this->taskExec('mkdocs build --config-file=etc/mkdocs.yaml'))
->addTask($this->taskFilesystemStack()
->remove(['doc/about/changelog.md', 'doc/about/license.md']))
->run();
} | [
"function",
"doc",
"(",
")",
":",
"Result",
"{",
"return",
"$",
"this",
"->",
"collectionBuilder",
"(",
")",
"->",
"addTask",
"(",
"$",
"this",
"->",
"taskFilesystemStack",
"(",
")",
"->",
"copy",
"(",
"'CHANGELOG.md'",
",",
"'doc/about/changelog.md'",
")",
... | Builds the documentation.
@return Result The task result. | [
"Builds",
"the",
"documentation",
"."
] | ae0129ec01f3e77e3598b82971383c334b213afe | https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/RoboFile.php#L49-L58 | train |
peakphp/framework | src/Common/Traits/Macro.php | Macro.callMacro | public function callMacro(string $name, array $args)
{
if (isset($this->macros[$name])) {
return call_user_func_array($this->macros[$name], $args);
}
throw new RuntimeException('There is no macro with the given name "'.$name.'" to call');
} | php | public function callMacro(string $name, array $args)
{
if (isset($this->macros[$name])) {
return call_user_func_array($this->macros[$name], $args);
}
throw new RuntimeException('There is no macro with the given name "'.$name.'" to call');
} | [
"public",
"function",
"callMacro",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"args",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"macros",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"$",
"this",
"->",
... | Call a macro
@param string $name
@param array $args
@return mixed | [
"Call",
"a",
"macro"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Traits/Macro.php#L44-L50 | train |
peakphp/framework | src/Bedrock/Http/Application.php | Application.stack | public function stack($handlers)
{
if (is_array($handlers)) {
$this->handlers = array_merge($this->handlers, $handlers);
} else {
$this->handlers[] = $handlers;
}
return $this;
} | php | public function stack($handlers)
{
if (is_array($handlers)) {
$this->handlers = array_merge($this->handlers, $handlers);
} else {
$this->handlers[] = $handlers;
}
return $this;
} | [
"public",
"function",
"stack",
"(",
"$",
"handlers",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"handlers",
")",
")",
"{",
"$",
"this",
"->",
"handlers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"handlers",
",",
"$",
"handlers",
")",
";",
"}",
"... | Add something to application stack
@param mixed $handlers
@return $this | [
"Add",
"something",
"to",
"application",
"stack"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L80-L88 | train |
peakphp/framework | src/Bedrock/Http/Application.php | Application.stackRoute | public function stackRoute(?string $method, string $path, $handlers)
{
return $this->stack(
$this->createRoute($method, $path, $handlers)
);
} | php | public function stackRoute(?string $method, string $path, $handlers)
{
return $this->stack(
$this->createRoute($method, $path, $handlers)
);
} | [
"public",
"function",
"stackRoute",
"(",
"?",
"string",
"$",
"method",
",",
"string",
"$",
"path",
",",
"$",
"handlers",
")",
"{",
"return",
"$",
"this",
"->",
"stack",
"(",
"$",
"this",
"->",
"createRoute",
"(",
"$",
"method",
",",
"$",
"path",
",",... | Create and stack a new route
@param string|null $method
@param string $path
@param mixed $handlers
@return Application | [
"Create",
"and",
"stack",
"a",
"new",
"route"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L165-L170 | train |
peakphp/framework | src/Bedrock/Http/Application.php | Application.createRoute | public function createRoute(?string $method, string $path, $handlers): Route
{
if ($handlers instanceof \Peak\Blueprint\Http\Stack) {
return new Route($method, $path, $handlers);
}
if (!is_array($handlers)) {
$handlers = [$handlers];
}
return new Route($method, $path, new Stack($handlers, $this->getHandlerResolver()));
} | php | public function createRoute(?string $method, string $path, $handlers): Route
{
if ($handlers instanceof \Peak\Blueprint\Http\Stack) {
return new Route($method, $path, $handlers);
}
if (!is_array($handlers)) {
$handlers = [$handlers];
}
return new Route($method, $path, new Stack($handlers, $this->getHandlerResolver()));
} | [
"public",
"function",
"createRoute",
"(",
"?",
"string",
"$",
"method",
",",
"string",
"$",
"path",
",",
"$",
"handlers",
")",
":",
"Route",
"{",
"if",
"(",
"$",
"handlers",
"instanceof",
"\\",
"Peak",
"\\",
"Blueprint",
"\\",
"Http",
"\\",
"Stack",
")... | Create a new route
@param null|string $method
@param string $path
@param mixed $handlers
@return Route | [
"Create",
"a",
"new",
"route"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L179-L188 | train |
peakphp/framework | src/Bedrock/Http/Application.php | Application.createStack | public function createStack($handlers): Stack
{
if (!is_array($handlers)) {
$handlers = [$handlers];
}
return new Stack(
$handlers,
$this->handlerResolver
);
} | php | public function createStack($handlers): Stack
{
if (!is_array($handlers)) {
$handlers = [$handlers];
}
return new Stack(
$handlers,
$this->handlerResolver
);
} | [
"public",
"function",
"createStack",
"(",
"$",
"handlers",
")",
":",
"Stack",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"handlers",
")",
")",
"{",
"$",
"handlers",
"=",
"[",
"$",
"handlers",
"]",
";",
"}",
"return",
"new",
"Stack",
"(",
"$",
"hand... | Create a stack with the current app handlerResolver
@param mixed $handlers
@return Stack | [
"Create",
"a",
"stack",
"with",
"the",
"current",
"app",
"handlerResolver"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L195-L204 | train |
peakphp/framework | src/Bedrock/Http/Application.php | Application.run | public function run(ServerRequestInterface $request, ResponseEmitter $emitter)
{
return $emitter->emit($this->handle($request));
} | php | public function run(ServerRequestInterface $request, ResponseEmitter $emitter)
{
return $emitter->emit($this->handle($request));
} | [
"public",
"function",
"run",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseEmitter",
"$",
"emitter",
")",
"{",
"return",
"$",
"emitter",
"->",
"emit",
"(",
"$",
"this",
"->",
"handle",
"(",
"$",
"request",
")",
")",
";",
"}"
] | Run the stack with a request and emit the response
@param ServerRequestInterface $request
@param ResponseEmitter $emitter
@return mixed | [
"Run",
"the",
"stack",
"with",
"a",
"request",
"and",
"emit",
"the",
"response"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L248-L251 | train |
milejko/mmi | src/Mmi/Db/Adapter/PdoMysql.php | PdoMysql.tableList | public function tableList($schema = null)
{
$list = $this->fetchAll('SHOW TABLES;');
$tables = [];
foreach ($list as $row) {
foreach ($row as $name) {
$tables[] = $name;
}
}
return $tables;
} | php | public function tableList($schema = null)
{
$list = $this->fetchAll('SHOW TABLES;');
$tables = [];
foreach ($list as $row) {
foreach ($row as $name) {
$tables[] = $name;
}
}
return $tables;
} | [
"public",
"function",
"tableList",
"(",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"fetchAll",
"(",
"'SHOW TABLES;'",
")",
";",
"$",
"tables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"row",
")",
... | Listuje tabele w schemacie bazy danych
@param string $schema nie istotny w MySQL
@return array | [
"Listuje",
"tabele",
"w",
"schemacie",
"bazy",
"danych"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoMysql.php#L106-L116 | train |
CVO-Technologies/cakephp-gearman | src/Shell/Task/EmailTask.php | EmailTask.main | public function main(array $workload)
{
$defineFullBaseUrl = !empty($workload['fullBaseUrl']);
if ($defineFullBaseUrl) {
$previousFullBaseUrl = Configure::read('App.fullBaseUrl', $workload['fullBaseUrl']);
Configure::write('App.fullBaseUrl', $workload['fullBaseUrl']);
} else {
$this->log(__('Could not set full base URL when sending email'), LogLevel::WARNING);
}
/* @var \Cake\Mailer\Email $email */
$email = $workload['email'];
if ($defineFullBaseUrl) {
Configure::write('App.fullBaseUrl', $previousFullBaseUrl);
}
$subject = $email->subject();
if (method_exists($email, 'getOriginalSubject')) {
$subject = $email->getOriginalSubject();
}
$this->log(__('Sending email with subject {0} to {1}', $subject, implode(',', $email->to())), LogLevel::INFO);
return $email->transport($workload['transport'])->send();
} | php | public function main(array $workload)
{
$defineFullBaseUrl = !empty($workload['fullBaseUrl']);
if ($defineFullBaseUrl) {
$previousFullBaseUrl = Configure::read('App.fullBaseUrl', $workload['fullBaseUrl']);
Configure::write('App.fullBaseUrl', $workload['fullBaseUrl']);
} else {
$this->log(__('Could not set full base URL when sending email'), LogLevel::WARNING);
}
/* @var \Cake\Mailer\Email $email */
$email = $workload['email'];
if ($defineFullBaseUrl) {
Configure::write('App.fullBaseUrl', $previousFullBaseUrl);
}
$subject = $email->subject();
if (method_exists($email, 'getOriginalSubject')) {
$subject = $email->getOriginalSubject();
}
$this->log(__('Sending email with subject {0} to {1}', $subject, implode(',', $email->to())), LogLevel::INFO);
return $email->transport($workload['transport'])->send();
} | [
"public",
"function",
"main",
"(",
"array",
"$",
"workload",
")",
"{",
"$",
"defineFullBaseUrl",
"=",
"!",
"empty",
"(",
"$",
"workload",
"[",
"'fullBaseUrl'",
"]",
")",
";",
"if",
"(",
"$",
"defineFullBaseUrl",
")",
"{",
"$",
"previousFullBaseUrl",
"=",
... | Send an email using the provided transport.
@param array $workload The fullBaseUrl, email and transport name
@return array Information from the transport | [
"Send",
"an",
"email",
"using",
"the",
"provided",
"transport",
"."
] | 538f060a617165482159c4f5f42d4b0562a14194 | https://github.com/CVO-Technologies/cakephp-gearman/blob/538f060a617165482159c4f5f42d4b0562a14194/src/Shell/Task/EmailTask.php#L17-L44 | train |
milejko/mmi | src/Mmi/Validator/NumberBetween.php | NumberBetween.isValid | public function isValid($value)
{
//czy liczba
if (!is_numeric($value)) {
return $this->_error(self::INVALID);
}
//sprawdzamy dolny zakres
if ($this->getFrom() !== null && $value < $this->getFrom()) {
return $this->_error(self::INVALID);
}
//sprawdzamy górny zakres
if ($this->getTo() !== null && $value > $this->getTo()) {
return $this->_error(self::INVALID);
}
return true;
} | php | public function isValid($value)
{
//czy liczba
if (!is_numeric($value)) {
return $this->_error(self::INVALID);
}
//sprawdzamy dolny zakres
if ($this->getFrom() !== null && $value < $this->getFrom()) {
return $this->_error(self::INVALID);
}
//sprawdzamy górny zakres
if ($this->getTo() !== null && $value > $this->getTo()) {
return $this->_error(self::INVALID);
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"//czy liczba",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_error",
"(",
"self",
"::",
"INVALID",
")",
";",
"}",
"//sprawdzamy dolny zakres",... | Walidacja liczb od-do
@param mixed $value wartość
@return boolean | [
"Walidacja",
"liczb",
"od",
"-",
"do"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Validator/NumberBetween.php#L49-L64 | train |
milejko/mmi | src/Mmi/Cache/MemcacheHandler.php | MemcacheHandler._parseMemcacheAddress | private function _parseMemcacheAddress($link)
{
$protoSeparator = strpos($link, '://');
if ($protoSeparator !== false) {
$link = substr($link, $protoSeparator + 3);
}
$server = $link;
$serverOptions = [];
$hookSeparator = strpos($link, '?');
if ($hookSeparator !== false) {
$server = substr($link, 0, $hookSeparator);
parse_str(substr($link, $hookSeparator + 1), $serverOptions);
}
$server = explode(':', $server);
$serverOptions['host'] = $server[0];
$serverOptions['port'] = $server[1];
return $serverOptions;
} | php | private function _parseMemcacheAddress($link)
{
$protoSeparator = strpos($link, '://');
if ($protoSeparator !== false) {
$link = substr($link, $protoSeparator + 3);
}
$server = $link;
$serverOptions = [];
$hookSeparator = strpos($link, '?');
if ($hookSeparator !== false) {
$server = substr($link, 0, $hookSeparator);
parse_str(substr($link, $hookSeparator + 1), $serverOptions);
}
$server = explode(':', $server);
$serverOptions['host'] = $server[0];
$serverOptions['port'] = $server[1];
return $serverOptions;
} | [
"private",
"function",
"_parseMemcacheAddress",
"(",
"$",
"link",
")",
"{",
"$",
"protoSeparator",
"=",
"strpos",
"(",
"$",
"link",
",",
"'://'",
")",
";",
"if",
"(",
"$",
"protoSeparator",
"!==",
"false",
")",
"{",
"$",
"link",
"=",
"substr",
"(",
"$"... | Parsuje adres serwera memcached
@param string $link źródło
@return array | [
"Parsuje",
"adres",
"serwera",
"memcached"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/MemcacheHandler.php#L112-L129 | train |
peakphp/framework | src/Common/Pagination/Pagination.php | Pagination.calculate | public function calculate(): Pagination
{
// calculate how many page
$this->pages_count = 1;
if ($this->items_count > 0 && $this->items_per_page > 0) {
$this->pages_count = ceil(($this->items_count / $this->items_per_page));
} elseif ($this->items_count == 0) {
$this->pages_count = 0;
}
// generate pages array
$this->pages = [];
if ($this->pages_count > 0) {
$this->pages = range(1, $this->pages_count);
}
// check current page
if (!$this->isPage($this->current_page)) {
throw new Exception(__CLASS__.': page '.$this->current_page.' doesn\'t exists');
}
$this->first_page = empty($this->pages) ? null : 1;
$this->last_page = ($this->pages_count < 1) ? null : $this->pages_count;
// prev/next page
$this->prev_page = ($this->current_page > 1) ? $this->current_page - 1 : null;
$this->next_page = (($this->current_page + 1) <= $this->pages_count) ? $this->current_page + 1 : null;
// item start/end page
$this->item_start = (($this->current_page - 1) * $this->items_per_page);
$this->item_end = $this->item_start + $this->items_per_page;
if (($this->items_count != 0)) {
++$this->item_start;
}
if ($this->item_end > $this->items_count) {
$this->item_end = $this->items_count;
}
// item start offset
$this->offset = $this->item_start - 1;
return $this;
} | php | public function calculate(): Pagination
{
// calculate how many page
$this->pages_count = 1;
if ($this->items_count > 0 && $this->items_per_page > 0) {
$this->pages_count = ceil(($this->items_count / $this->items_per_page));
} elseif ($this->items_count == 0) {
$this->pages_count = 0;
}
// generate pages array
$this->pages = [];
if ($this->pages_count > 0) {
$this->pages = range(1, $this->pages_count);
}
// check current page
if (!$this->isPage($this->current_page)) {
throw new Exception(__CLASS__.': page '.$this->current_page.' doesn\'t exists');
}
$this->first_page = empty($this->pages) ? null : 1;
$this->last_page = ($this->pages_count < 1) ? null : $this->pages_count;
// prev/next page
$this->prev_page = ($this->current_page > 1) ? $this->current_page - 1 : null;
$this->next_page = (($this->current_page + 1) <= $this->pages_count) ? $this->current_page + 1 : null;
// item start/end page
$this->item_start = (($this->current_page - 1) * $this->items_per_page);
$this->item_end = $this->item_start + $this->items_per_page;
if (($this->items_count != 0)) {
++$this->item_start;
}
if ($this->item_end > $this->items_count) {
$this->item_end = $this->items_count;
}
// item start offset
$this->offset = $this->item_start - 1;
return $this;
} | [
"public",
"function",
"calculate",
"(",
")",
":",
"Pagination",
"{",
"// calculate how many page",
"$",
"this",
"->",
"pages_count",
"=",
"1",
";",
"if",
"(",
"$",
"this",
"->",
"items_count",
">",
"0",
"&&",
"$",
"this",
"->",
"items_per_page",
">",
"0",
... | Calculate stuff for pagination
@throws Exception | [
"Calculate",
"stuff",
"for",
"pagination"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Pagination/Pagination.php#L81-L124 | train |
peakphp/framework | src/Common/Pagination/Pagination.php | Pagination.isPage | public function isPage(int $number): bool
{
return (in_array($number, $this->pages)) ? true : false;
} | php | public function isPage(int $number): bool
{
return (in_array($number, $this->pages)) ? true : false;
} | [
"public",
"function",
"isPage",
"(",
"int",
"$",
"number",
")",
":",
"bool",
"{",
"return",
"(",
"in_array",
"(",
"$",
"number",
",",
"$",
"this",
"->",
"pages",
")",
")",
"?",
"true",
":",
"false",
";",
"}"
] | Check if a page exists
@param int $number
@return bool | [
"Check",
"if",
"a",
"page",
"exists"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Pagination/Pagination.php#L168-L171 | train |
honeybee/honeybee | src/Projection/EventHandler/ProjectionUpdater.php | ProjectionUpdater.mirrorReferencedProjection | protected function mirrorReferencedProjection(EntityReferenceInterface $projection)
{
$projection_type = $projection->getType();
$mirrored_attribute_map = $projection_type->getAttributes()->filter(
function (AttributeInterface $attribute) {
return (bool)$attribute->getOption('mirrored', false) === true;
}
);
// Don't need to load a referenced entity if the mirrored attribute map is empty
if ($mirrored_attribute_map->isEmpty()) {
return $projection;
}
// Load the referenced projection to mirror values from
$referenced_type = $this->projection_type_map->getByClassName(
$projection_type->getReferencedTypeClass()
);
$referenced_identifier = $projection->getReferencedIdentifier();
if (empty($referenced_identifier)) {
$this->logger->error('[Zombie Alarm] RefId EMPTY: '.json_encode($projection->getRoot()->toArray()));
return $projection;
}
if ($referenced_identifier === $projection->getRoot()->getIdentifier()) {
$referenced_projection = $projection->getRoot(); // self reference, no need to load
} else {
$referenced_projection = $this->loadReferencedProjection($referenced_type, $referenced_identifier);
if (!$referenced_projection) {
$this->logger->debug('[Zombie Alarm] Unable to load referenced projection: ' . $referenced_identifier);
return $projection;
}
}
// Add default attribute values
$mirrored_values['@type'] = $projection_type->getPrefix();
$mirrored_values['identifier'] = $projection->getIdentifier();
$mirrored_values['referenced_identifier'] = $projection->getReferencedIdentifier();
$mirrored_values = array_merge(
$projection->createMirrorFrom($referenced_projection)->toArray(),
$mirrored_values
);
return $projection_type->createEntity($mirrored_values, $projection->getParent());
} | php | protected function mirrorReferencedProjection(EntityReferenceInterface $projection)
{
$projection_type = $projection->getType();
$mirrored_attribute_map = $projection_type->getAttributes()->filter(
function (AttributeInterface $attribute) {
return (bool)$attribute->getOption('mirrored', false) === true;
}
);
// Don't need to load a referenced entity if the mirrored attribute map is empty
if ($mirrored_attribute_map->isEmpty()) {
return $projection;
}
// Load the referenced projection to mirror values from
$referenced_type = $this->projection_type_map->getByClassName(
$projection_type->getReferencedTypeClass()
);
$referenced_identifier = $projection->getReferencedIdentifier();
if (empty($referenced_identifier)) {
$this->logger->error('[Zombie Alarm] RefId EMPTY: '.json_encode($projection->getRoot()->toArray()));
return $projection;
}
if ($referenced_identifier === $projection->getRoot()->getIdentifier()) {
$referenced_projection = $projection->getRoot(); // self reference, no need to load
} else {
$referenced_projection = $this->loadReferencedProjection($referenced_type, $referenced_identifier);
if (!$referenced_projection) {
$this->logger->debug('[Zombie Alarm] Unable to load referenced projection: ' . $referenced_identifier);
return $projection;
}
}
// Add default attribute values
$mirrored_values['@type'] = $projection_type->getPrefix();
$mirrored_values['identifier'] = $projection->getIdentifier();
$mirrored_values['referenced_identifier'] = $projection->getReferencedIdentifier();
$mirrored_values = array_merge(
$projection->createMirrorFrom($referenced_projection)->toArray(),
$mirrored_values
);
return $projection_type->createEntity($mirrored_values, $projection->getParent());
} | [
"protected",
"function",
"mirrorReferencedProjection",
"(",
"EntityReferenceInterface",
"$",
"projection",
")",
"{",
"$",
"projection_type",
"=",
"$",
"projection",
"->",
"getType",
"(",
")",
";",
"$",
"mirrored_attribute_map",
"=",
"$",
"projection_type",
"->",
"ge... | Evaluate and updated mirrored values from a loaded referenced projection | [
"Evaluate",
"and",
"updated",
"mirrored",
"values",
"from",
"a",
"loaded",
"referenced",
"projection"
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Projection/EventHandler/ProjectionUpdater.php#L328-L372 | train |
peakphp/framework | src/Pipeline/AbstractProcessor.php | AbstractProcessor.resolvePipe | protected function resolvePipe($pipe, $payload)
{
if ($pipe instanceof Closure) {
// process pipe closure
return call_user_func($pipe, $payload);
} elseif ($pipe instanceof Pipeline) {
// process another pipeline instance
return $pipe->process($payload);
} elseif (is_string($pipe) && class_exists($pipe)) {
// process pipe class name
return $this->processPipeClassName($pipe, $payload);
} elseif (is_object($pipe)) {
// process pipe object instance
return $this->processPipeObject($pipe, $payload);
} elseif (is_callable($pipe)) {
// process callable pipe function
return $pipe($payload);
}
// unknown pipe type
throw new InvalidPipeException();
} | php | protected function resolvePipe($pipe, $payload)
{
if ($pipe instanceof Closure) {
// process pipe closure
return call_user_func($pipe, $payload);
} elseif ($pipe instanceof Pipeline) {
// process another pipeline instance
return $pipe->process($payload);
} elseif (is_string($pipe) && class_exists($pipe)) {
// process pipe class name
return $this->processPipeClassName($pipe, $payload);
} elseif (is_object($pipe)) {
// process pipe object instance
return $this->processPipeObject($pipe, $payload);
} elseif (is_callable($pipe)) {
// process callable pipe function
return $pipe($payload);
}
// unknown pipe type
throw new InvalidPipeException();
} | [
"protected",
"function",
"resolvePipe",
"(",
"$",
"pipe",
",",
"$",
"payload",
")",
"{",
"if",
"(",
"$",
"pipe",
"instanceof",
"Closure",
")",
"{",
"// process pipe closure",
"return",
"call_user_func",
"(",
"$",
"pipe",
",",
"$",
"payload",
")",
";",
"}",... | Resolve a pipe execution
@param mixed $pipe Support closure, class instance, class string, pipeline instance and pipe function name
@param mixed $payload Payload pass to each pipe
@return mixed
@throws MissingPipeInterfaceException
@throws InvalidPipeException | [
"Resolve",
"a",
"pipe",
"execution"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Pipeline/AbstractProcessor.php#L45-L66 | train |
peakphp/framework | src/Pipeline/AbstractProcessor.php | AbstractProcessor.processPipeClassName | protected function processPipeClassName(string $pipe, $payload)
{
if (isset($this->container)) {
$pinst = $this->container->get($pipe);
}
if (!isset($pinst)) {
$pinst = new $pipe();
}
if (!$pinst instanceof PipeInterface) {
throw new MissingPipeInterfaceException(get_class($pinst));
}
return $pinst($payload);
} | php | protected function processPipeClassName(string $pipe, $payload)
{
if (isset($this->container)) {
$pinst = $this->container->get($pipe);
}
if (!isset($pinst)) {
$pinst = new $pipe();
}
if (!$pinst instanceof PipeInterface) {
throw new MissingPipeInterfaceException(get_class($pinst));
}
return $pinst($payload);
} | [
"protected",
"function",
"processPipeClassName",
"(",
"string",
"$",
"pipe",
",",
"$",
"payload",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"container",
")",
")",
"{",
"$",
"pinst",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"... | Process Pipe string class name
@param string $pipe
@param mixed $payload
@return mixed
@throws MissingPipeInterfaceException | [
"Process",
"Pipe",
"string",
"class",
"name"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Pipeline/AbstractProcessor.php#L76-L91 | train |
peakphp/framework | src/Pipeline/AbstractProcessor.php | AbstractProcessor.processPipeObject | protected function processPipeObject(object $pipe, $payload)
{
if (!$pipe instanceof PipeInterface) {
throw new MissingPipeInterfaceException(get_class($pipe));
}
return $pipe($payload);
} | php | protected function processPipeObject(object $pipe, $payload)
{
if (!$pipe instanceof PipeInterface) {
throw new MissingPipeInterfaceException(get_class($pipe));
}
return $pipe($payload);
} | [
"protected",
"function",
"processPipeObject",
"(",
"object",
"$",
"pipe",
",",
"$",
"payload",
")",
"{",
"if",
"(",
"!",
"$",
"pipe",
"instanceof",
"PipeInterface",
")",
"{",
"throw",
"new",
"MissingPipeInterfaceException",
"(",
"get_class",
"(",
"$",
"pipe",
... | Process pipe class object
@param object $pipe
@param mixed $payload
@return mixed
@throws MissingPipeInterfaceException | [
"Process",
"pipe",
"class",
"object"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Pipeline/AbstractProcessor.php#L101-L107 | train |
honeybee/honeybee | src/Infrastructure/Workflow/WorkflowService.php | WorkflowService.resolveStateMachineName | public function resolveStateMachineName($arg)
{
if (is_string($arg) && empty(trim($arg))) {
throw new RuntimeError('State machine name must be a non-empty string.');
}
if (is_string($arg)) {
return $arg;
}
$default_suffix = $this->config->get('state_machine_name_suffix', 'default_workflow');
if ($arg instanceof AggregateRootTypeInterface || $arg instanceof ProjectionTypeInterface) {
return $arg->getPrefix() . '.' . $default_suffix;
} elseif ($arg instanceof AggregateRootInterface || $arg instanceof ProjectionInterface) {
return $arg->getType()->getPrefix() . '.' . $default_suffix;
} elseif (is_object($arg) && is_callable($arg, 'getStateMachineName')) {
return $arg->getStateMachineName();
} elseif (is_object($arg) && is_callable($arg, '__toString')) {
return (string)$arg;
}
throw new RuntimeError('Could not resolve a state machine name for given argument.');
} | php | public function resolveStateMachineName($arg)
{
if (is_string($arg) && empty(trim($arg))) {
throw new RuntimeError('State machine name must be a non-empty string.');
}
if (is_string($arg)) {
return $arg;
}
$default_suffix = $this->config->get('state_machine_name_suffix', 'default_workflow');
if ($arg instanceof AggregateRootTypeInterface || $arg instanceof ProjectionTypeInterface) {
return $arg->getPrefix() . '.' . $default_suffix;
} elseif ($arg instanceof AggregateRootInterface || $arg instanceof ProjectionInterface) {
return $arg->getType()->getPrefix() . '.' . $default_suffix;
} elseif (is_object($arg) && is_callable($arg, 'getStateMachineName')) {
return $arg->getStateMachineName();
} elseif (is_object($arg) && is_callable($arg, '__toString')) {
return (string)$arg;
}
throw new RuntimeError('Could not resolve a state machine name for given argument.');
} | [
"public",
"function",
"resolveStateMachineName",
"(",
"$",
"arg",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"arg",
")",
"&&",
"empty",
"(",
"trim",
"(",
"$",
"arg",
")",
")",
")",
"{",
"throw",
"new",
"RuntimeError",
"(",
"'State machine name must be a n... | Resolves a name for the given item that can be used to build or lookup an already built state machine.
@param mixed $arg object to resolve a name for
@return string name to use for state machine lookups/building
@throws RuntimeError when no name can be resolved | [
"Resolves",
"a",
"name",
"for",
"the",
"given",
"item",
"that",
"can",
"be",
"used",
"to",
"build",
"or",
"lookup",
"an",
"already",
"built",
"state",
"machine",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/WorkflowService.php#L56-L79 | train |
milejko/mmi | src/Mmi/Mvc/View.php | View.getAllVariables | public function getAllVariables()
{
//pobranie danych widoku
$data = $this->_data;
//iteracja po danych
foreach ($data as $key => $value) {
//kasowanie danych prywatnych mmi (zaczynają się od _)
if ($key[0] == '_') {
//usuwanie klucza
unset($data[$key]);
}
}
//zwrot danych
return $data;
} | php | public function getAllVariables()
{
//pobranie danych widoku
$data = $this->_data;
//iteracja po danych
foreach ($data as $key => $value) {
//kasowanie danych prywatnych mmi (zaczynają się od _)
if ($key[0] == '_') {
//usuwanie klucza
unset($data[$key]);
}
}
//zwrot danych
return $data;
} | [
"public",
"function",
"getAllVariables",
"(",
")",
"{",
"//pobranie danych widoku",
"$",
"data",
"=",
"$",
"this",
"->",
"_data",
";",
"//iteracja po danych",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//kasowanie danych pryw... | Pobiera wszystkie zmienne w postaci tablicy
@return array | [
"Pobiera",
"wszystkie",
"zmienne",
"w",
"postaci",
"tablicy"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L237-L251 | train |
milejko/mmi | src/Mmi/Mvc/View.php | View.renderTemplate | public function renderTemplate($path)
{
//wyszukiwanie template
if (null === $template = $this->getTemplateByPath($path)) {
//brak template
return;
}
//kompilacja szablonu
return $this->_compileTemplate(file_get_contents($template), BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_' . str_replace(['/', '\\', '_Resource_template_'], '_', substr($template, strrpos($template, '/src') + 5, -4) . '.php'));
} | php | public function renderTemplate($path)
{
//wyszukiwanie template
if (null === $template = $this->getTemplateByPath($path)) {
//brak template
return;
}
//kompilacja szablonu
return $this->_compileTemplate(file_get_contents($template), BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_' . str_replace(['/', '\\', '_Resource_template_'], '_', substr($template, strrpos($template, '/src') + 5, -4) . '.php'));
} | [
"public",
"function",
"renderTemplate",
"(",
"$",
"path",
")",
"{",
"//wyszukiwanie template",
"if",
"(",
"null",
"===",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplateByPath",
"(",
"$",
"path",
")",
")",
"{",
"//brak template",
"return",
";",
"}",
"... | Renderuje i zwraca wynik wykonania template
@param string $path ścieżka np. news/index/index
@param bool $fetch przekaż wynik wywołania w zmiennej
@return string | [
"Renderuje",
"i",
"zwraca",
"wynik",
"wykonania",
"template"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L310-L319 | train |
milejko/mmi | src/Mmi/Mvc/View.php | View.renderLayout | public function renderLayout($content, \Mmi\Http\Request $request)
{
return $this->isLayoutDisabled() ? $content : $this
//ustawianie treści w placeholder 'content'
->setPlaceholder('content', $content)
//renderowanie layoutu
->renderTemplate($this->_getLayout($request));
} | php | public function renderLayout($content, \Mmi\Http\Request $request)
{
return $this->isLayoutDisabled() ? $content : $this
//ustawianie treści w placeholder 'content'
->setPlaceholder('content', $content)
//renderowanie layoutu
->renderTemplate($this->_getLayout($request));
} | [
"public",
"function",
"renderLayout",
"(",
"$",
"content",
",",
"\\",
"Mmi",
"\\",
"Http",
"\\",
"Request",
"$",
"request",
")",
"{",
"return",
"$",
"this",
"->",
"isLayoutDisabled",
"(",
")",
"?",
"$",
"content",
":",
"$",
"this",
"//ustawianie treści w p... | Renderuje i zwraca wynik wykonania layoutu z ustawionym contentem
@param string $content
@param \Mmi\Http\Request $request
@return string | [
"Renderuje",
"i",
"zwraca",
"wynik",
"wykonania",
"layoutu",
"z",
"ustawionym",
"contentem"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L327-L334 | train |
milejko/mmi | src/Mmi/Mvc/View.php | View.renderDirectly | public function renderDirectly($templateCode)
{
//kompilacja szablonu
return $this->_compileTemplate($templateCode, BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_direct_' . md5($templateCode) . '.php');
} | php | public function renderDirectly($templateCode)
{
//kompilacja szablonu
return $this->_compileTemplate($templateCode, BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_direct_' . md5($templateCode) . '.php');
} | [
"public",
"function",
"renderDirectly",
"(",
"$",
"templateCode",
")",
"{",
"//kompilacja szablonu",
"return",
"$",
"this",
"->",
"_compileTemplate",
"(",
"$",
"templateCode",
",",
"BASE_PATH",
".",
"'/var/compile/'",
".",
"\\",
"App",
"\\",
"Registry",
"::",
"$... | Generowanie kodu PHP z kodu szablonu w locie
@param string $templateCode kod szablonu
@return string kod PHP | [
"Generowanie",
"kodu",
"PHP",
"z",
"kodu",
"szablonu",
"w",
"locie"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L341-L345 | train |
milejko/mmi | src/Mmi/Image/Image.php | Image.inputToResource | public static function inputToResource($input)
{
//jeśli resource zwrot
if (gettype($input) == 'resource') {
return $input;
}
//jeśli krótki content zakłada że to ścieżka pliku
return imagecreatefromstring((strlen($input) < self::BINARY_MIN_LENGTH) ? file_get_contents($input) : $input);
} | php | public static function inputToResource($input)
{
//jeśli resource zwrot
if (gettype($input) == 'resource') {
return $input;
}
//jeśli krótki content zakłada że to ścieżka pliku
return imagecreatefromstring((strlen($input) < self::BINARY_MIN_LENGTH) ? file_get_contents($input) : $input);
} | [
"public",
"static",
"function",
"inputToResource",
"(",
"$",
"input",
")",
"{",
"//jeśli resource zwrot",
"if",
"(",
"gettype",
"(",
"$",
"input",
")",
"==",
"'resource'",
")",
"{",
"return",
"$",
"input",
";",
"}",
"//jeśli krótki content zakłada że to ścieżka pl... | Konwertuje string, lub binaria do zasobu GD
@param mixed $input
@return resource | [
"Konwertuje",
"string",
"lub",
"binaria",
"do",
"zasobu",
"GD"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Image/Image.php#L27-L35 | train |
peakphp/framework | src/Common/TimeExpression.php | TimeExpression.dateIntervalToIntervalSpec | public static function dateIntervalToIntervalSpec(DateInterval $di): string
{
$time_parts = ['h', 'i', 's', 'f'];
$time_token_set = false;
$interval_spec = 'P';
foreach (array_keys(self::$tokens) as $token) {
if (in_array($token, $time_parts) && $time_token_set === false && $di->$token > 0) {
$interval_spec .= 'T';
$time_token_set = true;
}
if ($di->$token > 0) {
$token_string = $token;
if (array_key_exists($token, self::$tokensSubstitution)) {
$token_string = self::$tokensSubstitution[$token];
}
$interval_spec .= $di->$token.strtoupper($token_string);
}
}
return $interval_spec;
} | php | public static function dateIntervalToIntervalSpec(DateInterval $di): string
{
$time_parts = ['h', 'i', 's', 'f'];
$time_token_set = false;
$interval_spec = 'P';
foreach (array_keys(self::$tokens) as $token) {
if (in_array($token, $time_parts) && $time_token_set === false && $di->$token > 0) {
$interval_spec .= 'T';
$time_token_set = true;
}
if ($di->$token > 0) {
$token_string = $token;
if (array_key_exists($token, self::$tokensSubstitution)) {
$token_string = self::$tokensSubstitution[$token];
}
$interval_spec .= $di->$token.strtoupper($token_string);
}
}
return $interval_spec;
} | [
"public",
"static",
"function",
"dateIntervalToIntervalSpec",
"(",
"DateInterval",
"$",
"di",
")",
":",
"string",
"{",
"$",
"time_parts",
"=",
"[",
"'h'",
",",
"'i'",
",",
"'s'",
",",
"'f'",
"]",
";",
"$",
"time_token_set",
"=",
"false",
";",
"$",
"inter... | Transform a DateInterval to a valid ISO8601 interval
@param DateInterval $di
@return string | [
"Transform",
"a",
"DateInterval",
"to",
"a",
"valid",
"ISO8601",
"interval"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L238-L259 | train |
peakphp/framework | src/Common/TimeExpression.php | TimeExpression.decodeIntervalSpec | protected function decodeIntervalSpec(): void
{
$this->di = new DateInterval($this->expression);
$this->time = (new DateTime('@0'))
->add($this->di)
->getTimestamp();
} | php | protected function decodeIntervalSpec(): void
{
$this->di = new DateInterval($this->expression);
$this->time = (new DateTime('@0'))
->add($this->di)
->getTimestamp();
} | [
"protected",
"function",
"decodeIntervalSpec",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"di",
"=",
"new",
"DateInterval",
"(",
"$",
"this",
"->",
"expression",
")",
";",
"$",
"this",
"->",
"time",
"=",
"(",
"new",
"DateTime",
"(",
"'@0'",
")",
... | Decode a DateInterval Interval spec format
@throws Exception | [
"Decode",
"a",
"DateInterval",
"Interval",
"spec",
"format"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L343-L349 | train |
peakphp/framework | src/Common/TimeExpression.php | TimeExpression.decodeRegexString | protected function decodeRegexString(): bool
{
$regex_string = '#([0-9]+)[\s]*('.implode('|', array_keys($this->tokensValues)).'){1}#i';
$regex_clock_string = '#^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$#i';
if (preg_match_all($regex_string, $this->expression, $matches)) {
foreach ($matches[1] as $index => $value) {
$this->time += $this->tokensValues[$matches[2][$index]] * $value;
}
$this->di = DateInterval::createFromDateString($this->integerToString($this->time));
return true;
} elseif (preg_match_all($regex_clock_string, $this->expression, $matches) && count($matches) == 4) {
if (!empty($matches[1][0])) {
$this->time += (int)$matches[1][0] * 3600;
}
if (!empty($matches[2][0])) {
$this->time += (int)$matches[2][0] * 60;
}
if (!empty($matches[3][0])) {
$this->time += (int)$matches[3][0];
}
$this->di = DateInterval::createFromDateString($this->integerToString($this->time));
return true;
}
return false;
} | php | protected function decodeRegexString(): bool
{
$regex_string = '#([0-9]+)[\s]*('.implode('|', array_keys($this->tokensValues)).'){1}#i';
$regex_clock_string = '#^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$#i';
if (preg_match_all($regex_string, $this->expression, $matches)) {
foreach ($matches[1] as $index => $value) {
$this->time += $this->tokensValues[$matches[2][$index]] * $value;
}
$this->di = DateInterval::createFromDateString($this->integerToString($this->time));
return true;
} elseif (preg_match_all($regex_clock_string, $this->expression, $matches) && count($matches) == 4) {
if (!empty($matches[1][0])) {
$this->time += (int)$matches[1][0] * 3600;
}
if (!empty($matches[2][0])) {
$this->time += (int)$matches[2][0] * 60;
}
if (!empty($matches[3][0])) {
$this->time += (int)$matches[3][0];
}
$this->di = DateInterval::createFromDateString($this->integerToString($this->time));
return true;
}
return false;
} | [
"protected",
"function",
"decodeRegexString",
"(",
")",
":",
"bool",
"{",
"$",
"regex_string",
"=",
"'#([0-9]+)[\\s]*('",
".",
"implode",
"(",
"'|'",
",",
"array_keys",
"(",
"$",
"this",
"->",
"tokensValues",
")",
")",
".",
"'){1}#i'",
";",
"$",
"regex_clock... | Decode string with customs regex formats
@return bool | [
"Decode",
"string",
"with",
"customs",
"regex",
"formats"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L371-L397 | train |
peakphp/framework | src/Common/TimeExpression.php | TimeExpression.integerToString | protected function integerToString($time): string
{
$tokens = array_reverse($this->tokensValues, true);
$expression = [];
foreach ($tokens as $token => $value) {
if ($time <= 0) {
break;
}
if ($time < $value || !in_array($token, array_keys($this->tokensValues))) {
continue;
}
$mod = 0;
if ($time & $value) {
$mod = fmod($time, $value);
$time -= $mod;
}
$div = round($time / $value);
$expression[] = sprintf(
'%d %s',
$div,
($token.(($div > 1 && substr($token, -1, 1) !== 's') ? 's' : ''))
);
$time = $mod;
}
$return = implode(' ', $expression);
if (empty($return)) {
$return = sprintf('%d %s', 0, 'ms');
}
return $return;
} | php | protected function integerToString($time): string
{
$tokens = array_reverse($this->tokensValues, true);
$expression = [];
foreach ($tokens as $token => $value) {
if ($time <= 0) {
break;
}
if ($time < $value || !in_array($token, array_keys($this->tokensValues))) {
continue;
}
$mod = 0;
if ($time & $value) {
$mod = fmod($time, $value);
$time -= $mod;
}
$div = round($time / $value);
$expression[] = sprintf(
'%d %s',
$div,
($token.(($div > 1 && substr($token, -1, 1) !== 's') ? 's' : ''))
);
$time = $mod;
}
$return = implode(' ', $expression);
if (empty($return)) {
$return = sprintf('%d %s', 0, 'ms');
}
return $return;
} | [
"protected",
"function",
"integerToString",
"(",
"$",
"time",
")",
":",
"string",
"{",
"$",
"tokens",
"=",
"array_reverse",
"(",
"$",
"this",
"->",
"tokensValues",
",",
"true",
")",
";",
"$",
"expression",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"toke... | Transform an integer to a non ISO8601 interval string
@param integer $time
@return string | [
"Transform",
"an",
"integer",
"to",
"a",
"non",
"ISO8601",
"interval",
"string"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L405-L438 | train |
honeybee/honeybee | src/Infrastructure/Config/Config.php | Config.validateConfig | protected function validateConfig(SettingsInterface $settings)
{
foreach ($this->getRequiredSettings() as $required_setting) {
if (is_null($settings->getValues($required_setting))) {
throw new ConfigError(
"Missing mandatory setting '" . $required_setting . "' for config."
);
}
}
} | php | protected function validateConfig(SettingsInterface $settings)
{
foreach ($this->getRequiredSettings() as $required_setting) {
if (is_null($settings->getValues($required_setting))) {
throw new ConfigError(
"Missing mandatory setting '" . $required_setting . "' for config."
);
}
}
} | [
"protected",
"function",
"validateConfig",
"(",
"SettingsInterface",
"$",
"settings",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRequiredSettings",
"(",
")",
"as",
"$",
"required_setting",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"settings",
"->",
"ge... | Validate the given settings against any required rules.
This basic implementation just makes sure,
that all required settings are in place.
@param SettingsInterface $settings
@throws ConfigError | [
"Validate",
"the",
"given",
"settings",
"against",
"any",
"required",
"rules",
".",
"This",
"basic",
"implementation",
"just",
"makes",
"sure",
"that",
"all",
"required",
"settings",
"are",
"in",
"place",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Config.php#L144-L153 | train |
milejko/mmi | src/Mmi/Navigation/NavigationConfig.php | NavigationConfig.addElement | public function addElement(\Mmi\Navigation\NavigationConfigElement $element)
{
$this->_data[$element->getId()] = $element;
return $this;
} | php | public function addElement(\Mmi\Navigation\NavigationConfigElement $element)
{
$this->_data[$element->getId()] = $element;
return $this;
} | [
"public",
"function",
"addElement",
"(",
"\\",
"Mmi",
"\\",
"Navigation",
"\\",
"NavigationConfigElement",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"$",
"element",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"element",
";",
"return",
"$",
... | Dodaje element nawigatora
@param \Mmi\Navigation\NavigationConfigElement $element
@return \Mmi\Navigation\NavigationConfig | [
"Dodaje",
"element",
"nawigatora"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L42-L46 | train |
milejko/mmi | src/Mmi/Navigation/NavigationConfig.php | NavigationConfig.findById | public function findById($id, $withParents = false)
{
$parents = [];
foreach ($this->build() as $element) {
if (null !== ($found = $this->_findInChildren($element, $id, $withParents, $parents))) {
if ($withParents) {
$found['parents'] = array_reverse($parents);
}
return $found;
}
}
} | php | public function findById($id, $withParents = false)
{
$parents = [];
foreach ($this->build() as $element) {
if (null !== ($found = $this->_findInChildren($element, $id, $withParents, $parents))) {
if ($withParents) {
$found['parents'] = array_reverse($parents);
}
return $found;
}
}
} | [
"public",
"function",
"findById",
"(",
"$",
"id",
",",
"$",
"withParents",
"=",
"false",
")",
"{",
"$",
"parents",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"build",
"(",
")",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"null",
"!==",... | Znajduje element po identyfikatorze
@param int $id identyfikator
@return \Mmi\Navigation\NavigationConfigElement | [
"Znajduje",
"element",
"po",
"identyfikatorze"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L62-L73 | train |
milejko/mmi | src/Mmi/Navigation/NavigationConfig.php | NavigationConfig._findInChildren | protected function _findInChildren(array $element, $id, $withParents, array &$parents)
{
if ($element['id'] == $id) {
return $element;
}
foreach ($element['children'] as $child) {
if ($child['id'] == $id) {
if ($withParents) {
$parents[] = $element;
}
return $child;
}
if (null !== ($found = $this->_findInChildren($child, $id, $withParents, $parents))) {
if ($withParents) {
$parents[] = $element;
}
return $found;
}
}
} | php | protected function _findInChildren(array $element, $id, $withParents, array &$parents)
{
if ($element['id'] == $id) {
return $element;
}
foreach ($element['children'] as $child) {
if ($child['id'] == $id) {
if ($withParents) {
$parents[] = $element;
}
return $child;
}
if (null !== ($found = $this->_findInChildren($child, $id, $withParents, $parents))) {
if ($withParents) {
$parents[] = $element;
}
return $found;
}
}
} | [
"protected",
"function",
"_findInChildren",
"(",
"array",
"$",
"element",
",",
"$",
"id",
",",
"$",
"withParents",
",",
"array",
"&",
"$",
"parents",
")",
"{",
"if",
"(",
"$",
"element",
"[",
"'id'",
"]",
"==",
"$",
"id",
")",
"{",
"return",
"$",
"... | Rekurencyjnie przeszukuje elementy potomne
@param $element
@param int $id identyfikator
@return array | [
"Rekurencyjnie",
"przeszukuje",
"elementy",
"potomne"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L81-L100 | train |
milejko/mmi | src/Mmi/Navigation/NavigationConfig.php | NavigationConfig.build | public function build()
{
if (!empty($this->build)) {
return $this->build;
}
//root
$this->build = [[
'active' => true,
'name' => '',
'label' => '',
'id' => 'root',
'level' => 0,
'uri' => '',
'children' => []
]];
foreach ($this->_data as $element) {
$this->build[0]['children'][$element->getId()] = $element->build();
}
//usuwanie konfiguracji po zbudowaniu
$this->_data = [];
return $this->build;
} | php | public function build()
{
if (!empty($this->build)) {
return $this->build;
}
//root
$this->build = [[
'active' => true,
'name' => '',
'label' => '',
'id' => 'root',
'level' => 0,
'uri' => '',
'children' => []
]];
foreach ($this->_data as $element) {
$this->build[0]['children'][$element->getId()] = $element->build();
}
//usuwanie konfiguracji po zbudowaniu
$this->_data = [];
return $this->build;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"build",
")",
")",
"{",
"return",
"$",
"this",
"->",
"build",
";",
"}",
"//root",
"$",
"this",
"->",
"build",
"=",
"[",
"[",
"'active'",
"=>",
"true",
... | Buduje wszystkie obiekty
@return array | [
"Buduje",
"wszystkie",
"obiekty"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L106-L127 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.