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
matt-allan/neko
src/Neko.php
Neko.snakeCase
public static function snakeCase($value) { $key = $value; if (isset(static::$snakeCache[$key])) { return static::$snakeCache[$key]; } $value = preg_replace('/\s+/', '', ucwords($value)); $value = str_replace('-', '_', $value); $value = static::normalizeScreamingCase($value); return static::$snakeCache[$key] = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $value)); }
php
public static function snakeCase($value) { $key = $value; if (isset(static::$snakeCache[$key])) { return static::$snakeCache[$key]; } $value = preg_replace('/\s+/', '', ucwords($value)); $value = str_replace('-', '_', $value); $value = static::normalizeScreamingCase($value); return static::$snakeCache[$key] = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $value)); }
[ "public", "static", "function", "snakeCase", "(", "$", "value", ")", "{", "$", "key", "=", "$", "value", ";", "if", "(", "isset", "(", "static", "::", "$", "snakeCache", "[", "$", "key", "]", ")", ")", "{", "return", "static", "::", "$", "snakeCach...
Convert a value to snake_case. @param string $value @return string
[ "Convert", "a", "value", "to", "snake_case", "." ]
7c138d723fb78c72860128e91f24949007d2dd61
https://github.com/matt-allan/neko/blob/7c138d723fb78c72860128e91f24949007d2dd61/src/Neko.php#L46-L57
train
matt-allan/neko
src/Neko.php
Neko.kebabCase
public static function kebabCase($value) { $key = $value; if (isset(static::$kebabCache[$key])) { return static::$kebabCache[$key]; } $value = preg_replace('/\s+/', '', ucwords($value)); $value = str_replace('_', '-', $value); $value = static::normalizeScreamingCase($value); return static::$kebabCache[$key] = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '-$1', $value)); }
php
public static function kebabCase($value) { $key = $value; if (isset(static::$kebabCache[$key])) { return static::$kebabCache[$key]; } $value = preg_replace('/\s+/', '', ucwords($value)); $value = str_replace('_', '-', $value); $value = static::normalizeScreamingCase($value); return static::$kebabCache[$key] = strtolower(preg_replace('~(?<=\\w)([A-Z])~', '-$1', $value)); }
[ "public", "static", "function", "kebabCase", "(", "$", "value", ")", "{", "$", "key", "=", "$", "value", ";", "if", "(", "isset", "(", "static", "::", "$", "kebabCache", "[", "$", "key", "]", ")", ")", "{", "return", "static", "::", "$", "kebabCach...
Convert a value to kebab-case. @param string $value @return string
[ "Convert", "a", "value", "to", "kebab", "-", "case", "." ]
7c138d723fb78c72860128e91f24949007d2dd61
https://github.com/matt-allan/neko/blob/7c138d723fb78c72860128e91f24949007d2dd61/src/Neko.php#L65-L76
train
matt-allan/neko
src/Neko.php
Neko.pascalCase
public static function pascalCase($value) { if (isset(static::$pascalCache[$value])) { return static::$pascalCache[$value]; } $value = static::normalizeScreamingCase($value); return static::$pascalCache[$value] = str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $value))); }
php
public static function pascalCase($value) { if (isset(static::$pascalCache[$value])) { return static::$pascalCache[$value]; } $value = static::normalizeScreamingCase($value); return static::$pascalCache[$value] = str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $value))); }
[ "public", "static", "function", "pascalCase", "(", "$", "value", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "pascalCache", "[", "$", "value", "]", ")", ")", "{", "return", "static", "::", "$", "pascalCache", "[", "$", "value", "]", ";", ...
Convert a value to PascalCase. @param string $value @return string
[ "Convert", "a", "value", "to", "PascalCase", "." ]
7c138d723fb78c72860128e91f24949007d2dd61
https://github.com/matt-allan/neko/blob/7c138d723fb78c72860128e91f24949007d2dd61/src/Neko.php#L84-L92
train
matt-allan/neko
src/Neko.php
Neko.camelCase
public static function camelCase($value) { if (isset(static::$camelCache[$value])) { return static::$camelCache[$value]; } return static::$camelCache[$value] = lcfirst(static::pascalCase($value)); }
php
public static function camelCase($value) { if (isset(static::$camelCache[$value])) { return static::$camelCache[$value]; } return static::$camelCache[$value] = lcfirst(static::pascalCase($value)); }
[ "public", "static", "function", "camelCase", "(", "$", "value", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "camelCache", "[", "$", "value", "]", ")", ")", "{", "return", "static", "::", "$", "camelCache", "[", "$", "value", "]", ";", "...
Convert a value to camelCase. @param string $value @return string
[ "Convert", "a", "value", "to", "camelCase", "." ]
7c138d723fb78c72860128e91f24949007d2dd61
https://github.com/matt-allan/neko/blob/7c138d723fb78c72860128e91f24949007d2dd61/src/Neko.php#L100-L107
train
milejko/mmi-cms
src/Cms/CategoryController.php
CategoryController.dispatchAction
public function dispatchAction() { //pobranie kategorii $category = $this->_getPublishedCategoryByUri($this->uri); //wpięcie kategorii do głównego widoku aplikacji FrontController::getInstance()->getView()->category = $category; //klucz bufora $cacheKey = 'category-html-' . $category->id; //buforowanie dozwolone $bufferingAllowed = $this->_bufferingAllowed(); //wczytanie zbuforowanej strony (dla niezalogowanych i z pustym requestem) if ($bufferingAllowed && (null !== $html = \App\Registry::$cache->load($cacheKey))) { //wysyłanie nagłówka o buforowaniu strony $this->getResponse()->setHeader('X-Cache', 'HIT'); //zwrot html return $this->_decorateHtmlWithEditButton($html, $category); } //wysyłanie nagłówka o braku buforowaniu strony $this->getResponse()->setHeader('X-Cache', 'MISS'); //przekazanie rekordu kategorii do widoku $this->view->category = $category; //renderowanie docelowej akcji $html = \Mmi\Mvc\ActionHelper::getInstance()->forward($this->_prepareForwardRequest($category)); //buforowanie niedozwolone if (!$bufferingAllowed || 0 == $cacheLifetime = $this->_getCategoryCacheLifetime($category)) { //zwrot html return $this->_decorateHtmlWithEditButton($html, $category); } //zapis html kategorii do cache \App\Registry::$cache->save($html, $cacheKey, $cacheLifetime); //zwrot html return $this->_decorateHtmlWithEditButton($html, $category); }
php
public function dispatchAction() { //pobranie kategorii $category = $this->_getPublishedCategoryByUri($this->uri); //wpięcie kategorii do głównego widoku aplikacji FrontController::getInstance()->getView()->category = $category; //klucz bufora $cacheKey = 'category-html-' . $category->id; //buforowanie dozwolone $bufferingAllowed = $this->_bufferingAllowed(); //wczytanie zbuforowanej strony (dla niezalogowanych i z pustym requestem) if ($bufferingAllowed && (null !== $html = \App\Registry::$cache->load($cacheKey))) { //wysyłanie nagłówka o buforowaniu strony $this->getResponse()->setHeader('X-Cache', 'HIT'); //zwrot html return $this->_decorateHtmlWithEditButton($html, $category); } //wysyłanie nagłówka o braku buforowaniu strony $this->getResponse()->setHeader('X-Cache', 'MISS'); //przekazanie rekordu kategorii do widoku $this->view->category = $category; //renderowanie docelowej akcji $html = \Mmi\Mvc\ActionHelper::getInstance()->forward($this->_prepareForwardRequest($category)); //buforowanie niedozwolone if (!$bufferingAllowed || 0 == $cacheLifetime = $this->_getCategoryCacheLifetime($category)) { //zwrot html return $this->_decorateHtmlWithEditButton($html, $category); } //zapis html kategorii do cache \App\Registry::$cache->save($html, $cacheKey, $cacheLifetime); //zwrot html return $this->_decorateHtmlWithEditButton($html, $category); }
[ "public", "function", "dispatchAction", "(", ")", "{", "//pobranie kategorii", "$", "category", "=", "$", "this", "->", "_getPublishedCategoryByUri", "(", "$", "this", "->", "uri", ")", ";", "//wpięcie kategorii do głównego widoku aplikacji", "FrontController", "::", ...
Akcja dispatchera kategorii
[ "Akcja", "dispatchera", "kategorii" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/CategoryController.php#L28-L60
train
milejko/mmi-cms
src/Cms/CategoryController.php
CategoryController._prepareForwardRequest
protected function _prepareForwardRequest(\Cms\Orm\CmsCategoryRecord $category) { //tworzenie nowego requestu na podstawie obecnego $request = clone $this->getRequest(); $request->setModuleName('cms') ->setControllerName('category') ->setActionName('article'); //przekierowanie MVC if ($category->mvcParams) { //tablica z tpl $mvcParams = []; //parsowanie parametrów mvc parse_str($category->mvcParams, $mvcParams); return $request->setParams($mvcParams); } //pobranie typu (szablonu) i jego parametrów mvc if (!$category->getJoined('cms_category_type')->mvcParams) { return $request; } //tablica z tpl $mvcParams = []; //parsowanie parametrów mvc parse_str($category->getJoined('cms_category_type')->mvcParams, $mvcParams); return $request->setParams($mvcParams); }
php
protected function _prepareForwardRequest(\Cms\Orm\CmsCategoryRecord $category) { //tworzenie nowego requestu na podstawie obecnego $request = clone $this->getRequest(); $request->setModuleName('cms') ->setControllerName('category') ->setActionName('article'); //przekierowanie MVC if ($category->mvcParams) { //tablica z tpl $mvcParams = []; //parsowanie parametrów mvc parse_str($category->mvcParams, $mvcParams); return $request->setParams($mvcParams); } //pobranie typu (szablonu) i jego parametrów mvc if (!$category->getJoined('cms_category_type')->mvcParams) { return $request; } //tablica z tpl $mvcParams = []; //parsowanie parametrów mvc parse_str($category->getJoined('cms_category_type')->mvcParams, $mvcParams); return $request->setParams($mvcParams); }
[ "protected", "function", "_prepareForwardRequest", "(", "\\", "Cms", "\\", "Orm", "\\", "CmsCategoryRecord", "$", "category", ")", "{", "//tworzenie nowego requestu na podstawie obecnego", "$", "request", "=", "clone", "$", "this", "->", "getRequest", "(", ")", ";",...
Pobiera request do przekierowania @param \Cms\Orm\CmsCategoryRecord $category @return \Mmi\Http\Request @throws \Mmi\App\KernelException
[ "Pobiera", "request", "do", "przekierowania" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/CategoryController.php#L193-L217
train
milejko/mmi-cms
src/Cms/CategoryController.php
CategoryController._decorateHtmlWithEditButton
protected function _decorateHtmlWithEditButton($html, \Cms\Orm\CmsCategoryRecord $category) { //brak roli redaktora if (!$this->_hasRedactorRole()) { return $html; } //zwraca wyrenderowany HTML return str_replace('</body>', \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => 'cms', 'controller' => 'category', 'action' => 'editButton', 'originalId' => $category->cmsCategoryOriginalId, 'categoryId' => $category->id])) . '</body>', $html); }
php
protected function _decorateHtmlWithEditButton($html, \Cms\Orm\CmsCategoryRecord $category) { //brak roli redaktora if (!$this->_hasRedactorRole()) { return $html; } //zwraca wyrenderowany HTML return str_replace('</body>', \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(['module' => 'cms', 'controller' => 'category', 'action' => 'editButton', 'originalId' => $category->cmsCategoryOriginalId, 'categoryId' => $category->id])) . '</body>', $html); }
[ "protected", "function", "_decorateHtmlWithEditButton", "(", "$", "html", ",", "\\", "Cms", "\\", "Orm", "\\", "CmsCategoryRecord", "$", "category", ")", "{", "//brak roli redaktora", "if", "(", "!", "$", "this", "->", "_hasRedactorRole", "(", ")", ")", "{", ...
Pobiera request do renderowania akcji @param \Cms\Orm\CmsCategoryRecord $category @return string @throws \Mmi\App\KernelException
[ "Pobiera", "request", "do", "renderowania", "akcji" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/CategoryController.php#L225-L233
train
milejko/mmi-cms
src/Cms/CategoryController.php
CategoryController._getCategoryCacheLifetime
protected function _getCategoryCacheLifetime(\Cms\Orm\CmsCategoryRecord $category) { //czas buforowania (na podstawie typu kategorii i pojedynczej kategorii $cacheLifetime = (null !== $category->cacheLifetime) ? $category->cacheLifetime : ((null !== $category->getJoined('cms_category_type')->cacheLifetime) ? $category->getJoined('cms_category_type')->cacheLifetime : Orm\CmsCategoryRecord::DEFAULT_CACHE_LIFETIME); //jeśli bufor wyłączony (na poziomie typu kategorii, lub pojedynczej kategorii) if (0 == $cacheLifetime) { //brak bufora return 0; } //iteracja po widgetach foreach ($category->getWidgetModel()->getWidgetRelations() as $widgetRelation) { //bufor wyłączony przez widget if (0 == $widgetCacheLifetime = $widgetRelation->getWidgetRecord()->cacheLifetime) { //brak bufora return 0; } //wpływ widgeta na czas buforowania kategorii $cacheLifetime = ($cacheLifetime > $widgetCacheLifetime) ? $widgetCacheLifetime : $cacheLifetime; } //zwrot długości bufora return $cacheLifetime; }
php
protected function _getCategoryCacheLifetime(\Cms\Orm\CmsCategoryRecord $category) { //czas buforowania (na podstawie typu kategorii i pojedynczej kategorii $cacheLifetime = (null !== $category->cacheLifetime) ? $category->cacheLifetime : ((null !== $category->getJoined('cms_category_type')->cacheLifetime) ? $category->getJoined('cms_category_type')->cacheLifetime : Orm\CmsCategoryRecord::DEFAULT_CACHE_LIFETIME); //jeśli bufor wyłączony (na poziomie typu kategorii, lub pojedynczej kategorii) if (0 == $cacheLifetime) { //brak bufora return 0; } //iteracja po widgetach foreach ($category->getWidgetModel()->getWidgetRelations() as $widgetRelation) { //bufor wyłączony przez widget if (0 == $widgetCacheLifetime = $widgetRelation->getWidgetRecord()->cacheLifetime) { //brak bufora return 0; } //wpływ widgeta na czas buforowania kategorii $cacheLifetime = ($cacheLifetime > $widgetCacheLifetime) ? $widgetCacheLifetime : $cacheLifetime; } //zwrot długości bufora return $cacheLifetime; }
[ "protected", "function", "_getCategoryCacheLifetime", "(", "\\", "Cms", "\\", "Orm", "\\", "CmsCategoryRecord", "$", "category", ")", "{", "//czas buforowania (na podstawie typu kategorii i pojedynczej kategorii", "$", "cacheLifetime", "=", "(", "null", "!==", "$", "categ...
Zwraca czas buforowania kategorii @return integer
[ "Zwraca", "czas", "buforowania", "kategorii" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/CategoryController.php#L239-L260
train
milejko/mmi-cms
src/Cms/CategoryController.php
CategoryController._bufferingAllowed
protected function _bufferingAllowed() { //jeśli zdefiniowano własny obiekt sprawdzający, czy można buforować if (\App\Registry::$config->category instanceof \Cms\Config\CategoryConfig && \App\Registry::$config->category->bufferingAllowedClass) { $class = \App\Registry::$config->category->bufferingAllowedClass; $buffering = new $class($this->_request); } else { //domyślny cmsowy obiekt sprawdzający, czy można buforować $buffering = new \Cms\Model\CategoryBuffering($this->_request); } return $buffering->isAllowed(); }
php
protected function _bufferingAllowed() { //jeśli zdefiniowano własny obiekt sprawdzający, czy można buforować if (\App\Registry::$config->category instanceof \Cms\Config\CategoryConfig && \App\Registry::$config->category->bufferingAllowedClass) { $class = \App\Registry::$config->category->bufferingAllowedClass; $buffering = new $class($this->_request); } else { //domyślny cmsowy obiekt sprawdzający, czy można buforować $buffering = new \Cms\Model\CategoryBuffering($this->_request); } return $buffering->isAllowed(); }
[ "protected", "function", "_bufferingAllowed", "(", ")", "{", "//jeśli zdefiniowano własny obiekt sprawdzający, czy można buforować", "if", "(", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "category", "instanceof", "\\", "Cms", "\\", "Config", "\\", "Cate...
Czy buforowanie dozwolone @return boolean
[ "Czy", "buforowanie", "dozwolone" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/CategoryController.php#L300-L311
train
fezfez/codeGenerator
src/CrudGenerator/Utils/FileManager.php
FileManager.filePutsContent
public function filePutsContent($path, $content) { if (@file_put_contents($path, $content) === false) { throw new \RuntimeException(sprintf("Could't puts content %s", $path)); } chmod($path, 0777); }
php
public function filePutsContent($path, $content) { if (@file_put_contents($path, $content) === false) { throw new \RuntimeException(sprintf("Could't puts content %s", $path)); } chmod($path, 0777); }
[ "public", "function", "filePutsContent", "(", "$", "path", ",", "$", "content", ")", "{", "if", "(", "@", "file_put_contents", "(", "$", "path", ",", "$", "content", ")", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf",...
Puts content into file @param string $path File path @param string $content File Content
[ "Puts", "content", "into", "file" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Utils/FileManager.php#L39-L46
train
fezfez/codeGenerator
src/CrudGenerator/Utils/FileManager.php
FileManager.ifDirDoesNotExistCreate
public function ifDirDoesNotExistCreate($directory, $recursive = false) { if ($this->isDir($directory) === false) { $this->mkdir($directory, $recursive); return true; } else { return false; } }
php
public function ifDirDoesNotExistCreate($directory, $recursive = false) { if ($this->isDir($directory) === false) { $this->mkdir($directory, $recursive); return true; } else { return false; } }
[ "public", "function", "ifDirDoesNotExistCreate", "(", "$", "directory", ",", "$", "recursive", "=", "false", ")", "{", "if", "(", "$", "this", "->", "isDir", "(", "$", "directory", ")", "===", "false", ")", "{", "$", "this", "->", "mkdir", "(", "$", ...
Create dir if not exist @param string $directory @param boolean $recursive @return boolean
[ "Create", "dir", "if", "not", "exist" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Utils/FileManager.php#L142-L151
train
pscheit/jparser
PLUG/parsing/Grammar.php
Grammar.get_rules
function get_rules( $nt ){ $rules = array(); if( isset($this->ntindex[$nt]) ){ foreach( $this->ntindex[$nt] as $i ){ $rules[$i] = $this->rules[$i]; } } return $rules; }
php
function get_rules( $nt ){ $rules = array(); if( isset($this->ntindex[$nt]) ){ foreach( $this->ntindex[$nt] as $i ){ $rules[$i] = $this->rules[$i]; } } return $rules; }
[ "function", "get_rules", "(", "$", "nt", ")", "{", "$", "rules", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "ntindex", "[", "$", "nt", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "ntindex", "[", "$", "...
Get rules by non-terminal left hand side @param int|string non terminal symbol @return array none or more rule arrays
[ "Get", "rules", "by", "non", "-", "terminal", "left", "hand", "side" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/parsing/Grammar.php#L159-L167
train
pscheit/jparser
PLUG/parsing/Grammar.php
Grammar.follow_set
function follow_set( $s ){ if( ! isset($this->follows[$s]) ){ $type = $this->is_terminal($s) ? 'terminal' : 'non-terminal'; trigger_error("No follow set for $type $s", E_USER_WARNING ); return array(); } return $this->follows[$s]; }
php
function follow_set( $s ){ if( ! isset($this->follows[$s]) ){ $type = $this->is_terminal($s) ? 'terminal' : 'non-terminal'; trigger_error("No follow set for $type $s", E_USER_WARNING ); return array(); } return $this->follows[$s]; }
[ "function", "follow_set", "(", "$", "s", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "follows", "[", "$", "s", "]", ")", ")", "{", "$", "type", "=", "$", "this", "->", "is_terminal", "(", "$", "s", ")", "?", "'terminal'", ":", ...
Get FOLLOW set for a single given symbol @param int scalar symbol @return array set of terminal symbols
[ "Get", "FOLLOW", "set", "for", "a", "single", "given", "symbol" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/parsing/Grammar.php#L240-L247
train
stanislav-web/Searcher
src/Searcher/Hydrators/ArrayHydrator.php
ArrayHydrator.extract
public function extract(callable $callback = null) { if ($callback === null) { $result = $this->result->toArray(); } else { $result = $callback($this->result->toArray()); } return $result; }
php
public function extract(callable $callback = null) { if ($callback === null) { $result = $this->result->toArray(); } else { $result = $callback($this->result->toArray()); } return $result; }
[ "public", "function", "extract", "(", "callable", "$", "callback", "=", "null", ")", "{", "if", "(", "$", "callback", "===", "null", ")", "{", "$", "result", "=", "$", "this", "->", "result", "->", "toArray", "(", ")", ";", "}", "else", "{", "$", ...
Extract result data to array @param callback|null $callback function to data @return mixed
[ "Extract", "result", "data", "to", "array" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Hydrators/ArrayHydrator.php#L42-L54
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.getTraceAsString
public function getTraceAsString() { $lines = array (); for( $i = 0; $i < count($this->trace); $i++ ){ $a = $this->trace[$i]; $call = "{$a['function']}()"; if( isset($a['class']) ){ $call = "{$a['class']}{$a['type']}$call"; } $lines[] = "#$i {$a['file']}({$a['line']}): $call"; } $lines[] = "#$i {main}"; return implode( "\n", $lines ); }
php
public function getTraceAsString() { $lines = array (); for( $i = 0; $i < count($this->trace); $i++ ){ $a = $this->trace[$i]; $call = "{$a['function']}()"; if( isset($a['class']) ){ $call = "{$a['class']}{$a['type']}$call"; } $lines[] = "#$i {$a['file']}({$a['line']}): $call"; } $lines[] = "#$i {main}"; return implode( "\n", $lines ); }
[ "public", "function", "getTraceAsString", "(", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "trace", ")", ";", "$", "i", "++", ")", "{", "$", "a", ...
Get backtrace from where error was raised as string as per built-in Exception class @return string
[ "Get", "backtrace", "from", "where", "error", "was", "raised", "as", "string", "as", "per", "built", "-", "in", "Exception", "class" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L241-L253
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.raise
public function raise() { // log error to file according to PLUG_ERROR_LOGGING if( PLUG_ERROR_LOGGING & $this->type ) { // send to standard, or configured log file $logfile = defined('PLUG_ERROR_LOG') ? PLUG_ERROR_LOG : ''; $logged = self::log( call_user_func(self::$logfunc,$this), $logfile ); } // add to error stack if we are keeping this type if error // internal errors are always raised if( PLUG_ERROR_REPORTING & $this->type || $this->type === E_USER_INTERNAL ) { // register self as a raised error $this->id = self::$i++; self::$stack[ $this->type ][ $this->id ] = $this; // cli can pipe error to stderr, but not if the logging call already did. if( PLUG_CLI ){ self::log( call_user_func(self::$logfunc,$this), STDERR ); } } // call exit handler on fatal error // @todo - configurable fatal level $fatal = E_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR; if( $this->type & $fatal ){ call_user_func( self::$deathfunc, $this ); } }
php
public function raise() { // log error to file according to PLUG_ERROR_LOGGING if( PLUG_ERROR_LOGGING & $this->type ) { // send to standard, or configured log file $logfile = defined('PLUG_ERROR_LOG') ? PLUG_ERROR_LOG : ''; $logged = self::log( call_user_func(self::$logfunc,$this), $logfile ); } // add to error stack if we are keeping this type if error // internal errors are always raised if( PLUG_ERROR_REPORTING & $this->type || $this->type === E_USER_INTERNAL ) { // register self as a raised error $this->id = self::$i++; self::$stack[ $this->type ][ $this->id ] = $this; // cli can pipe error to stderr, but not if the logging call already did. if( PLUG_CLI ){ self::log( call_user_func(self::$logfunc,$this), STDERR ); } } // call exit handler on fatal error // @todo - configurable fatal level $fatal = E_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR; if( $this->type & $fatal ){ call_user_func( self::$deathfunc, $this ); } }
[ "public", "function", "raise", "(", ")", "{", "// log error to file according to PLUG_ERROR_LOGGING", "if", "(", "PLUG_ERROR_LOGGING", "&", "$", "this", "->", "type", ")", "{", "// send to standard, or configured log file ", "$", "logfile", "=", "defined", "(", "'PLUG_E...
Dispatch this error @todo callbacks to registered listeners @return Void
[ "Dispatch", "this", "error" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L281-L305
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.death
private static function death( PLUGError $Err ){ if( PLUG_CLI ){ // Print final death message to stderr if last error was logged $logfile = ini_get('error_log'); if( $logfile ){ PLUGCli::stdout("Error, %s exiting %s\n", $Err->getMessage(), $Err->code ); } } else { // display all errors in browser PLUG::dump_errors(); } exit( $Err->code ); }
php
private static function death( PLUGError $Err ){ if( PLUG_CLI ){ // Print final death message to stderr if last error was logged $logfile = ini_get('error_log'); if( $logfile ){ PLUGCli::stdout("Error, %s exiting %s\n", $Err->getMessage(), $Err->code ); } } else { // display all errors in browser PLUG::dump_errors(); } exit( $Err->code ); }
[ "private", "static", "function", "death", "(", "PLUGError", "$", "Err", ")", "{", "if", "(", "PLUG_CLI", ")", "{", "// Print final death message to stderr if last error was logged", "$", "logfile", "=", "ini_get", "(", "'error_log'", ")", ";", "if", "(", "$", "l...
Default script exit handler @param PLUGError @return void
[ "Default", "script", "exit", "handler" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L315-L328
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.log
static function log( $logline, $out = '' ) { // Output log line, no error checking to save performance // Send to descriptor or other stream if resource passed if( is_resource($out) && fwrite( $out, "$logline\n" ) ){ return true; } // Log to specified file else if( $out && error_log( "$logline\n", 3, $out ) ){ return $out; } // else default - probably apache error log else if( error_log( $logline, 0 ) ){ $out = ini_get('error_log'); return $out ? $out : true; } else { return false; } }
php
static function log( $logline, $out = '' ) { // Output log line, no error checking to save performance // Send to descriptor or other stream if resource passed if( is_resource($out) && fwrite( $out, "$logline\n" ) ){ return true; } // Log to specified file else if( $out && error_log( "$logline\n", 3, $out ) ){ return $out; } // else default - probably apache error log else if( error_log( $logline, 0 ) ){ $out = ini_get('error_log'); return $out ? $out : true; } else { return false; } }
[ "static", "function", "log", "(", "$", "logline", ",", "$", "out", "=", "''", ")", "{", "// Output log line, no error checking to save performance", "// Send to descriptor or other stream if resource passed", "if", "(", "is_resource", "(", "$", "out", ")", "&&", "fwrite...
Log an error string. @param string line to log @param string|resource optional log file or stream resource to send output @return mixed path logged to, true indicates successful non-file logging, or false on error
[ "Log", "an", "error", "string", "." ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L370-L388
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.display
static function display( PLUGError $Err ){ $html = ini_get('html_errors'); if( $html ){ $s = '<div class="error"><strong>%s:</strong> %s. in <strong>%s</strong> on line <strong>%u</strong></div>'; } else { $s = "\n%s: %s. in %s on line %u"; } $args = array ( $s, $Err->getTypeString(), $Err->getMessage(), $Err->getFile(), $Err->getLine() ); // add trace in dev mode if( ! PLUG::is_compiled() ){ $args[0] .= $html ? "\n<pre>%s</pre>" : "\n%s"; $args[] = $Err->getTraceAsString(); } return call_user_func_array( 'sprintf', $args ); }
php
static function display( PLUGError $Err ){ $html = ini_get('html_errors'); if( $html ){ $s = '<div class="error"><strong>%s:</strong> %s. in <strong>%s</strong> on line <strong>%u</strong></div>'; } else { $s = "\n%s: %s. in %s on line %u"; } $args = array ( $s, $Err->getTypeString(), $Err->getMessage(), $Err->getFile(), $Err->getLine() ); // add trace in dev mode if( ! PLUG::is_compiled() ){ $args[0] .= $html ? "\n<pre>%s</pre>" : "\n%s"; $args[] = $Err->getTraceAsString(); } return call_user_func_array( 'sprintf', $args ); }
[ "static", "function", "display", "(", "PLUGError", "$", "Err", ")", "{", "$", "html", "=", "ini_get", "(", "'html_errors'", ")", ";", "if", "(", "$", "html", ")", "{", "$", "s", "=", "'<div class=\"error\"><strong>%s:</strong> %s. in <strong>%s</strong> on line <s...
Default error formatting function @param PLUGError @return string
[ "Default", "error", "formatting", "function" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L408-L429
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.clear
public function clear() { unset( self::$stack[ $this->type ][ $this->id ] ); if( empty( self::$stack[ $this->type ] ) ){ unset( self::$stack[ $this->type ] ); } $this->id = null; }
php
public function clear() { unset( self::$stack[ $this->type ][ $this->id ] ); if( empty( self::$stack[ $this->type ] ) ){ unset( self::$stack[ $this->type ] ); } $this->id = null; }
[ "public", "function", "clear", "(", ")", "{", "unset", "(", "self", "::", "$", "stack", "[", "$", "this", "->", "type", "]", "[", "$", "this", "->", "id", "]", ")", ";", "if", "(", "empty", "(", "self", "::", "$", "stack", "[", "$", "this", "...
Clear this error @return Void
[ "Clear", "this", "error" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L438-L444
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.get_errors
static function get_errors( $emask = null ) { $all = array(); foreach( self::$stack as $type => $errs ){ if( $emask === null || $type & $emask ) { foreach( $errs as $Err ){ $all[] = $Err; } } } return $all; }
php
static function get_errors( $emask = null ) { $all = array(); foreach( self::$stack as $type => $errs ){ if( $emask === null || $type & $emask ) { foreach( $errs as $Err ){ $all[] = $Err; } } } return $all; }
[ "static", "function", "get_errors", "(", "$", "emask", "=", "null", ")", "{", "$", "all", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "stack", "as", "$", "type", "=>", "$", "errs", ")", "{", "if", "(", "$", "emask", "===", "...
Get all raised errors of specific types @param int optional type bitmask @return array
[ "Get", "all", "raised", "errors", "of", "specific", "types" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L454-L464
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.&
static function &get_reference( $type, $id ) { if( empty( self::$stack[ $type ][ $id ] ) ){ $null = null; return $null; } else { return self::$stack[ $type ][ $id ]; } }
php
static function &get_reference( $type, $id ) { if( empty( self::$stack[ $type ][ $id ] ) ){ $null = null; return $null; } else { return self::$stack[ $type ][ $id ]; } }
[ "static", "function", "&", "get_reference", "(", "$", "type", ",", "$", "id", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "stack", "[", "$", "type", "]", "[", "$", "id", "]", ")", ")", "{", "$", "null", "=", "null", ";", "return", "...
Get a reference to an error instance. @internal @param int @param int @return PLUGError
[ "Get", "a", "reference", "to", "an", "error", "instance", "." ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L476-L484
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.is_error
static function is_error( $emask = null ) { if( $emask === null ){ return (bool) self::get_global_level(); } else { return (bool) ( self::get_global_level() & $emask ); } }
php
static function is_error( $emask = null ) { if( $emask === null ){ return (bool) self::get_global_level(); } else { return (bool) ( self::get_global_level() & $emask ); } }
[ "static", "function", "is_error", "(", "$", "emask", "=", "null", ")", "{", "if", "(", "$", "emask", "===", "null", ")", "{", "return", "(", "bool", ")", "self", "::", "get_global_level", "(", ")", ";", "}", "else", "{", "return", "(", "bool", ")",...
Test whether errors of a certain type have been raised system wide @param int optional bitmask @return bool
[ "Test", "whether", "errors", "of", "a", "certain", "type", "have", "been", "raised", "system", "wide" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L494-L501
train
pscheit/jparser
PLUG/core/PLUGError.php
PLUGError.get_global_level
static function get_global_level () { $e = 0; $types = array_keys( self::$stack ); foreach( $types as $t ) { $e |= $t; } return $e; }
php
static function get_global_level () { $e = 0; $types = array_keys( self::$stack ); foreach( $types as $t ) { $e |= $t; } return $e; }
[ "static", "function", "get_global_level", "(", ")", "{", "$", "e", "=", "0", ";", "$", "types", "=", "array_keys", "(", "self", "::", "$", "stack", ")", ";", "foreach", "(", "$", "types", "as", "$", "t", ")", "{", "$", "e", "|=", "$", "t", ";",...
get system wide level of errors @return int
[ "get", "system", "wide", "level", "of", "errors" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/core/PLUGError.php#L510-L517
train
fezfez/codeGenerator
src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php
JsonMetaDataDAO.isFirstLevelIsDto
private function isFirstLevelIsDto(\JSONSchema\Structure\Schema $schema) { $isFirstLevelIsDto = false; foreach ($schema->getProperties() as $propertie) { if (in_array($propertie->getType(), array('object', 'array')) === false) { $isFirstLevelIsDto = true; } } return $isFirstLevelIsDto; }
php
private function isFirstLevelIsDto(\JSONSchema\Structure\Schema $schema) { $isFirstLevelIsDto = false; foreach ($schema->getProperties() as $propertie) { if (in_array($propertie->getType(), array('object', 'array')) === false) { $isFirstLevelIsDto = true; } } return $isFirstLevelIsDto; }
[ "private", "function", "isFirstLevelIsDto", "(", "\\", "JSONSchema", "\\", "Structure", "\\", "Schema", "$", "schema", ")", "{", "$", "isFirstLevelIsDto", "=", "false", ";", "foreach", "(", "$", "schema", "->", "getProperties", "(", ")", "as", "$", "properti...
Is there is only array or object at the first level, its not considered as a metadata but as a collection of it @param \JSONSchema\Structure\Schema $schema @return boolean
[ "Is", "there", "is", "only", "array", "or", "object", "at", "the", "first", "level", "its", "not", "considered", "as", "a", "metadata", "but", "as", "a", "collection", "of", "it" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php#L101-L112
train
fezfez/codeGenerator
src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php
JsonMetaDataDAO.hydrateItems
private function hydrateItems( $daddyName, array $items, MetadataDataObjectJson $metadata, MetaDataCollection $mainCollection ) { $mergeArray = true; if ($mergeArray === true && $this->itemsAreAllOfType($items, array('object')) === true) { $metadata->appendRelation( $this->hydrateMetaDataRelationColumn( $daddyName, $this->mergeItems($items), $metadata, $mainCollection ) ); } else { $specialProperties = array(); foreach ($items as $propName => $item) { // Relation of relation if (in_array($item->getType(), array('object', 'array')) === false) { $specialProperties[$propName] = $item; continue; } $metadata->appendRelation( $this->hydrateMetaDataRelationColumn($daddyName, $item->getProperties(), $metadata, $mainCollection) ); } } return $metadata; }
php
private function hydrateItems( $daddyName, array $items, MetadataDataObjectJson $metadata, MetaDataCollection $mainCollection ) { $mergeArray = true; if ($mergeArray === true && $this->itemsAreAllOfType($items, array('object')) === true) { $metadata->appendRelation( $this->hydrateMetaDataRelationColumn( $daddyName, $this->mergeItems($items), $metadata, $mainCollection ) ); } else { $specialProperties = array(); foreach ($items as $propName => $item) { // Relation of relation if (in_array($item->getType(), array('object', 'array')) === false) { $specialProperties[$propName] = $item; continue; } $metadata->appendRelation( $this->hydrateMetaDataRelationColumn($daddyName, $item->getProperties(), $metadata, $mainCollection) ); } } return $metadata; }
[ "private", "function", "hydrateItems", "(", "$", "daddyName", ",", "array", "$", "items", ",", "MetadataDataObjectJson", "$", "metadata", ",", "MetaDataCollection", "$", "mainCollection", ")", "{", "$", "mergeArray", "=", "true", ";", "if", "(", "$", "mergeArr...
Items is considered as relation @param string $daddyName @param array $items @param MetadataDataObjectJson $metadata @return MetadataDataObjectJson
[ "Items", "is", "considered", "as", "relation" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php#L187-L221
train
fezfez/codeGenerator
src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php
JsonMetaDataDAO.hydrateProperties
private function hydrateProperties( array $properties, MetadataDataObjectJson $metadata, MetaDataCollection $mainCollection ) { $specialProperties = array(); foreach ($properties as $propName => $propertie) { if (false === ($propertie instanceof \JSONSchema\Structure\Property)) { throw new \Exception('$propertie is not an instance of Property'); } if (in_array($propertie->getType(), array('object', 'array')) === true) { $specialProperties[$propName] = $propertie; continue; } $column = new MetaDataColumn(); $column->setNullable(!$propertie->getRequired()); $column->setName($propertie->getName()); $column->setType($propertie->getType()); $metadata->appendColumn($column); } if ($specialProperties !== array()) { foreach ($specialProperties as $prop) { $metadata->appendRelation( $this->hydrateMetaDataRelationColumn( $prop->getName(), $prop->getProperties(), $metadata, $mainCollection ) ); } } return $metadata; }
php
private function hydrateProperties( array $properties, MetadataDataObjectJson $metadata, MetaDataCollection $mainCollection ) { $specialProperties = array(); foreach ($properties as $propName => $propertie) { if (false === ($propertie instanceof \JSONSchema\Structure\Property)) { throw new \Exception('$propertie is not an instance of Property'); } if (in_array($propertie->getType(), array('object', 'array')) === true) { $specialProperties[$propName] = $propertie; continue; } $column = new MetaDataColumn(); $column->setNullable(!$propertie->getRequired()); $column->setName($propertie->getName()); $column->setType($propertie->getType()); $metadata->appendColumn($column); } if ($specialProperties !== array()) { foreach ($specialProperties as $prop) { $metadata->appendRelation( $this->hydrateMetaDataRelationColumn( $prop->getName(), $prop->getProperties(), $metadata, $mainCollection ) ); } } return $metadata; }
[ "private", "function", "hydrateProperties", "(", "array", "$", "properties", ",", "MetadataDataObjectJson", "$", "metadata", ",", "MetaDataCollection", "$", "mainCollection", ")", "{", "$", "specialProperties", "=", "array", "(", ")", ";", "foreach", "(", "$", "...
Properties is considered as column @param array $properties @param MetadataDataObjectJson $metadata @param MetaDataCollection $mainCollection @throws \Exception @return MetadataDataObjectJson
[ "Properties", "is", "considered", "as", "column" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php#L249-L287
train
fezfez/codeGenerator
src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php
JsonMetaDataDAO.getMetadataFor
public function getMetadataFor($tableName, array $parentName = array()) { $avaibleData = array(); foreach ($this->getAllMetadata() as $metadata) { $avaibleData[] = $metadata->getName(); if ($metadata->getName() === $tableName) { return $metadata; } } throw new \Exception(sprintf('"%s" not found in "%s"', $tableName, implode(', ', $avaibleData))); }
php
public function getMetadataFor($tableName, array $parentName = array()) { $avaibleData = array(); foreach ($this->getAllMetadata() as $metadata) { $avaibleData[] = $metadata->getName(); if ($metadata->getName() === $tableName) { return $metadata; } } throw new \Exception(sprintf('"%s" not found in "%s"', $tableName, implode(', ', $avaibleData))); }
[ "public", "function", "getMetadataFor", "(", "$", "tableName", ",", "array", "$", "parentName", "=", "array", "(", ")", ")", "{", "$", "avaibleData", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAllMetadata", "(", ")", "as", "$",...
Get particularie metadata from jsin @param string $tableName @return \CrudGenerator\Metadata\Sources\Json\MetadataDataObjectJson
[ "Get", "particularie", "metadata", "from", "jsin" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Metadata/Sources/Json/JsonMetaDataDAO.php#L295-L306
train
milejko/mmi-cms
src/Cms/Model/Mail.php
Mail.pushEmail
public static function pushEmail($name, $to, array $params = [], $fromName = null, $replyTo = null, $subject = null, $sendAfter = null, array $attachments = []) { //brak definicji if (null === ($def = Orm\CmsMailDefinitionQuery::langByName($name) ->findFirst())) { return false; } //walidacja listy adresów "do" $email = new \Mmi\Validator\EmailAddressList; if (!$email->isValid($to)) { return false; } //nowy rekord maila $mail = new Orm\CmsMailRecord; $mail->cmsMailDefinitionId = $def->id; $mail->to = $to; $mail->fromName = $fromName ? $fromName : $def->fromName; $mail->replyTo = $replyTo ? $replyTo : $def->replyTo; $mail->subject = $subject ? $subject : $def->subject; $mail->dateSendAfter = $sendAfter ? $sendAfter : date('Y-m-d H:i:s'); $files = []; //załączniki foreach ($attachments as $fileName => $filePath) { if (!file_exists($filePath)) { continue; } $files[$fileName] = ($filePath); } //serializacja załączników $mail->attachements = serialize($files); //przepychanie zmiennych do widoku $view = \Mmi\App\FrontController::getInstance()->getView(); foreach ($params as $key => $value) { $view->$key = $value; } //rendering wiadomości $mail->message = $view->renderDirectly($def->message); //rendering tematu $mail->subject = $view->renderDirectly($mail->subject); $mail->dateAdd = date('Y-m-d H:i:s'); //zapis maila return $mail->save(); }
php
public static function pushEmail($name, $to, array $params = [], $fromName = null, $replyTo = null, $subject = null, $sendAfter = null, array $attachments = []) { //brak definicji if (null === ($def = Orm\CmsMailDefinitionQuery::langByName($name) ->findFirst())) { return false; } //walidacja listy adresów "do" $email = new \Mmi\Validator\EmailAddressList; if (!$email->isValid($to)) { return false; } //nowy rekord maila $mail = new Orm\CmsMailRecord; $mail->cmsMailDefinitionId = $def->id; $mail->to = $to; $mail->fromName = $fromName ? $fromName : $def->fromName; $mail->replyTo = $replyTo ? $replyTo : $def->replyTo; $mail->subject = $subject ? $subject : $def->subject; $mail->dateSendAfter = $sendAfter ? $sendAfter : date('Y-m-d H:i:s'); $files = []; //załączniki foreach ($attachments as $fileName => $filePath) { if (!file_exists($filePath)) { continue; } $files[$fileName] = ($filePath); } //serializacja załączników $mail->attachements = serialize($files); //przepychanie zmiennych do widoku $view = \Mmi\App\FrontController::getInstance()->getView(); foreach ($params as $key => $value) { $view->$key = $value; } //rendering wiadomości $mail->message = $view->renderDirectly($def->message); //rendering tematu $mail->subject = $view->renderDirectly($mail->subject); $mail->dateAdd = date('Y-m-d H:i:s'); //zapis maila return $mail->save(); }
[ "public", "static", "function", "pushEmail", "(", "$", "name", ",", "$", "to", ",", "array", "$", "params", "=", "[", "]", ",", "$", "fromName", "=", "null", ",", "$", "replyTo", "=", "null", ",", "$", "subject", "=", "null", ",", "$", "sendAfter",...
Dodaje email do kolejki @param string $name nazwa-klucz e-maila z definicji @param string $to adres do lub adresy oddzielone ";" @param array $params zmienne do podstawienia w treści maila @param string $fromName nazwa od @param string $replyTo adres odpowiedz do @param string $subject temat @param string $sendAfter data i czas wyślij po @param array $attachments tabela z załącznikami w postaci ['nazwa dla usera' => 'fizyczna ścieżka i nazwa pliku'] @return int id zapisanego rekordu
[ "Dodaje", "email", "do", "kolejki" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/Mail.php#L44-L86
train
milejko/mmi-cms
src/Cms/Model/Mail.php
Mail.getMultioptions
public static function getMultioptions() { $rows = (new Orm\CmsMailServerQuery) ->whereActive()->equals(1) ->find(); $pairs = []; foreach ($rows as $row) { $pairs[$row->id] = $row->address . ':' . $row->port . ' (' . $row->username . ')'; } return $pairs; }
php
public static function getMultioptions() { $rows = (new Orm\CmsMailServerQuery) ->whereActive()->equals(1) ->find(); $pairs = []; foreach ($rows as $row) { $pairs[$row->id] = $row->address . ':' . $row->port . ' (' . $row->username . ')'; } return $pairs; }
[ "public", "static", "function", "getMultioptions", "(", ")", "{", "$", "rows", "=", "(", "new", "Orm", "\\", "CmsMailServerQuery", ")", "->", "whereActive", "(", ")", "->", "equals", "(", "1", ")", "->", "find", "(", ")", ";", "$", "pairs", "=", "[",...
Pobiera aktywne serwery do listy @return array lista
[ "Pobiera", "aktywne", "serwery", "do", "listy" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/Mail.php#L201-L211
train
manaphp/framework
Renderer/Engine/Sword/Compiler.php
Compiler._compileComments
protected function _compileComments($value) { $pattern = sprintf('/%s--(.*?)--%s/s', $this->_escapedTags[0], $this->_escapedTags[1]); return preg_replace($pattern, '<?php /*$1*/ ?> ', $value); }
php
protected function _compileComments($value) { $pattern = sprintf('/%s--(.*?)--%s/s', $this->_escapedTags[0], $this->_escapedTags[1]); return preg_replace($pattern, '<?php /*$1*/ ?> ', $value); }
[ "protected", "function", "_compileComments", "(", "$", "value", ")", "{", "$", "pattern", "=", "sprintf", "(", "'/%s--(.*?)--%s/s'", ",", "$", "this", "->", "_escapedTags", "[", "0", "]", ",", "$", "this", "->", "_escapedTags", "[", "1", "]", ")", ";", ...
Compile Sword comments into valid PHP. @param string $value @return string
[ "Compile", "Sword", "comments", "into", "valid", "PHP", "." ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Renderer/Engine/Sword/Compiler.php#L311-L316
train
manaphp/framework
Renderer/Engine/Sword/Compiler.php
Compiler._compileEchos
protected function _compileEchos($value) { foreach ($this->_getEchoMethods() as $method => $length) { $value = $this->$method($value); } return $value; }
php
protected function _compileEchos($value) { foreach ($this->_getEchoMethods() as $method => $length) { $value = $this->$method($value); } return $value; }
[ "protected", "function", "_compileEchos", "(", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "_getEchoMethods", "(", ")", "as", "$", "method", "=>", "$", "length", ")", "{", "$", "value", "=", "$", "this", "->", "$", "method", "(", "$", ...
Compile Sword echos into valid PHP. @param string $value @return string
[ "Compile", "Sword", "echos", "into", "valid", "PHP", "." ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Renderer/Engine/Sword/Compiler.php#L325-L332
train
manaphp/framework
Renderer/Engine/Sword/Compiler.php
Compiler._getEchoMethods
protected function _getEchoMethods() { $methods = [ '_compileRawEchos' => strlen(stripcslashes($this->_rawTags[0])), '_compileEscapedEchos' => strlen(stripcslashes($this->_escapedTags[0])), ]; uksort($methods, static function ($method1, $method2) use ($methods) { // Ensure the longest tags are processed first if ($methods[$method1] > $methods[$method2]) { return -1; } if ($methods[$method1] < $methods[$method2]) { return 1; } // Otherwise give preference to raw tags (assuming they've overridden) if ($method1 === '_compileRawEchos') { return -1; } if ($method2 === '_compileRawEchos') { return 1; } if ($method1 === '_compileEscapedEchos') { return -1; } if ($method2 === '_compileEscapedEchos') { return 1; } return 0; }); return $methods; }
php
protected function _getEchoMethods() { $methods = [ '_compileRawEchos' => strlen(stripcslashes($this->_rawTags[0])), '_compileEscapedEchos' => strlen(stripcslashes($this->_escapedTags[0])), ]; uksort($methods, static function ($method1, $method2) use ($methods) { // Ensure the longest tags are processed first if ($methods[$method1] > $methods[$method2]) { return -1; } if ($methods[$method1] < $methods[$method2]) { return 1; } // Otherwise give preference to raw tags (assuming they've overridden) if ($method1 === '_compileRawEchos') { return -1; } if ($method2 === '_compileRawEchos') { return 1; } if ($method1 === '_compileEscapedEchos') { return -1; } if ($method2 === '_compileEscapedEchos') { return 1; } return 0; }); return $methods; }
[ "protected", "function", "_getEchoMethods", "(", ")", "{", "$", "methods", "=", "[", "'_compileRawEchos'", "=>", "strlen", "(", "stripcslashes", "(", "$", "this", "->", "_rawTags", "[", "0", "]", ")", ")", ",", "'_compileEscapedEchos'", "=>", "strlen", "(", ...
Get the echo methods in the proper order for compilation. @return array
[ "Get", "the", "echo", "methods", "in", "the", "proper", "order", "for", "compilation", "." ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Renderer/Engine/Sword/Compiler.php#L339-L374
train
manaphp/framework
Renderer/Engine/Sword/Compiler.php
Compiler._compile_allow
protected function _compile_allow($expression) { $parts = explode(',', substr($expression, 1, -1)); $expr = $this->compileString($parts[1]); return "<?php if (\$di->authorization->isAllowed($parts[0])): ?>$expr<?php endif ?>"; }
php
protected function _compile_allow($expression) { $parts = explode(',', substr($expression, 1, -1)); $expr = $this->compileString($parts[1]); return "<?php if (\$di->authorization->isAllowed($parts[0])): ?>$expr<?php endif ?>"; }
[ "protected", "function", "_compile_allow", "(", "$", "expression", ")", "{", "$", "parts", "=", "explode", "(", "','", ",", "substr", "(", "$", "expression", ",", "1", ",", "-", "1", ")", ")", ";", "$", "expr", "=", "$", "this", "->", "compileString"...
Compile the allow statements into valid PHP. @param string $expression @return string
[ "Compile", "the", "allow", "statements", "into", "valid", "PHP", "." ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Renderer/Engine/Sword/Compiler.php#L602-L607
train
manaphp/framework
Renderer/Engine/Sword/Compiler.php
Compiler._compile_asset
protected function _compile_asset($expression) { if (strcspn($expression, '$\'"') === strlen($expression)) { $expression = '(\'' . trim($expression, '()') . '\')'; } return asset(substr($expression, 2, -2)); /*return "<?= asset{$expression}; ?>";*/ }
php
protected function _compile_asset($expression) { if (strcspn($expression, '$\'"') === strlen($expression)) { $expression = '(\'' . trim($expression, '()') . '\')'; } return asset(substr($expression, 2, -2)); /*return "<?= asset{$expression}; ?>";*/ }
[ "protected", "function", "_compile_asset", "(", "$", "expression", ")", "{", "if", "(", "strcspn", "(", "$", "expression", ",", "'$\\'\"'", ")", "===", "strlen", "(", "$", "expression", ")", ")", "{", "$", "expression", "=", "'(\\''", ".", "trim", "(", ...
Compile the Asset statements into valid PHP. @param string $expression @return string
[ "Compile", "the", "Asset", "statements", "into", "valid", "PHP", "." ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Renderer/Engine/Sword/Compiler.php#L894-L902
train
milejko/mmi-cms
src/Cms/ConnectorController.php
ConnectorController.importFileAction
public function importFileAction() { //text/plain $this->getResponse()->setTypePlain(); //adres endpointu $endpoint = base64_decode($this->url) . '/?module=cms&controller=connector&name=' . $this->name . '&action='; try { //wczytanie danych $data = json_decode(file_get_contents($endpoint . 'exportFileMeta'), true); } catch (\Exception $e) { //zwrot pustego statusu return 'ERR'; } //próba importu meta-danych if (null === $file = (new Model\ConnectorModel)->importFileMeta($data)) { //plik istnieje, lub próba nie udana return 'META ERROR'; } try { mkdir(dirname($file->getRealPath()), 0777, true); } catch (\Exception $e) { //nic } try { //próba pobrania i zapisu binarium file_put_contents($file->getRealPath(), file_get_contents($endpoint . 'exportFileBinary')); } catch (\Exception $e) { die($e->getMessage()); //zwrot pustego statusu return 'BIN ERROR'; } return 'OK'; }
php
public function importFileAction() { //text/plain $this->getResponse()->setTypePlain(); //adres endpointu $endpoint = base64_decode($this->url) . '/?module=cms&controller=connector&name=' . $this->name . '&action='; try { //wczytanie danych $data = json_decode(file_get_contents($endpoint . 'exportFileMeta'), true); } catch (\Exception $e) { //zwrot pustego statusu return 'ERR'; } //próba importu meta-danych if (null === $file = (new Model\ConnectorModel)->importFileMeta($data)) { //plik istnieje, lub próba nie udana return 'META ERROR'; } try { mkdir(dirname($file->getRealPath()), 0777, true); } catch (\Exception $e) { //nic } try { //próba pobrania i zapisu binarium file_put_contents($file->getRealPath(), file_get_contents($endpoint . 'exportFileBinary')); } catch (\Exception $e) { die($e->getMessage()); //zwrot pustego statusu return 'BIN ERROR'; } return 'OK'; }
[ "public", "function", "importFileAction", "(", ")", "{", "//text/plain", "$", "this", "->", "getResponse", "(", ")", "->", "setTypePlain", "(", ")", ";", "//adres endpointu", "$", "endpoint", "=", "base64_decode", "(", "$", "this", "->", "url", ")", ".", "...
Importuje plik na podstawie nazwy
[ "Importuje", "plik", "na", "podstawie", "nazwy" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/ConnectorController.php#L34-L66
train
milejko/mmi-cms
src/Cms/ConnectorController.php
ConnectorController.exportFileBinaryAction
public function exportFileBinaryAction() { $this->getResponse()->setType('application/octet-stream') ->send(); //wyszukiwanie pliku if (null === $file = (new Orm\CmsFileQuery)->whereName()->equals($this->name) ->findFirst()) { throw new \Mmi\Mvc\MvcNotFoundException('File not found'); } //plik zbyt duży do transferu if ($file->size > self::MAX_FILE_SIZE) { throw new \Mmi\Mvc\MvcForbiddenException('File to large'); } readfile($file->getRealPath()); exit; }
php
public function exportFileBinaryAction() { $this->getResponse()->setType('application/octet-stream') ->send(); //wyszukiwanie pliku if (null === $file = (new Orm\CmsFileQuery)->whereName()->equals($this->name) ->findFirst()) { throw new \Mmi\Mvc\MvcNotFoundException('File not found'); } //plik zbyt duży do transferu if ($file->size > self::MAX_FILE_SIZE) { throw new \Mmi\Mvc\MvcForbiddenException('File to large'); } readfile($file->getRealPath()); exit; }
[ "public", "function", "exportFileBinaryAction", "(", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setType", "(", "'application/octet-stream'", ")", "->", "send", "(", ")", ";", "//wyszukiwanie pliku", "if", "(", "null", "===", "$", "file", "=...
Eksportuje binarium pliku @return mixed @throws \Mmi\Mvc\MvcNotFoundException @throws \Mmi\Mvc\MvcForbiddenException
[ "Eksportuje", "binarium", "pliku" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/ConnectorController.php#L74-L89
train
milejko/mmi-cms
src/Cms/ConnectorController.php
ConnectorController.exportFileMetaAction
public function exportFileMetaAction() { //wyszukiwanie pliku if (null === $files = (new Orm\CmsFileQuery)->whereName()->equals($this->name) ->find()) { throw new \Mmi\Mvc\MvcNotFoundException('File not found'); } $data = []; //iteracja po plikach foreach ($files as $file) { //spłaszczenie meta-danych $file->data = ($file->data && ($file->data instanceof \Mmi\DataObject)) ? json_encode($file->data->toArray()) : null; $data[] = $file->toArray(); } //zwrot meta return json_encode($data); }
php
public function exportFileMetaAction() { //wyszukiwanie pliku if (null === $files = (new Orm\CmsFileQuery)->whereName()->equals($this->name) ->find()) { throw new \Mmi\Mvc\MvcNotFoundException('File not found'); } $data = []; //iteracja po plikach foreach ($files as $file) { //spłaszczenie meta-danych $file->data = ($file->data && ($file->data instanceof \Mmi\DataObject)) ? json_encode($file->data->toArray()) : null; $data[] = $file->toArray(); } //zwrot meta return json_encode($data); }
[ "public", "function", "exportFileMetaAction", "(", ")", "{", "//wyszukiwanie pliku", "if", "(", "null", "===", "$", "files", "=", "(", "new", "Orm", "\\", "CmsFileQuery", ")", "->", "whereName", "(", ")", "->", "equals", "(", "$", "this", "->", "name", "...
Eksportuje meta pliku @return mixed @throws \Mmi\Mvc\MvcNotFoundException @throws \Mmi\Mvc\MvcForbiddenException
[ "Eksportuje", "meta", "pliku" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/ConnectorController.php#L97-L113
train
milejko/mmi-cms
src/Cms/Model/Log.php
Log.add
public static function add($operation = null, array $data = []) { \Mmi\App\FrontController::getInstance()->getLogger()->info('Legacy log: ' . $operation); \Mmi\App\FrontController::getInstance()->getLogger()->warning('\Cms\Log\Model deprecated, use MMi PSR logger instead'); }
php
public static function add($operation = null, array $data = []) { \Mmi\App\FrontController::getInstance()->getLogger()->info('Legacy log: ' . $operation); \Mmi\App\FrontController::getInstance()->getLogger()->warning('\Cms\Log\Model deprecated, use MMi PSR logger instead'); }
[ "public", "static", "function", "add", "(", "$", "operation", "=", "null", ",", "array", "$", "data", "=", "[", "]", ")", "{", "\\", "Mmi", "\\", "App", "\\", "FrontController", "::", "getInstance", "(", ")", "->", "getLogger", "(", ")", "->", "info"...
Dodaje zdarzenie do logu @param string $operation operacja @param array $data dane @return bool czy dodano
[ "Dodaje", "zdarzenie", "do", "logu" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/Log.php#L26-L30
train
beleneglorion/php-bugherd-api
lib/Bugherd/Api/Comment.php
Comment.create
public function create($projectId,$taskId,array $params = array()) { $defaults = array( 'text' => null, 'user_id' => null, 'user_email' => null ); $params = array_filter(array_merge($defaults, $params)); $data = array('comment'=>$params); $path = '/projects/'.urlencode($projectId).'/tasks/'.urlencode($taskId).'/comments.json'; return $this->post($path,$data); }
php
public function create($projectId,$taskId,array $params = array()) { $defaults = array( 'text' => null, 'user_id' => null, 'user_email' => null ); $params = array_filter(array_merge($defaults, $params)); $data = array('comment'=>$params); $path = '/projects/'.urlencode($projectId).'/tasks/'.urlencode($taskId).'/comments.json'; return $this->post($path,$data); }
[ "public", "function", "create", "(", "$", "projectId", ",", "$", "taskId", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "defaults", "=", "array", "(", "'text'", "=>", "null", ",", "'user_id'", "=>", "null", ",", "'user_email'", ...
Create a new comment on a task @link https://www.bugherd.com/api_v2#api_comment_create @param string $projectId the project id @param string $taskId the project id @param array $params the new issue data @return mixed
[ "Create", "a", "new", "comment", "on", "a", "task" ]
f0fce97042bd05bc5560fbf37051cd74f802cea1
https://github.com/beleneglorion/php-bugherd-api/blob/f0fce97042bd05bc5560fbf37051cd74f802cea1/lib/Bugherd/Api/Comment.php#L38-L51
train
milejko/mmi-cms
src/CmsAdmin/Grid/Column/ColumnAbstract.php
ColumnAbstract.getFilterValue
public function getFilterValue($param = null) { //iteracja po filtrach w gridzie foreach ($this->_grid->getState()->getFilters() as $filter) { //znaleziony filtr dla tego pola z tabelą if ($filter->getTableName() . '.' . $filter->getField() == $this->getName()) { //zwrot wartości filtra return $filter->getValue(); } //znaleziony filtr dla tego pola (bez tabeli) if (!$filter->getTableName() && $filter->getField() == $this->getName()) { /** @var \stdClass $value */ $valueObj = json_decode($filter->getValue()); if (null !== $param && is_object($valueObj) && property_exists($valueObj, $param)) { return $valueObj->{$param}; } //zwrot wartości filtra return $filter->getValue(); } } }
php
public function getFilterValue($param = null) { //iteracja po filtrach w gridzie foreach ($this->_grid->getState()->getFilters() as $filter) { //znaleziony filtr dla tego pola z tabelą if ($filter->getTableName() . '.' . $filter->getField() == $this->getName()) { //zwrot wartości filtra return $filter->getValue(); } //znaleziony filtr dla tego pola (bez tabeli) if (!$filter->getTableName() && $filter->getField() == $this->getName()) { /** @var \stdClass $value */ $valueObj = json_decode($filter->getValue()); if (null !== $param && is_object($valueObj) && property_exists($valueObj, $param)) { return $valueObj->{$param}; } //zwrot wartości filtra return $filter->getValue(); } } }
[ "public", "function", "getFilterValue", "(", "$", "param", "=", "null", ")", "{", "//iteracja po filtrach w gridzie", "foreach", "(", "$", "this", "->", "_grid", "->", "getState", "(", ")", "->", "getFilters", "(", ")", "as", "$", "filter", ")", "{", "//zn...
Zwraca filtr dla pola @return string
[ "Zwraca", "filtr", "dla", "pola" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/Grid/Column/ColumnAbstract.php#L129-L149
train
milejko/mmi-cms
src/CmsAdmin/Grid/Column/ColumnAbstract.php
ColumnAbstract.isFieldInRecord
public function isFieldInRecord() { //zażądany join if (strpos($this->getName(), '.')) { return true; } //sorawdzenie w rekordzie return property_exists($this->_grid->getQuery()->getRecordName(), $this->getName()); }
php
public function isFieldInRecord() { //zażądany join if (strpos($this->getName(), '.')) { return true; } //sorawdzenie w rekordzie return property_exists($this->_grid->getQuery()->getRecordName(), $this->getName()); }
[ "public", "function", "isFieldInRecord", "(", ")", "{", "//zażądany join", "if", "(", "strpos", "(", "$", "this", "->", "getName", "(", ")", ",", "'.'", ")", ")", "{", "return", "true", ";", "}", "//sorawdzenie w rekordzie", "return", "property_exists", "(",...
Sprawdza istnienie pola w rekordzie @return boolean
[ "Sprawdza", "istnienie", "pola", "w", "rekordzie" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/Grid/Column/ColumnAbstract.php#L155-L163
train
milejko/mmi-cms
src/CmsAdmin/Grid/Column/ColumnAbstract.php
ColumnAbstract.getOrderMethod
public function getOrderMethod() { //iteracja po sortowaniach w gridzie foreach ($this->_grid->getState()->getOrder() as $order) { //znalezione sortowanie tego pola //gdy jest podana nazwa tabeli if ($order->getTableName()) { if ($order->getTableName() . '.' . $order->getField() == $this->getName()) { //zwrot metody sortowania return $order->getMethod(); } } else { //bez tabeli if ($order->getField() == $this->getName()) { //zwrot metody sortowania return $order->getMethod(); } } } }
php
public function getOrderMethod() { //iteracja po sortowaniach w gridzie foreach ($this->_grid->getState()->getOrder() as $order) { //znalezione sortowanie tego pola //gdy jest podana nazwa tabeli if ($order->getTableName()) { if ($order->getTableName() . '.' . $order->getField() == $this->getName()) { //zwrot metody sortowania return $order->getMethod(); } } else { //bez tabeli if ($order->getField() == $this->getName()) { //zwrot metody sortowania return $order->getMethod(); } } } }
[ "public", "function", "getOrderMethod", "(", ")", "{", "//iteracja po sortowaniach w gridzie", "foreach", "(", "$", "this", "->", "_grid", "->", "getState", "(", ")", "->", "getOrder", "(", ")", "as", "$", "order", ")", "{", "//znalezione sortowanie tego pola", ...
Zwraca sortowanie dla pola @return string
[ "Zwraca", "sortowanie", "dla", "pola" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/CmsAdmin/Grid/Column/ColumnAbstract.php#L169-L187
train
Jalle19/php-tvheadend
src/model/SubscriptionStatus.php
SubscriptionStatus.augment
public function augment(SubscriptionNotification $notification) { $this->in = $notification->in; $this->out = $notification->out; }
php
public function augment(SubscriptionNotification $notification) { $this->in = $notification->in; $this->out = $notification->out; }
[ "public", "function", "augment", "(", "SubscriptionNotification", "$", "notification", ")", "{", "$", "this", "->", "in", "=", "$", "notification", "->", "in", ";", "$", "this", "->", "out", "=", "$", "notification", "->", "out", ";", "}" ]
Augments this instance with data from the notification @param SubscriptionNotification $notification
[ "Augments", "this", "instance", "with", "data", "from", "the", "notification" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/model/SubscriptionStatus.php#L76-L80
train
milejko/mmi-cms
src/Cms/Form/Element/Tree.php
Tree._generateJs
private function _generateJs($treeId) { $id = $this->getOption('id'); $treeClearId = $treeId . '_clear'; $view = \Mmi\App\FrontController::getInstance()->getView(); $view->headScript()->appendScript("$(document).ready(function () { $('#$treeId').jstree({ 'core': { 'themes': { 'name': 'default', 'variant': 'small', 'responsive' : true, 'stripes' : true }, 'multiple': " . ($this->getOption('multiple') ? 'true' : 'false') . ", 'expand_selected_onload': true, 'check_callback' : false } }) .on('changed.jstree', function (e, data) { var selectedStr = ''; if (0 in data.selected) { selectedStr = data.selected[0]; } for (idx = 1, len = data.selected.length; idx < len; ++idx) { selectedStr = selectedStr.concat(';' + data.selected[idx]) } $('#$id').val(selectedStr); }); $('#$treeClearId').click(function () { $('#$id').val(''); $('#$treeId').jstree('deselect_all'); }); }); "); }
php
private function _generateJs($treeId) { $id = $this->getOption('id'); $treeClearId = $treeId . '_clear'; $view = \Mmi\App\FrontController::getInstance()->getView(); $view->headScript()->appendScript("$(document).ready(function () { $('#$treeId').jstree({ 'core': { 'themes': { 'name': 'default', 'variant': 'small', 'responsive' : true, 'stripes' : true }, 'multiple': " . ($this->getOption('multiple') ? 'true' : 'false') . ", 'expand_selected_onload': true, 'check_callback' : false } }) .on('changed.jstree', function (e, data) { var selectedStr = ''; if (0 in data.selected) { selectedStr = data.selected[0]; } for (idx = 1, len = data.selected.length; idx < len; ++idx) { selectedStr = selectedStr.concat(';' + data.selected[idx]) } $('#$id').val(selectedStr); }); $('#$treeClearId').click(function () { $('#$id').val(''); $('#$treeId').jstree('deselect_all'); }); }); "); }
[ "private", "function", "_generateJs", "(", "$", "treeId", ")", "{", "$", "id", "=", "$", "this", "->", "getOption", "(", "'id'", ")", ";", "$", "treeClearId", "=", "$", "treeId", ".", "'_clear'", ";", "$", "view", "=", "\\", "Mmi", "\\", "App", "\\...
Generuje JS do odpalenia drzewka @param string $treeId @return void
[ "Generuje", "JS", "do", "odpalenia", "drzewka" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Form/Element/Tree.php#L155-L190
train
milejko/mmi-cms
src/Cms/App/CmsFrontControllerPlugin.php
CmsFrontControllerPlugin.postDispatch
public function postDispatch(\Mmi\Http\Request $request) { //ustawienie widoku $view = \Mmi\App\FrontController::getInstance()->getView(); $base = $view->baseUrl; $view->domain = \App\Registry::$config->host; $view->languages = \App\Registry::$config->languages; $jsRequest = $request->toArray(); $jsRequest['baseUrl'] = $base; $jsRequest['locale'] = \App\Registry::$translate->getLocale(); unset($jsRequest['controller']); unset($jsRequest['action']); //umieszczenie tablicy w headScript() $view->headScript()->prependScript('var request = ' . json_encode($jsRequest)); }
php
public function postDispatch(\Mmi\Http\Request $request) { //ustawienie widoku $view = \Mmi\App\FrontController::getInstance()->getView(); $base = $view->baseUrl; $view->domain = \App\Registry::$config->host; $view->languages = \App\Registry::$config->languages; $jsRequest = $request->toArray(); $jsRequest['baseUrl'] = $base; $jsRequest['locale'] = \App\Registry::$translate->getLocale(); unset($jsRequest['controller']); unset($jsRequest['action']); //umieszczenie tablicy w headScript() $view->headScript()->prependScript('var request = ' . json_encode($jsRequest)); }
[ "public", "function", "postDispatch", "(", "\\", "Mmi", "\\", "Http", "\\", "Request", "$", "request", ")", "{", "//ustawienie widoku", "$", "view", "=", "\\", "Mmi", "\\", "App", "\\", "FrontController", "::", "getInstance", "(", ")", "->", "getView", "("...
Wykonywana po dispatcherze @param \Mmi\Http\Request $request
[ "Wykonywana", "po", "dispatcherze" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/App/CmsFrontControllerPlugin.php#L101-L115
train
milejko/mmi-cms
src/Cms/App/CmsFrontControllerPlugin.php
CmsFrontControllerPlugin._setLoginRequest
protected function _setLoginRequest(\Mmi\Http\Request $request, $preferAdmin) { //logowanie bez preferencji admina, tylko gdy uprawniony if (false === $preferAdmin && \App\Registry::$acl->isRoleAllowed('guest', 'cms:user:login')) { return $request->setModuleName('cms') ->setControllerName('user') ->setActionName('login'); } //logowanie admina return $request->setModuleName('cmsAdmin') ->setControllerName('index') ->setActionName('login'); }
php
protected function _setLoginRequest(\Mmi\Http\Request $request, $preferAdmin) { //logowanie bez preferencji admina, tylko gdy uprawniony if (false === $preferAdmin && \App\Registry::$acl->isRoleAllowed('guest', 'cms:user:login')) { return $request->setModuleName('cms') ->setControllerName('user') ->setActionName('login'); } //logowanie admina return $request->setModuleName('cmsAdmin') ->setControllerName('index') ->setActionName('login'); }
[ "protected", "function", "_setLoginRequest", "(", "\\", "Mmi", "\\", "Http", "\\", "Request", "$", "request", ",", "$", "preferAdmin", ")", "{", "//logowanie bez preferencji admina, tylko gdy uprawniony", "if", "(", "false", "===", "$", "preferAdmin", "&&", "\\", ...
Ustawia request na logowanie admina @param \Mmi\Http\Request $request @return \Mmi\Http\Request
[ "Ustawia", "request", "na", "logowanie", "admina" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/App/CmsFrontControllerPlugin.php#L134-L146
train
milejko/mmi-cms
src/Cms/Model/TagRelationModel.php
TagRelationModel.createTagRelation
public function createTagRelation($tag) { //filtrowanie tagu $filteredTag = (new \Mmi\Filter\Input)->filter($tag); //kreacja tagu jeśli brak if (null === $tagRecord = (new CmsTagQuery) ->whereTag()->equals($filteredTag) ->findFirst()) { $tagRecord = new CmsTagRecord; $tagRecord->tag = $filteredTag; $tagRecord->save(); } //znaleziona relacja - nic do zrobienia if (null !== (new CmsTagRelationQuery) ->whereCmsTagId()->equals($tagRecord->id) ->andFieldObject()->equals($this->_object) ->andFieldObjectId()->equals($this->_objectId) ->findFirst()) { return; } //tworzenie relacji $newRelationRecord = new CmsTagRelationRecord; $newRelationRecord->cmsTagId = $tagRecord->id; $newRelationRecord->object = $this->_object; $newRelationRecord->objectId = $this->_objectId; //zapis $newRelationRecord->save(); }
php
public function createTagRelation($tag) { //filtrowanie tagu $filteredTag = (new \Mmi\Filter\Input)->filter($tag); //kreacja tagu jeśli brak if (null === $tagRecord = (new CmsTagQuery) ->whereTag()->equals($filteredTag) ->findFirst()) { $tagRecord = new CmsTagRecord; $tagRecord->tag = $filteredTag; $tagRecord->save(); } //znaleziona relacja - nic do zrobienia if (null !== (new CmsTagRelationQuery) ->whereCmsTagId()->equals($tagRecord->id) ->andFieldObject()->equals($this->_object) ->andFieldObjectId()->equals($this->_objectId) ->findFirst()) { return; } //tworzenie relacji $newRelationRecord = new CmsTagRelationRecord; $newRelationRecord->cmsTagId = $tagRecord->id; $newRelationRecord->object = $this->_object; $newRelationRecord->objectId = $this->_objectId; //zapis $newRelationRecord->save(); }
[ "public", "function", "createTagRelation", "(", "$", "tag", ")", "{", "//filtrowanie tagu", "$", "filteredTag", "=", "(", "new", "\\", "Mmi", "\\", "Filter", "\\", "Input", ")", "->", "filter", "(", "$", "tag", ")", ";", "//kreacja tagu jeśli brak", "if", ...
Taguje tagiem po nazwie @param string $tag tag
[ "Taguje", "tagiem", "po", "nazwie" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Model/TagRelationModel.php#L52-L81
train
Erdiko/users
scripts/create-users.php
ErdikoUsersInstall.installRoles
public function installRoles() { $this->_roleService = new erdiko\users\models\Role(); $results = array( "successes" => array(), "failures" => array(), ); foreach($this->_rolesArray as $role) { // attempt to create the role // wrap this in a try/catch since this throws an exception if failure on create $createResult = false; try { $createResult = (boolean)$this->_roleService->create($role); } catch(\Exception $e) { // TODO do we need to log this elsewhere? } if(true !== $createResult) { $results["failures"][] = $role; } else { $results["successes"][] = $role; } } return $results; }
php
public function installRoles() { $this->_roleService = new erdiko\users\models\Role(); $results = array( "successes" => array(), "failures" => array(), ); foreach($this->_rolesArray as $role) { // attempt to create the role // wrap this in a try/catch since this throws an exception if failure on create $createResult = false; try { $createResult = (boolean)$this->_roleService->create($role); } catch(\Exception $e) { // TODO do we need to log this elsewhere? } if(true !== $createResult) { $results["failures"][] = $role; } else { $results["successes"][] = $role; } } return $results; }
[ "public", "function", "installRoles", "(", ")", "{", "$", "this", "->", "_roleService", "=", "new", "erdiko", "\\", "users", "\\", "models", "\\", "Role", "(", ")", ";", "$", "results", "=", "array", "(", "\"successes\"", "=>", "array", "(", ")", ",", ...
loop through the roles array and create records
[ "loop", "through", "the", "roles", "array", "and", "create", "records" ]
a063e0c61ceccdbfeaf7750e92bac8c3565c39a9
https://github.com/Erdiko/users/blob/a063e0c61ceccdbfeaf7750e92bac8c3565c39a9/scripts/create-users.php#L33-L60
train
Erdiko/users
scripts/create-users.php
ErdikoUsersInstall.installUsers
public function installUsers() { $this->_userService = new erdiko\users\models\User(); $results = array( "successes" => array(), "failures" => array(), ); foreach($this->_usersArray as $user) { // get role ID from the name $user["role"] = $this->_getRole($user["role"])->getId(); // create the user $createResult = (boolean)$this->_userService->createUser($user); unset($user["password"]); if(true !== $createResult) { $results["failures"][] = $user; } else { $results["successes"][] = $user; } } return $results; }
php
public function installUsers() { $this->_userService = new erdiko\users\models\User(); $results = array( "successes" => array(), "failures" => array(), ); foreach($this->_usersArray as $user) { // get role ID from the name $user["role"] = $this->_getRole($user["role"])->getId(); // create the user $createResult = (boolean)$this->_userService->createUser($user); unset($user["password"]); if(true !== $createResult) { $results["failures"][] = $user; } else { $results["successes"][] = $user; } } return $results; }
[ "public", "function", "installUsers", "(", ")", "{", "$", "this", "->", "_userService", "=", "new", "erdiko", "\\", "users", "\\", "models", "\\", "User", "(", ")", ";", "$", "results", "=", "array", "(", "\"successes\"", "=>", "array", "(", ")", ",", ...
loop through the users array and create records
[ "loop", "through", "the", "users", "array", "and", "create", "records" ]
a063e0c61ceccdbfeaf7750e92bac8c3565c39a9
https://github.com/Erdiko/users/blob/a063e0c61ceccdbfeaf7750e92bac8c3565c39a9/scripts/create-users.php#L73-L100
train
manaphp/framework
Authorization.php
Authorization.isAllowed
public function isAllowed($permission = null, $role = null) { if ($permission && strpos($permission, '/') !== false) { list($controllerClassName, $action) = $this->inferControllerAction($permission); $controllerClassName = $this->alias->resolveNS($controllerClassName); if (!isset($this->_acl[$controllerClassName])) { /** @var \ManaPHP\Rest\Controller $controllerInstance */ $controllerInstance = new $controllerClassName; $this->_acl[$controllerClassName] = $controllerInstance->getAcl(); } } else { $controllerInstance = $this->dispatcher->getControllerInstance(); $controllerClassName = get_class($controllerInstance); $action = $permission ? lcfirst(Text::camelize($permission)) : $this->dispatcher->getAction(); if (!isset($this->_acl[$controllerClassName])) { $this->_acl[$controllerClassName] = $controllerInstance->getAcl(); } } $acl = $this->_acl[$controllerClassName]; $role = $role ?: $this->identity->getRole(); if (strpos($role, ',') === false) { return $this->isAclAllow($acl, $role, $action); } else { foreach (explode($role, ',') as $r) { if ($this->isAclAllow($acl, $r, $action)) { return true; } } return false; } }
php
public function isAllowed($permission = null, $role = null) { if ($permission && strpos($permission, '/') !== false) { list($controllerClassName, $action) = $this->inferControllerAction($permission); $controllerClassName = $this->alias->resolveNS($controllerClassName); if (!isset($this->_acl[$controllerClassName])) { /** @var \ManaPHP\Rest\Controller $controllerInstance */ $controllerInstance = new $controllerClassName; $this->_acl[$controllerClassName] = $controllerInstance->getAcl(); } } else { $controllerInstance = $this->dispatcher->getControllerInstance(); $controllerClassName = get_class($controllerInstance); $action = $permission ? lcfirst(Text::camelize($permission)) : $this->dispatcher->getAction(); if (!isset($this->_acl[$controllerClassName])) { $this->_acl[$controllerClassName] = $controllerInstance->getAcl(); } } $acl = $this->_acl[$controllerClassName]; $role = $role ?: $this->identity->getRole(); if (strpos($role, ',') === false) { return $this->isAclAllow($acl, $role, $action); } else { foreach (explode($role, ',') as $r) { if ($this->isAclAllow($acl, $r, $action)) { return true; } } return false; } }
[ "public", "function", "isAllowed", "(", "$", "permission", "=", "null", ",", "$", "role", "=", "null", ")", "{", "if", "(", "$", "permission", "&&", "strpos", "(", "$", "permission", ",", "'/'", ")", "!==", "false", ")", "{", "list", "(", "$", "con...
Check whether a user is allowed to access a permission @param string $permission @param string $role @return bool
[ "Check", "whether", "a", "user", "is", "allowed", "to", "access", "a", "permission" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Authorization.php#L223-L257
train
paypayue/paypay-soap
src/Structure/RequestCreditCardPayment.php
RequestCreditCardPayment.withRedirectUrls
public function withRedirectUrls($redirects) { if (isset($redirects['success'])) { $this->returnUrlSuccess = $redirects['success']; } if (isset($redirects['cancel'])) { $this->returnUrlCancel = $redirects['cancel']; } if (isset($redirects['back'])) { $this->returnUrlBack = $redirects['back']; } return $this; }
php
public function withRedirectUrls($redirects) { if (isset($redirects['success'])) { $this->returnUrlSuccess = $redirects['success']; } if (isset($redirects['cancel'])) { $this->returnUrlCancel = $redirects['cancel']; } if (isset($redirects['back'])) { $this->returnUrlBack = $redirects['back']; } return $this; }
[ "public", "function", "withRedirectUrls", "(", "$", "redirects", ")", "{", "if", "(", "isset", "(", "$", "redirects", "[", "'success'", "]", ")", ")", "{", "$", "this", "->", "returnUrlSuccess", "=", "$", "redirects", "[", "'success'", "]", ";", "}", "...
Sets the redirect urls on the request @param array $redirects @return RequestCreditCardPayment
[ "Sets", "the", "redirect", "urls", "on", "the", "request" ]
ab01d5c041bbf1032fa5725abef5a6b19af746e4
https://github.com/paypayue/paypay-soap/blob/ab01d5c041bbf1032fa5725abef5a6b19af746e4/src/Structure/RequestCreditCardPayment.php#L63-L78
train
manaphp/framework
Image.php
Image.resizeCropCenter
public function resizeCropCenter($width, $height) { $_width = $this->do_getWidth(); $_height = $this->do_getHeight(); if ($_width / $_height > $width / $height) { $crop_height = $_height; $crop_width = $width * $crop_height / $height; $offsetX = ($_width - $crop_width) / 2; $offsetY = 0; } else { $crop_width = $_width; $crop_height = $height * $crop_width / $width; $offsetY = ($_height - $crop_height) / 2; $offsetX = 0; } $this->crop($crop_width, $crop_height, $offsetX, $offsetY); $this->scale($width / $crop_width); return $this; }
php
public function resizeCropCenter($width, $height) { $_width = $this->do_getWidth(); $_height = $this->do_getHeight(); if ($_width / $_height > $width / $height) { $crop_height = $_height; $crop_width = $width * $crop_height / $height; $offsetX = ($_width - $crop_width) / 2; $offsetY = 0; } else { $crop_width = $_width; $crop_height = $height * $crop_width / $width; $offsetY = ($_height - $crop_height) / 2; $offsetX = 0; } $this->crop($crop_width, $crop_height, $offsetX, $offsetY); $this->scale($width / $crop_width); return $this; }
[ "public", "function", "resizeCropCenter", "(", "$", "width", ",", "$", "height", ")", "{", "$", "_width", "=", "$", "this", "->", "do_getWidth", "(", ")", ";", "$", "_height", "=", "$", "this", "->", "do_getHeight", "(", ")", ";", "if", "(", "$", "...
Resize the image by a given width and height @param int $width @param int $height @return static
[ "Resize", "the", "image", "by", "a", "given", "width", "and", "height" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Image.php#L76-L97
train
manaphp/framework
Image.php
Image.scale
public function scale($ratio) { $_width = (int)$this->do_getWidth(); $_height = (int)$this->do_getHeight(); if ($ratio === 1) { return $this; } $width = (int)($_width * $ratio); $height = (int)($_height * $ratio); $this->do_resize($width, $height); return $this; }
php
public function scale($ratio) { $_width = (int)$this->do_getWidth(); $_height = (int)$this->do_getHeight(); if ($ratio === 1) { return $this; } $width = (int)($_width * $ratio); $height = (int)($_height * $ratio); $this->do_resize($width, $height); return $this; }
[ "public", "function", "scale", "(", "$", "ratio", ")", "{", "$", "_width", "=", "(", "int", ")", "$", "this", "->", "do_getWidth", "(", ")", ";", "$", "_height", "=", "(", "int", ")", "$", "this", "->", "do_getHeight", "(", ")", ";", "if", "(", ...
Scale the image by a given ratio @param float $ratio @return static
[ "Scale", "the", "image", "by", "a", "given", "ratio" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Image.php#L108-L123
train
manaphp/framework
Image.php
Image.scaleFixedHeight
public function scaleFixedHeight($height) { $_width = $this->do_getWidth(); $_height = $this->do_getHeight(); $width = (int)($_width * $height / $_height); $this->do_resize($width, $height); return $this; }
php
public function scaleFixedHeight($height) { $_width = $this->do_getWidth(); $_height = $this->do_getHeight(); $width = (int)($_width * $height / $_height); $this->do_resize($width, $height); return $this; }
[ "public", "function", "scaleFixedHeight", "(", "$", "height", ")", "{", "$", "_width", "=", "$", "this", "->", "do_getWidth", "(", ")", ";", "$", "_height", "=", "$", "this", "->", "do_getHeight", "(", ")", ";", "$", "width", "=", "(", "int", ")", ...
Scale the image by a given height @param int $height @return static
[ "Scale", "the", "image", "by", "a", "given", "height" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Image.php#L150-L159
train
brightnucleus/boilerplate
_scripts/Validation.php
Validation.validatePascalCase
public static function validatePascalCase($string) { if (SetupHelper::getPascalCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not in PascalCase.', $string ) ); }
php
public static function validatePascalCase($string) { if (SetupHelper::getPascalCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not in PascalCase.', $string ) ); }
[ "public", "static", "function", "validatePascalCase", "(", "$", "string", ")", "{", "if", "(", "SetupHelper", "::", "getPascalCase", "(", "$", "string", ")", "===", "$", "string", ")", "{", "return", "(", "string", ")", "$", "string", ";", "}", "throw", ...
Verify that a string is in PascalCase or throw an Exception. @since 0.1.0 @param string $string The string to validate. @return string The validated string. @throws InvalidArgumentException If the string is not in PascalCase.
[ "Verify", "that", "a", "string", "is", "in", "PascalCase", "or", "throw", "an", "Exception", "." ]
27092790349481e1bece8f79eaccaa15cc35d845
https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/Validation.php#L37-L49
train
brightnucleus/boilerplate
_scripts/Validation.php
Validation.validateLowerCase
public static function validateLowerCase($string) { if (SetupHelper::getLowerCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not in lowercase.', $string ) ); }
php
public static function validateLowerCase($string) { if (SetupHelper::getLowerCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not in lowercase.', $string ) ); }
[ "public", "static", "function", "validateLowerCase", "(", "$", "string", ")", "{", "if", "(", "SetupHelper", "::", "getLowerCase", "(", "$", "string", ")", "===", "$", "string", ")", "{", "return", "(", "string", ")", "$", "string", ";", "}", "throw", ...
Verify that a string is in lowercase or throw an Exception. @since 0.1.0 @param string $string The string to validate. @return string The validated string. @throws InvalidArgumentException If the string is not in lowercase.
[ "Verify", "that", "a", "string", "is", "in", "lowercase", "or", "throw", "an", "Exception", "." ]
27092790349481e1bece8f79eaccaa15cc35d845
https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/Validation.php#L61-L73
train
brightnucleus/boilerplate
_scripts/Validation.php
Validation.validateTrimmed
public static function validateTrimmed($string) { if (SetupHelper::trim($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not trimmed.', $string ) ); }
php
public static function validateTrimmed($string) { if (SetupHelper::trim($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not trimmed.', $string ) ); }
[ "public", "static", "function", "validateTrimmed", "(", "$", "string", ")", "{", "if", "(", "SetupHelper", "::", "trim", "(", "$", "string", ")", "===", "$", "string", ")", "{", "return", "(", "string", ")", "$", "string", ";", "}", "throw", "new", "...
Verify that a string is trimmed or throw an Exception. @since 0.1.0 @param string $string The string to validate. @return string The validated string. @throws InvalidArgumentException If the string is not trimmed.
[ "Verify", "that", "a", "string", "is", "trimmed", "or", "throw", "an", "Exception", "." ]
27092790349481e1bece8f79eaccaa15cc35d845
https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/Validation.php#L85-L97
train
brightnucleus/boilerplate
_scripts/Validation.php
Validation.validateEmail
public static function validateEmail($string) { if (filter_var($string, FILTER_VALIDATE_EMAIL)) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not a valid email.', $string ) ); }
php
public static function validateEmail($string) { if (filter_var($string, FILTER_VALIDATE_EMAIL)) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not a valid email.', $string ) ); }
[ "public", "static", "function", "validateEmail", "(", "$", "string", ")", "{", "if", "(", "filter_var", "(", "$", "string", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "return", "(", "string", ")", "$", "string", ";", "}", "throw", "new", "InvalidArgument...
Verify that a string is an email or throw an Exception. @since 0.1.0 @param string $string The string to validate. @return string The validated string. @throws InvalidArgumentException If the string is not an email.
[ "Verify", "that", "a", "string", "is", "an", "email", "or", "throw", "an", "Exception", "." ]
27092790349481e1bece8f79eaccaa15cc35d845
https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/Validation.php#L109-L121
train
brightnucleus/boilerplate
_scripts/Validation.php
Validation.validateURL
public static function validateURL($string) { if (filter_var($string, FILTER_VALIDATE_URL)) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not a valid URL.', $string ) ); }
php
public static function validateURL($string) { if (filter_var($string, FILTER_VALIDATE_URL)) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not a valid URL.', $string ) ); }
[ "public", "static", "function", "validateURL", "(", "$", "string", ")", "{", "if", "(", "filter_var", "(", "$", "string", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "return", "(", "string", ")", "$", "string", ";", "}", "throw", "new", "InvalidArgumentExce...
Verify that a string is a URL or throw an Exception. @since 0.1.0 @param string $string The string to validate. @return string The validated string. @throws InvalidArgumentException If the string is not a URL.
[ "Verify", "that", "a", "string", "is", "a", "URL", "or", "throw", "an", "Exception", "." ]
27092790349481e1bece8f79eaccaa15cc35d845
https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/Validation.php#L133-L145
train
xdan/jodit-connector-application
src/BaseApplication.php
BaseApplication.getUserRole
public function getUserRole() { return isset($_SESSION[$this->config->roleSessionVar]) ? $_SESSION[$this->config->roleSessionVar] : $this->config->defaultRole; }
php
public function getUserRole() { return isset($_SESSION[$this->config->roleSessionVar]) ? $_SESSION[$this->config->roleSessionVar] : $this->config->defaultRole; }
[ "public", "function", "getUserRole", "(", ")", "{", "return", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "config", "->", "roleSessionVar", "]", ")", "?", "$", "_SESSION", "[", "$", "this", "->", "config", "->", "roleSessionVar", "]", ":", "...
Get user role @return string
[ "Get", "user", "role" ]
a1f8ebf2d605665fb25e737d60a62ea410358c62
https://github.com/xdan/jodit-connector-application/blob/a1f8ebf2d605665fb25e737d60a62ea410358c62/src/BaseApplication.php#L89-L91
train
xdan/jodit-connector-application
src/BaseApplication.php
BaseApplication.read
public function read(Config $source) { $path = $source->getPath(); $sourceData = (object)[ 'baseurl' => $source->baseurl, 'path' => str_replace(realpath($source->getRoot()) . Consts::DS, '', $path), 'files' => [], ]; try { $this->accessControl->checkPermission($this->getUserRole(), $this->action, $path); } catch (\Exception $e) { return $sourceData; } $dir = opendir($path); $config = $this->config; while ($file = readdir($dir)) { if ($file != '.' && $file != '..' && is_file($path . $file)) { $file = new File($path . $file); if ($file->isGoodFile($source)) { $item = [ 'file' => $file->getPathByRoot($source), ]; if ($config->createThumb || !$file->isImage()) { $item['thumb'] = Image::getThumb($file, $source)->getPathByRoot($source); } $item['changed'] = date($config->datetimeFormat, $file->getTime()); $item['size'] = Helper::humanFileSize($file->getSize()); $item['isImage'] = $file->isImage(); $sourceData->files[] = $item; } } } return $sourceData; }
php
public function read(Config $source) { $path = $source->getPath(); $sourceData = (object)[ 'baseurl' => $source->baseurl, 'path' => str_replace(realpath($source->getRoot()) . Consts::DS, '', $path), 'files' => [], ]; try { $this->accessControl->checkPermission($this->getUserRole(), $this->action, $path); } catch (\Exception $e) { return $sourceData; } $dir = opendir($path); $config = $this->config; while ($file = readdir($dir)) { if ($file != '.' && $file != '..' && is_file($path . $file)) { $file = new File($path . $file); if ($file->isGoodFile($source)) { $item = [ 'file' => $file->getPathByRoot($source), ]; if ($config->createThumb || !$file->isImage()) { $item['thumb'] = Image::getThumb($file, $source)->getPathByRoot($source); } $item['changed'] = date($config->datetimeFormat, $file->getTime()); $item['size'] = Helper::humanFileSize($file->getSize()); $item['isImage'] = $file->isImage(); $sourceData->files[] = $item; } } } return $sourceData; }
[ "public", "function", "read", "(", "Config", "$", "source", ")", "{", "$", "path", "=", "$", "source", "->", "getPath", "(", ")", ";", "$", "sourceData", "=", "(", "object", ")", "[", "'baseurl'", "=>", "$", "source", "->", "baseurl", ",", "'path'", ...
Read folder and retrun filelist @param \Jodit\Config $source @return object @throws \Exception
[ "Read", "folder", "and", "retrun", "filelist" ]
a1f8ebf2d605665fb25e737d60a62ea410358c62
https://github.com/xdan/jodit-connector-application/blob/a1f8ebf2d605665fb25e737d60a62ea410358c62/src/BaseApplication.php#L321-L364
train
xdan/jodit-connector-application
src/BaseApplication.php
BaseApplication.getSource
public function getSource() { $source = $this->config->getSource($this->request->source); if (!$source) { throw new \Exception('Source not found', Consts::ERROR_CODE_NOT_EXISTS); } return $source; }
php
public function getSource() { $source = $this->config->getSource($this->request->source); if (!$source) { throw new \Exception('Source not found', Consts::ERROR_CODE_NOT_EXISTS); } return $source; }
[ "public", "function", "getSource", "(", ")", "{", "$", "source", "=", "$", "this", "->", "config", "->", "getSource", "(", "$", "this", "->", "request", "->", "source", ")", ";", "if", "(", "!", "$", "source", ")", "{", "throw", "new", "\\", "Excep...
Return current source @return \Jodit\Config @throws \Exception
[ "Return", "current", "source" ]
a1f8ebf2d605665fb25e737d60a62ea410358c62
https://github.com/xdan/jodit-connector-application/blob/a1f8ebf2d605665fb25e737d60a62ea410358c62/src/BaseApplication.php#L376-L384
train
Jalle19/php-tvheadend
src/client/BasicHttpClient.php
BasicHttpClient.createBaseRequest
protected function createBaseRequest($relativeUrl) { $baseUrl = $this->getBaseUrl(false); $request = new \Zend\Http\Request(); $request->setUri($baseUrl.$relativeUrl); $request->setMethod(\Zend\Http\Request::METHOD_POST); $request->getHeaders()->addHeaders(array( 'Content-Type'=>'application/x-www-form-urlencoded; charset=UTF-8', 'Accept-Encoding'=>'identity')); // plain text $this->addDefaultParameters($request); return $request; }
php
protected function createBaseRequest($relativeUrl) { $baseUrl = $this->getBaseUrl(false); $request = new \Zend\Http\Request(); $request->setUri($baseUrl.$relativeUrl); $request->setMethod(\Zend\Http\Request::METHOD_POST); $request->getHeaders()->addHeaders(array( 'Content-Type'=>'application/x-www-form-urlencoded; charset=UTF-8', 'Accept-Encoding'=>'identity')); // plain text $this->addDefaultParameters($request); return $request; }
[ "protected", "function", "createBaseRequest", "(", "$", "relativeUrl", ")", "{", "$", "baseUrl", "=", "$", "this", "->", "getBaseUrl", "(", "false", ")", ";", "$", "request", "=", "new", "\\", "Zend", "\\", "Http", "\\", "Request", "(", ")", ";", "$", ...
Creates a basic HTTP request @param string $relativeUrl the relative API URL @return \Zend\Http\Request
[ "Creates", "a", "basic", "HTTP", "request" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/client/BasicHttpClient.php#L111-L124
train
Jalle19/php-tvheadend
src/client/BasicHttpClient.php
BasicHttpClient.addDefaultParameters
protected function addDefaultParameters(&$request) { $defaultParameters = array( 'all'=>1, 'dir'=>'ASC', 'start'=>0, 'limit'=>999999999); foreach ($defaultParameters as $name=> $value) $request->getPost()->set($name, $value); }
php
protected function addDefaultParameters(&$request) { $defaultParameters = array( 'all'=>1, 'dir'=>'ASC', 'start'=>0, 'limit'=>999999999); foreach ($defaultParameters as $name=> $value) $request->getPost()->set($name, $value); }
[ "protected", "function", "addDefaultParameters", "(", "&", "$", "request", ")", "{", "$", "defaultParameters", "=", "array", "(", "'all'", "=>", "1", ",", "'dir'", "=>", "'ASC'", ",", "'start'", "=>", "0", ",", "'limit'", "=>", "999999999", ")", ";", "fo...
Adds default parameters to the request, such as sorting @param \Zend\Http\Request $request the request
[ "Adds", "default", "parameters", "to", "the", "request", "such", "as", "sorting" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/client/BasicHttpClient.php#L143-L153
train
fezfez/codeGenerator
src/CrudGenerator/Generators/Questions/Metadata/MetaDataQuestion.php
MetaDataQuestion.ask
public function ask(MetaDataSource $metadataSource, $choice = null) { $metaDataCollection = $this->getMetadataDao($metadataSource)->getAllMetadata(); $responseCollection = new PredefinedResponseCollection(); foreach ($metaDataCollection as $metaData) { $response = new PredefinedResponse($metaData->getOriginalName(), $metaData->getOriginalName(), $metaData); $response->setAdditionalData(array('source' => $metadataSource->getUniqueName())); $responseCollection->append($response); } $question = new QuestionWithPredefinedResponse( "Select Metadata", self::QUESTION_KEY, $responseCollection ); $question->setPreselectedResponse($choice); $question->setShutdownWithoutResponse(true); return $this->context->askCollection($question); }
php
public function ask(MetaDataSource $metadataSource, $choice = null) { $metaDataCollection = $this->getMetadataDao($metadataSource)->getAllMetadata(); $responseCollection = new PredefinedResponseCollection(); foreach ($metaDataCollection as $metaData) { $response = new PredefinedResponse($metaData->getOriginalName(), $metaData->getOriginalName(), $metaData); $response->setAdditionalData(array('source' => $metadataSource->getUniqueName())); $responseCollection->append($response); } $question = new QuestionWithPredefinedResponse( "Select Metadata", self::QUESTION_KEY, $responseCollection ); $question->setPreselectedResponse($choice); $question->setShutdownWithoutResponse(true); return $this->context->askCollection($question); }
[ "public", "function", "ask", "(", "MetaDataSource", "$", "metadataSource", ",", "$", "choice", "=", "null", ")", "{", "$", "metaDataCollection", "=", "$", "this", "->", "getMetadataDao", "(", "$", "metadataSource", ")", "->", "getAllMetadata", "(", ")", ";",...
Ask wich metadata you want to use @param MetaDataSource $metadataSource @param string|null $choice @throws ResponseExpectedException @return \CrudGenerator\Metadata\DataObject\MetaData
[ "Ask", "wich", "metadata", "you", "want", "to", "use" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Generators/Questions/Metadata/MetaDataQuestion.php#L66-L87
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.getNodeData
public function getNodeData($uuid) { $request = new client\Request('/api/idnode/load', array( 'uuid'=>$uuid, 'meta'=>0)); $response = $this->_client->getResponse($request); $content = json_decode($response->getContent()); if (count($content->entries) > 0) return $content->entries[0]; else return null; }
php
public function getNodeData($uuid) { $request = new client\Request('/api/idnode/load', array( 'uuid'=>$uuid, 'meta'=>0)); $response = $this->_client->getResponse($request); $content = json_decode($response->getContent()); if (count($content->entries) > 0) return $content->entries[0]; else return null; }
[ "public", "function", "getNodeData", "(", "$", "uuid", ")", "{", "$", "request", "=", "new", "client", "\\", "Request", "(", "'/api/idnode/load'", ",", "array", "(", "'uuid'", "=>", "$", "uuid", ",", "'meta'", "=>", "0", ")", ")", ";", "$", "response",...
Returns data about a node, such as the class name @param string $uuid @return \stdClass the raw node data response
[ "Returns", "data", "about", "a", "node", "such", "as", "the", "class", "name" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L137-L150
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.createNetwork
public function createNetwork($network) { $request = new client\Request('/api/mpegts/network/create', array( 'class'=>$network->getClassName(), 'conf'=>json_encode($network))); $this->_client->getResponse($request); }
php
public function createNetwork($network) { $request = new client\Request('/api/mpegts/network/create', array( 'class'=>$network->getClassName(), 'conf'=>json_encode($network))); $this->_client->getResponse($request); }
[ "public", "function", "createNetwork", "(", "$", "network", ")", "{", "$", "request", "=", "new", "client", "\\", "Request", "(", "'/api/mpegts/network/create'", ",", "array", "(", "'class'", "=>", "$", "network", "->", "getClassName", "(", ")", ",", "'conf'...
Creates the specified network @param model\network\Network $network the network
[ "Creates", "the", "specified", "network" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L156-L163
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.getNetwork
public function getNetwork($name) { // TODO: Use filtering $networks = $this->getNetworks(); foreach ($networks as $network) if ($network->networkname === $name) return $network; return null; }
php
public function getNetwork($name) { // TODO: Use filtering $networks = $this->getNetworks(); foreach ($networks as $network) if ($network->networkname === $name) return $network; return null; }
[ "public", "function", "getNetwork", "(", "$", "name", ")", "{", "// TODO: Use filtering", "$", "networks", "=", "$", "this", "->", "getNetworks", "(", ")", ";", "foreach", "(", "$", "networks", "as", "$", "network", ")", "if", "(", "$", "network", "->", ...
Returns the network with the specified name, or null if not found @param string $name the network name @return model\network\Network
[ "Returns", "the", "network", "with", "the", "specified", "name", "or", "null", "if", "not", "found" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L170-L180
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.createMultiplex
public function createMultiplex($network, $multiplex) { $request = new client\Request('/api/mpegts/network/mux_create', array( 'uuid'=>$network->uuid, 'conf'=>json_encode($multiplex))); $this->_client->getResponse($request); }
php
public function createMultiplex($network, $multiplex) { $request = new client\Request('/api/mpegts/network/mux_create', array( 'uuid'=>$network->uuid, 'conf'=>json_encode($multiplex))); $this->_client->getResponse($request); }
[ "public", "function", "createMultiplex", "(", "$", "network", ",", "$", "multiplex", ")", "{", "$", "request", "=", "new", "client", "\\", "Request", "(", "'/api/mpegts/network/mux_create'", ",", "array", "(", "'uuid'", "=>", "$", "network", "->", "uuid", ",...
Creates the specified multiplex on the specified network @param model\network\Network $network @param model\multiplex\Multiplex $multiplex
[ "Creates", "the", "specified", "multiplex", "on", "the", "specified", "network" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L215-L222
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.getChannels
public function getChannels($filter = null) { $channels = array(); // Create the request $request = new client\Request('/api/channel/grid'); if ($filter) $request->setFilter($filter); // Get the response $response = $this->_client->getResponse($request); $rawContent = $response->getContent(); $content = json_decode($rawContent); foreach ($content->entries as $entry) $channels[] = model\Channel::fromRawEntry($entry); return $channels; }
php
public function getChannels($filter = null) { $channels = array(); // Create the request $request = new client\Request('/api/channel/grid'); if ($filter) $request->setFilter($filter); // Get the response $response = $this->_client->getResponse($request); $rawContent = $response->getContent(); $content = json_decode($rawContent); foreach ($content->entries as $entry) $channels[] = model\Channel::fromRawEntry($entry); return $channels; }
[ "public", "function", "getChannels", "(", "$", "filter", "=", "null", ")", "{", "$", "channels", "=", "array", "(", ")", ";", "// Create the request", "$", "request", "=", "new", "client", "\\", "Request", "(", "'/api/channel/grid'", ")", ";", "if", "(", ...
Returns the list of channels @param model\Filter $filter (optional) filter to use @return model\Channel[]
[ "Returns", "the", "list", "of", "channels" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L229-L249
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.getServices
public function getServices($filter = null) { $services = array(); // Create the request $request = new client\Request('/api/mpegts/service/grid'); if ($filter) $request->setFilter($filter); // Get the response $response = $this->_client->getResponse($request); $rawContent = $response->getContent(); $content = json_decode($rawContent); foreach ($content->entries as $entry) $services[] = model\Service::fromRawEntry($entry); return $services; }
php
public function getServices($filter = null) { $services = array(); // Create the request $request = new client\Request('/api/mpegts/service/grid'); if ($filter) $request->setFilter($filter); // Get the response $response = $this->_client->getResponse($request); $rawContent = $response->getContent(); $content = json_decode($rawContent); foreach ($content->entries as $entry) $services[] = model\Service::fromRawEntry($entry); return $services; }
[ "public", "function", "getServices", "(", "$", "filter", "=", "null", ")", "{", "$", "services", "=", "array", "(", ")", ";", "// Create the request", "$", "request", "=", "new", "client", "\\", "Request", "(", "'/api/mpegts/service/grid'", ")", ";", "if", ...
Returns the list of services @param model\Filter $filter (optional) filter to use @return model\Service[]
[ "Returns", "the", "list", "of", "services" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L256-L276
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.generateCometPollBoxId
private function generateCometPollBoxId() { $request = new client\Request('/comet/poll'); $response = $this->_client->getResponse($request); $content = json_decode($response->getContent()); $boxId = $content->boxid; return new BoxId($boxId); }
php
private function generateCometPollBoxId() { $request = new client\Request('/comet/poll'); $response = $this->_client->getResponse($request); $content = json_decode($response->getContent()); $boxId = $content->boxid; return new BoxId($boxId); }
[ "private", "function", "generateCometPollBoxId", "(", ")", "{", "$", "request", "=", "new", "client", "\\", "Request", "(", "'/comet/poll'", ")", ";", "$", "response", "=", "$", "this", "->", "_client", "->", "getResponse", "(", "$", "request", ")", ";", ...
Requests and returns a new "boxid" from the comet poll API @return BoxId
[ "Requests", "and", "returns", "a", "new", "boxid", "from", "the", "comet", "poll", "API" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L486-L495
train
Jalle19/php-tvheadend
src/Tvheadend.php
Tvheadend.ensureValidBoxId
private function ensureValidBoxId($class) { if (!array_key_exists($class, $this->_boxIds) || $this->_boxIds[$class]->getAge() > self::MAXIMUM_BOXID_AGE) $this->_boxIds[$class] = $this->generateCometPollBoxId(); }
php
private function ensureValidBoxId($class) { if (!array_key_exists($class, $this->_boxIds) || $this->_boxIds[$class]->getAge() > self::MAXIMUM_BOXID_AGE) $this->_boxIds[$class] = $this->generateCometPollBoxId(); }
[ "private", "function", "ensureValidBoxId", "(", "$", "class", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "class", ",", "$", "this", "->", "_boxIds", ")", "||", "$", "this", "->", "_boxIds", "[", "$", "class", "]", "->", "getAge", "(", ")...
Ensures that the specifeid class has a valid box ID defined @param string $class
[ "Ensures", "that", "the", "specifeid", "class", "has", "a", "valid", "box", "ID", "defined" ]
8fad6570f267ba573ca78b243cff7797b6cf8bbf
https://github.com/Jalle19/php-tvheadend/blob/8fad6570f267ba573ca78b243cff7797b6cf8bbf/src/Tvheadend.php#L501-L505
train
GromNaN/TubeLink
src/TubeLink/TubeLink.php
TubeLink.create
static public function create() { $t = new static(); $t->registerService(new Service\Youtube()); $t->registerService(new Service\Dailymotion()); $t->registerService(new Service\Vimeo()); $t->registerService(new Service\Spotify()); $t->registerService(new Service\SoundCloud()); return $t; }
php
static public function create() { $t = new static(); $t->registerService(new Service\Youtube()); $t->registerService(new Service\Dailymotion()); $t->registerService(new Service\Vimeo()); $t->registerService(new Service\Spotify()); $t->registerService(new Service\SoundCloud()); return $t; }
[ "static", "public", "function", "create", "(", ")", "{", "$", "t", "=", "new", "static", "(", ")", ";", "$", "t", "->", "registerService", "(", "new", "Service", "\\", "Youtube", "(", ")", ")", ";", "$", "t", "->", "registerService", "(", "new", "S...
Create a TubeLink instance with all services registered. @return TubeLink\TubeLink
[ "Create", "a", "TubeLink", "instance", "with", "all", "services", "registered", "." ]
a1d9bdd0c92b043d297b95e8069a5b30ceaded9a
https://github.com/GromNaN/TubeLink/blob/a1d9bdd0c92b043d297b95e8069a5b30ceaded9a/src/TubeLink/TubeLink.php#L58-L69
train
manaphp/framework
Cli/Controllers/EnvController.php
EnvController.switchCommand
public function switchCommand($target = '') { if ($target === '' && $values = $this->arguments->getValues()) { $target = $values[0]; } if ($target === '') { $target = $this->arguments->getOption('env'); } $candidates = []; foreach ($this->_getEnvTypes() as $file) { if (strpos($file, $target) === 0) { $candidates[] = $file; } } if (count($candidates) !== 1) { return $this->console->error(['can not one file: :env', 'env' => implode(',', $candidates)]); } $target = $candidates[0]; $glob = '@root/.env[._-]' . $target; $files = $this->filesystem->glob($glob); if ($files) { $file = $files[0]; $this->filesystem->fileCopy($file, '@root/.env', true); if (file_exists($file . '.php')) { $this->filesystem->fileDelete($file . '.php'); } $this->console->writeLn(['copy `:src` to `:dst` success.', 'src' => basename($file), 'dst' => '.env']); return 0; } else { return $this->console->error(['dotenv file `:file` is not exists', 'file' => $glob]); } }
php
public function switchCommand($target = '') { if ($target === '' && $values = $this->arguments->getValues()) { $target = $values[0]; } if ($target === '') { $target = $this->arguments->getOption('env'); } $candidates = []; foreach ($this->_getEnvTypes() as $file) { if (strpos($file, $target) === 0) { $candidates[] = $file; } } if (count($candidates) !== 1) { return $this->console->error(['can not one file: :env', 'env' => implode(',', $candidates)]); } $target = $candidates[0]; $glob = '@root/.env[._-]' . $target; $files = $this->filesystem->glob($glob); if ($files) { $file = $files[0]; $this->filesystem->fileCopy($file, '@root/.env', true); if (file_exists($file . '.php')) { $this->filesystem->fileDelete($file . '.php'); } $this->console->writeLn(['copy `:src` to `:dst` success.', 'src' => basename($file), 'dst' => '.env']); return 0; } else { return $this->console->error(['dotenv file `:file` is not exists', 'file' => $glob]); } }
[ "public", "function", "switchCommand", "(", "$", "target", "=", "''", ")", "{", "if", "(", "$", "target", "===", "''", "&&", "$", "values", "=", "$", "this", "->", "arguments", "->", "getValues", "(", ")", ")", "{", "$", "target", "=", "$", "values...
switch .env @param string $target @return int
[ "switch", ".", "env" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/EnvController.php#L39-L74
train
manaphp/framework
Cli/Controllers/EnvController.php
EnvController.cacheCommand
public function cacheCommand() { $file = $this->alias->resolve('@root/.env'); if (!file_exists($file)) { return $this->console->writeLn(['`:file` dotenv file is not exists', 'file' => $file]); } $data = (new Dotenv())->parse(file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)); $content = '<?php' . PHP_EOL . 'return ' . var_export($data, true) . ';' . PHP_EOL; $this->filesystem->filePut('@root/.env.php', $content); return 0; }
php
public function cacheCommand() { $file = $this->alias->resolve('@root/.env'); if (!file_exists($file)) { return $this->console->writeLn(['`:file` dotenv file is not exists', 'file' => $file]); } $data = (new Dotenv())->parse(file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)); $content = '<?php' . PHP_EOL . 'return ' . var_export($data, true) . ';' . PHP_EOL; $this->filesystem->filePut('@root/.env.php', $content); return 0; }
[ "public", "function", "cacheCommand", "(", ")", "{", "$", "file", "=", "$", "this", "->", "alias", "->", "resolve", "(", "'@root/.env'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "return", "$", "this", "->", "console",...
parse .env file and save to .env.php
[ "parse", ".", "env", "file", "and", "save", "to", ".", "env", ".", "php" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/EnvController.php#L87-L100
train
manaphp/framework
Cli/Controllers/EnvController.php
EnvController.inspectCommand
public function inspectCommand() { $file = $this->alias->resolve('@root/.env'); if (!file_exists($file)) { return $this->console->writeLn(['`:file` dotenv file is not exists', 'file' => $file]); } $data = (new Dotenv())->parse(file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)); $this->console->write(json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); return 0; }
php
public function inspectCommand() { $file = $this->alias->resolve('@root/.env'); if (!file_exists($file)) { return $this->console->writeLn(['`:file` dotenv file is not exists', 'file' => $file]); } $data = (new Dotenv())->parse(file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)); $this->console->write(json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); return 0; }
[ "public", "function", "inspectCommand", "(", ")", "{", "$", "file", "=", "$", "this", "->", "alias", "->", "resolve", "(", "'@root/.env'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "return", "$", "this", "->", "console...
show parsed .env file as json string
[ "show", "parsed", ".", "env", "file", "as", "json", "string" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/EnvController.php#L105-L117
train
milejko/mmi-cms
src/Cms/Form/AttributeForm.php
AttributeForm.beforeSave
public function beforeSave() { //iteracja po elementach dodanych przez atrybuty foreach ($this->_cmsAttributeElements as $attributeId => $element) { //wyszukiwanie atrybutu $attribute = $this->_findAttributeById($attributeId); //jeśli atrybut jest zmaterializowany if (null !== $attribute && $attribute->getJoined('cms_attribute_relation')->isMaterialized()) { //ustawienie wartości w rekordzie $this->getRecord()->{$attribute->key} = $element->getValue(); } } }
php
public function beforeSave() { //iteracja po elementach dodanych przez atrybuty foreach ($this->_cmsAttributeElements as $attributeId => $element) { //wyszukiwanie atrybutu $attribute = $this->_findAttributeById($attributeId); //jeśli atrybut jest zmaterializowany if (null !== $attribute && $attribute->getJoined('cms_attribute_relation')->isMaterialized()) { //ustawienie wartości w rekordzie $this->getRecord()->{$attribute->key} = $element->getValue(); } } }
[ "public", "function", "beforeSave", "(", ")", "{", "//iteracja po elementach dodanych przez atrybuty", "foreach", "(", "$", "this", "->", "_cmsAttributeElements", "as", "$", "attributeId", "=>", "$", "element", ")", "{", "//wyszukiwanie atrybutu", "$", "attribute", "=...
Ustawia w rekordzie zmaterializowane atrybuty
[ "Ustawia", "w", "rekordzie", "zmaterializowane", "atrybuty" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Form/AttributeForm.php#L88-L100
train
milejko/mmi-cms
src/Cms/Form/AttributeForm.php
AttributeForm._parseClassWithOptions
private function _parseClassWithOptions($classWithOptions) { $config = explode(':', $classWithOptions); $class = array_shift($config); //zwrot konfiguracji return (new \Mmi\OptionObject) ->setClass($class) ->setConfig($config); }
php
private function _parseClassWithOptions($classWithOptions) { $config = explode(':', $classWithOptions); $class = array_shift($config); //zwrot konfiguracji return (new \Mmi\OptionObject) ->setClass($class) ->setConfig($config); }
[ "private", "function", "_parseClassWithOptions", "(", "$", "classWithOptions", ")", "{", "$", "config", "=", "explode", "(", "':'", ",", "$", "classWithOptions", ")", ";", "$", "class", "=", "array_shift", "(", "$", "config", ")", ";", "//zwrot konfiguracji", ...
Parsowanie nazwy klasy wraz z opcjami @param string $classWithOptions @return \Mmi\OptionObject
[ "Parsowanie", "nazwy", "klasy", "wraz", "z", "opcjami" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Form/AttributeForm.php#L316-L324
train
manaphp/framework
Cli/Controllers/BashCompletionController.php
BashCompletionController.completeCommand
public function completeCommand() { $arguments = array_slice($GLOBALS['argv'], 3); $position = (int)$arguments[0]; $arguments = array_slice($arguments, 1); $count = count($arguments); $controller = null; if ($count > 1) { $controller = $arguments[1]; } $command = null; if ($count > 2) { $command = $arguments[2]; if ($command !== '' && $command[0] === '-') { $command = 'default'; } } $previous = $position > 0 ? $arguments[$position - 1] : null; $current = isset($arguments[$position]) ? $arguments[$position] : ''; if ($position === 1) { $words = $this->_getControllers(); } elseif ($current !== '' && $current[0] === '-') { $words = $this->_getArgumentNames($controller, $command); } elseif ($position === 2) { $words = $this->_getCommands($controller); } else { $words = $this->_getArgumentValues($controller, $command, $previous); } $this->console->writeLn(implode(' ', $this->_filterWords($words, $current))); return 0; }
php
public function completeCommand() { $arguments = array_slice($GLOBALS['argv'], 3); $position = (int)$arguments[0]; $arguments = array_slice($arguments, 1); $count = count($arguments); $controller = null; if ($count > 1) { $controller = $arguments[1]; } $command = null; if ($count > 2) { $command = $arguments[2]; if ($command !== '' && $command[0] === '-') { $command = 'default'; } } $previous = $position > 0 ? $arguments[$position - 1] : null; $current = isset($arguments[$position]) ? $arguments[$position] : ''; if ($position === 1) { $words = $this->_getControllers(); } elseif ($current !== '' && $current[0] === '-') { $words = $this->_getArgumentNames($controller, $command); } elseif ($position === 2) { $words = $this->_getCommands($controller); } else { $words = $this->_getArgumentValues($controller, $command, $previous); } $this->console->writeLn(implode(' ', $this->_filterWords($words, $current))); return 0; }
[ "public", "function", "completeCommand", "(", ")", "{", "$", "arguments", "=", "array_slice", "(", "$", "GLOBALS", "[", "'argv'", "]", ",", "3", ")", ";", "$", "position", "=", "(", "int", ")", "$", "arguments", "[", "0", "]", ";", "$", "arguments", ...
complete for bash @return int
[ "complete", "for", "bash" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/BashCompletionController.php#L158-L197
train
manaphp/framework
Cli/Controllers/BashCompletionController.php
BashCompletionController.installCommand
public function installCommand() { $content = <<<'EOT' #!/bin/bash _manacli(){ COMPREPLY=( $(./manacli.php bash_completion complete $COMP_CWORD "${COMP_WORDS[@]}") ) return 0; } complete -F _manacli manacli EOT; $file = '/etc/bash_completion.d/manacli'; if (DIRECTORY_SEPARATOR === '\\') { return $this->console->error('Windows system is not support bash completion!'); } try { $this->filesystem->filePut($file, PHP_EOL === '\n' ? $content : str_replace("\r", '', $content)); $this->filesystem->chmod($file, 0755); } catch (\Exception $e) { return $this->console->error('write bash completion script failed: ' . $e->getMessage()); } $this->console->writeLn('install bash completion script successfully'); $this->console->writeLn("please execute `source $file` command to become effective"); return 0; }
php
public function installCommand() { $content = <<<'EOT' #!/bin/bash _manacli(){ COMPREPLY=( $(./manacli.php bash_completion complete $COMP_CWORD "${COMP_WORDS[@]}") ) return 0; } complete -F _manacli manacli EOT; $file = '/etc/bash_completion.d/manacli'; if (DIRECTORY_SEPARATOR === '\\') { return $this->console->error('Windows system is not support bash completion!'); } try { $this->filesystem->filePut($file, PHP_EOL === '\n' ? $content : str_replace("\r", '', $content)); $this->filesystem->chmod($file, 0755); } catch (\Exception $e) { return $this->console->error('write bash completion script failed: ' . $e->getMessage()); } $this->console->writeLn('install bash completion script successfully'); $this->console->writeLn("please execute `source $file` command to become effective"); return 0; }
[ "public", "function", "installCommand", "(", ")", "{", "$", "content", "=", " <<<'EOT'\n#!/bin/bash\n\n_manacli(){\n COMPREPLY=( $(./manacli.php bash_completion complete $COMP_CWORD \"${COMP_WORDS[@]}\") )\n return 0;\n}\n\ncomplete -F _manacli manacli\nEOT", ";", "$", "file", "=", "...
install bash completion script
[ "install", "bash", "completion", "script" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Cli/Controllers/BashCompletionController.php#L202-L230
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.setTables
public function setTables() { foreach ($this->data['tables'] as $alias => $model) { // set model => alias (real table name) $this->builder->addFrom($model, $alias); } return null; }
php
public function setTables() { foreach ($this->data['tables'] as $alias => $model) { // set model => alias (real table name) $this->builder->addFrom($model, $alias); } return null; }
[ "public", "function", "setTables", "(", ")", "{", "foreach", "(", "$", "this", "->", "data", "[", "'tables'", "]", "as", "$", "alias", "=>", "$", "model", ")", "{", "// set model => alias (real table name)", "$", "this", "->", "builder", "->", "addFrom", "...
Setup tables to Builder @return null
[ "Setup", "tables", "to", "Builder" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L59-L69
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.setOrder
public function setOrder() { // set order position if exist $order = []; foreach ($this->data['order'] as $alias => $params) { $order = array_flip($order); if (empty($params) === false) { foreach ($params as $field => $sort) { $order[] = $alias . '.' . $field . ' ' . $sort; } } } $this->builder->orderBy($order); return null; }
php
public function setOrder() { // set order position if exist $order = []; foreach ($this->data['order'] as $alias => $params) { $order = array_flip($order); if (empty($params) === false) { foreach ($params as $field => $sort) { $order[] = $alias . '.' . $field . ' ' . $sort; } } } $this->builder->orderBy($order); return null; }
[ "public", "function", "setOrder", "(", ")", "{", "// set order position if exist", "$", "order", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'order'", "]", "as", "$", "alias", "=>", "$", "params", ")", "{", "$", "order", "=", ...
Setup orders positions to Builder @return null
[ "Setup", "orders", "positions", "to", "Builder" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L76-L95
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.setGroup
public function setGroup() { // set group position if exist $group = []; foreach ($this->data['group'] as $table => $params) { $params = array_flip($params); if (empty($params) === false) { foreach ($params as $field) { $group[] = $table . '.' . $field; } } } $this->builder->groupBy($group); return null; }
php
public function setGroup() { // set group position if exist $group = []; foreach ($this->data['group'] as $table => $params) { $params = array_flip($params); if (empty($params) === false) { foreach ($params as $field) { $group[] = $table . '.' . $field; } } } $this->builder->groupBy($group); return null; }
[ "public", "function", "setGroup", "(", ")", "{", "// set group position if exist", "$", "group", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'group'", "]", "as", "$", "table", "=>", "$", "params", ")", "{", "$", "params", "=", ...
Setup group positions to builder @return null
[ "Setup", "group", "positions", "to", "builder" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L102-L122
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.setWhere
public function setWhere() { // checking of Exact flag $index = 0; foreach ($this->data['where'] as $alias => $fields) { foreach ($fields as $field => $type) { // call expression handler $this->expressionRun($alias, $field, $type, $index); ++$index; } } return null; }
php
public function setWhere() { // checking of Exact flag $index = 0; foreach ($this->data['where'] as $alias => $fields) { foreach ($fields as $field => $type) { // call expression handler $this->expressionRun($alias, $field, $type, $index); ++$index; } } return null; }
[ "public", "function", "setWhere", "(", ")", "{", "// checking of Exact flag", "$", "index", "=", "0", ";", "foreach", "(", "$", "this", "->", "data", "[", "'where'", "]", "as", "$", "alias", "=>", "$", "fields", ")", "{", "foreach", "(", "$", "fields",...
Setup where filter @return null
[ "Setup", "where", "filter" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L158-L172
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.expressionRun
private function expressionRun($table, $field, $type, $index) { if ($type === Column::TYPE_TEXT) { // match query $query = "MATCH(" . $table . "." . $field . ") AGAINST (:query:)"; } else { // simple query $query = $table . "." . $field . " LIKE :query:"; } if ($index > 0) { $this->builder->orWhere($query, $this->ftFilter($type)); } else { $this->builder->where($query, $this->ftFilter($type)); } return null; }
php
private function expressionRun($table, $field, $type, $index) { if ($type === Column::TYPE_TEXT) { // match query $query = "MATCH(" . $table . "." . $field . ") AGAINST (:query:)"; } else { // simple query $query = $table . "." . $field . " LIKE :query:"; } if ($index > 0) { $this->builder->orWhere($query, $this->ftFilter($type)); } else { $this->builder->where($query, $this->ftFilter($type)); } return null; }
[ "private", "function", "expressionRun", "(", "$", "table", ",", "$", "field", ",", "$", "type", ",", "$", "index", ")", "{", "if", "(", "$", "type", "===", "Column", "::", "TYPE_TEXT", ")", "{", "// match query", "$", "query", "=", "\"MATCH(\"", ".", ...
Where condition customizer @param string $table @param string $field @param integer $type type of column @param integer $index counter @return null
[ "Where", "condition", "customizer" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L183-L206
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.loop
public function loop($hydratorset = null, $callback = null) { try { // get valid result $this->data = $this->searcher->getFields(); foreach ($this->data as $key => $values) { // start build interface if (empty($values) === false) { $this->{'set' . ucfirst($key)}(); } } // execute query return $this->setResult($hydratorset, $callback); } catch (ExceptionFactory $e) { echo $e->getMessage(); } }
php
public function loop($hydratorset = null, $callback = null) { try { // get valid result $this->data = $this->searcher->getFields(); foreach ($this->data as $key => $values) { // start build interface if (empty($values) === false) { $this->{'set' . ucfirst($key)}(); } } // execute query return $this->setResult($hydratorset, $callback); } catch (ExceptionFactory $e) { echo $e->getMessage(); } }
[ "public", "function", "loop", "(", "$", "hydratorset", "=", "null", ",", "$", "callback", "=", "null", ")", "{", "try", "{", "// get valid result", "$", "this", "->", "data", "=", "$", "this", "->", "searcher", "->", "getFields", "(", ")", ";", "foreac...
Build query chain @param null $hydratorset @param null $callback @throws ExceptionFactory {$error} @return Builder|null
[ "Build", "query", "chain" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L215-L235
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.ftFilter
protected function ftFilter($type) { if ($type === Column::TYPE_TEXT) { return array_map(function ($v) { return trim($v, '%'); }, $this->searcher->query); } return $this->searcher->query; }
php
protected function ftFilter($type) { if ($type === Column::TYPE_TEXT) { return array_map(function ($v) { return trim($v, '%'); }, $this->searcher->query); } return $this->searcher->query; }
[ "protected", "function", "ftFilter", "(", "$", "type", ")", "{", "if", "(", "$", "type", "===", "Column", "::", "TYPE_TEXT", ")", "{", "return", "array_map", "(", "function", "(", "$", "v", ")", "{", "return", "trim", "(", "$", "v", ",", "'%'", ")"...
Prepare query data to fulltext search @param integer $type column type @return array
[ "Prepare", "query", "data", "to", "fulltext", "search" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L243-L253
train
stanislav-web/Searcher
src/Searcher/Builder.php
Builder.setResult
protected function setResult($hydratorset = null, $callback = null) { $res = $this->builder->getQuery()->execute(); $call = "Searcher\\Searcher\\Hydrators\\" . ucfirst($hydratorset) . "Hydrator"; if ($res->valid() === true) { if(class_exists($call) === true) { $res = (new $call($res))->extract($callback); } return $res; } return null; }
php
protected function setResult($hydratorset = null, $callback = null) { $res = $this->builder->getQuery()->execute(); $call = "Searcher\\Searcher\\Hydrators\\" . ucfirst($hydratorset) . "Hydrator"; if ($res->valid() === true) { if(class_exists($call) === true) { $res = (new $call($res))->extract($callback); } return $res; } return null; }
[ "protected", "function", "setResult", "(", "$", "hydratorset", "=", "null", ",", "$", "callback", "=", "null", ")", "{", "$", "res", "=", "$", "this", "->", "builder", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "$", "call", "=", "\...
Setup output result @param null $hydratorset @param null $callback @return Builder|null
[ "Setup", "output", "result" ]
bf01156d1a2416ceddef0d238469563b74087d44
https://github.com/stanislav-web/Searcher/blob/bf01156d1a2416ceddef0d238469563b74087d44/src/Searcher/Builder.php#L262-L278
train
milejko/mmi-cms
src/Cms/Form/Element/Plupload.php
Plupload.addImprintElement
public function addImprintElement($type, $name, $label = null, $options = []) { $imprint = $this->getOption('imprint'); //brak pól - pusta lista if (null === $imprint) { $imprint = []; } $imprint[] = ['type' => $type, 'name' => $name, 'label' => ($label ?: $name), 'options' => $options]; return $this->setOption('imprint', $imprint); }
php
public function addImprintElement($type, $name, $label = null, $options = []) { $imprint = $this->getOption('imprint'); //brak pól - pusta lista if (null === $imprint) { $imprint = []; } $imprint[] = ['type' => $type, 'name' => $name, 'label' => ($label ?: $name), 'options' => $options]; return $this->setOption('imprint', $imprint); }
[ "public", "function", "addImprintElement", "(", "$", "type", ",", "$", "name", ",", "$", "label", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "imprint", "=", "$", "this", "->", "getOption", "(", "'imprint'", ")", ";", "//brak pól ...
Dodaje pole do metryczki @param string $type typ pola: text, checkbox, textarea, tinymce, select @param string $name nazwa pola @param string $label labelka pola @param string $options opcje pola @return \Cms\Form\Element\Plupload
[ "Dodaje", "pole", "do", "metryczki" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Form/Element/Plupload.php#L251-L260
train
milejko/mmi-cms
src/Cms/Form/Element/Plupload.php
Plupload._beforeRender
protected function _beforeRender() { $this->_id = $this->getOption('id'); if ($this->_form->hasRecord()) { $this->_object = $this->_form->getFileObjectName(); $this->_objectId = $this->_form->getRecord()->getPk(); } //jeśli wymuszony inny object if ($this->getOption('object')) { $this->_object = $this->getOption('object'); } $this->_tempObject = 'tmp-' . $this->_object; $this->_createTempFiles(); return $this; }
php
protected function _beforeRender() { $this->_id = $this->getOption('id'); if ($this->_form->hasRecord()) { $this->_object = $this->_form->getFileObjectName(); $this->_objectId = $this->_form->getRecord()->getPk(); } //jeśli wymuszony inny object if ($this->getOption('object')) { $this->_object = $this->getOption('object'); } $this->_tempObject = 'tmp-' . $this->_object; $this->_createTempFiles(); return $this; }
[ "protected", "function", "_beforeRender", "(", ")", "{", "$", "this", "->", "_id", "=", "$", "this", "->", "getOption", "(", "'id'", ")", ";", "if", "(", "$", "this", "->", "_form", "->", "hasRecord", "(", ")", ")", "{", "$", "this", "->", "_object...
Przygotowanie danych przed renderingiem pola formularza @return \Cms\Form\Element\Plupload
[ "Przygotowanie", "danych", "przed", "renderingiem", "pola", "formularza" ]
95483b08f25136b8d6bcf787ec4ecc3e8bdffb38
https://github.com/milejko/mmi-cms/blob/95483b08f25136b8d6bcf787ec4ecc3e8bdffb38/src/Cms/Form/Element/Plupload.php#L402-L416
train
manaphp/framework
Db/Model/Metadata.php
Metadata._readMetaData
protected function _readMetaData($model) { $modelName = is_string($model) ? $model : get_class($model); if (!isset($this->_metadata[$modelName])) { $data = $this->read($modelName); if ($data !== false) { $this->_metadata[$modelName] = $data; } else { $modelInstance = is_string($model) ? new $model : $model; $data = $this->_di->getShared($modelInstance->getDb(true))->getMetadata($modelInstance->getSource(true)); $this->_metadata[$modelName] = $data; $this->write($modelName, $data); } } return $this->_metadata[$modelName]; }
php
protected function _readMetaData($model) { $modelName = is_string($model) ? $model : get_class($model); if (!isset($this->_metadata[$modelName])) { $data = $this->read($modelName); if ($data !== false) { $this->_metadata[$modelName] = $data; } else { $modelInstance = is_string($model) ? new $model : $model; $data = $this->_di->getShared($modelInstance->getDb(true))->getMetadata($modelInstance->getSource(true)); $this->_metadata[$modelName] = $data; $this->write($modelName, $data); } } return $this->_metadata[$modelName]; }
[ "protected", "function", "_readMetaData", "(", "$", "model", ")", "{", "$", "modelName", "=", "is_string", "(", "$", "model", ")", "?", "$", "model", ":", "get_class", "(", "$", "model", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_...
Reads the complete meta-data for certain model @param string|\ManaPHP\Db\ModelInterface $model @return array
[ "Reads", "the", "complete", "meta", "-", "data", "for", "certain", "model" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Db/Model/Metadata.php#L27-L46
train
pscheit/jparser
PLUG/JavaScript/JParserBase.php
JParserBase.parse_string
static function parse_string( $src, $unicode = true, $parser = __CLASS__, $lexer = 'JTokenizer' ){ $Tokenizer = new $lexer( false, $unicode); $tokens = $Tokenizer->get_all_tokens( $src ); unset( $src ); $Parser = new $parser; return $Parser->parse( $tokens ); }
php
static function parse_string( $src, $unicode = true, $parser = __CLASS__, $lexer = 'JTokenizer' ){ $Tokenizer = new $lexer( false, $unicode); $tokens = $Tokenizer->get_all_tokens( $src ); unset( $src ); $Parser = new $parser; return $Parser->parse( $tokens ); }
[ "static", "function", "parse_string", "(", "$", "src", ",", "$", "unicode", "=", "true", ",", "$", "parser", "=", "__CLASS__", ",", "$", "lexer", "=", "'JTokenizer'", ")", "{", "$", "Tokenizer", "=", "new", "$", "lexer", "(", "false", ",", "$", "unic...
Parse a JavaScript string according to specific parser class @param string source string @param string parser subclass to use @return LRParseNode
[ "Parse", "a", "JavaScript", "string", "according", "to", "specific", "parser", "class" ]
f9de77171c0d37d237e0e9a918ed7bff19e12095
https://github.com/pscheit/jparser/blob/f9de77171c0d37d237e0e9a918ed7bff19e12095/PLUG/JavaScript/JParserBase.php#L43-L49
train
manaphp/framework
Http/Session/Bag.php
Bag.set
public function set($property, $value) { $defaultCurrentValue = []; $data = $this->session->get($this->_name, $defaultCurrentValue); $data[$property] = $value; $this->session->set($this->_name, $data); }
php
public function set($property, $value) { $defaultCurrentValue = []; $data = $this->session->get($this->_name, $defaultCurrentValue); $data[$property] = $value; $this->session->set($this->_name, $data); }
[ "public", "function", "set", "(", "$", "property", ",", "$", "value", ")", "{", "$", "defaultCurrentValue", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "session", "->", "get", "(", "$", "this", "->", "_name", ",", "$", "defaultCurrentVal...
Sets a value in the session bag @param string $property @param mixed $value
[ "Sets", "a", "value", "in", "the", "session", "bag" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Http/Session/Bag.php#L47-L54
train
manaphp/framework
Http/Session/Bag.php
Bag.get
public function get($property = null, $default = null) { $defaultCurrentValue = []; $data = $this->session->get($this->_name, $defaultCurrentValue); if ($property === null) { return $data; } else { return isset($data[$property]) ? $data[$property] : $default; } }
php
public function get($property = null, $default = null) { $defaultCurrentValue = []; $data = $this->session->get($this->_name, $defaultCurrentValue); if ($property === null) { return $data; } else { return isset($data[$property]) ? $data[$property] : $default; } }
[ "public", "function", "get", "(", "$", "property", "=", "null", ",", "$", "default", "=", "null", ")", "{", "$", "defaultCurrentValue", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "session", "->", "get", "(", "$", "this", "->", "_name"...
Obtains a value from the session bag optionally setting a default value @param string $property @param string $default @return mixed
[ "Obtains", "a", "value", "from", "the", "session", "bag", "optionally", "setting", "a", "default", "value" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Http/Session/Bag.php#L64-L74
train
manaphp/framework
Http/Session/Bag.php
Bag.has
public function has($property) { $defaultCurrentValue = []; $data = $this->session->get($this->_name, $defaultCurrentValue); return isset($data[$property]); }
php
public function has($property) { $defaultCurrentValue = []; $data = $this->session->get($this->_name, $defaultCurrentValue); return isset($data[$property]); }
[ "public", "function", "has", "(", "$", "property", ")", "{", "$", "defaultCurrentValue", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "session", "->", "get", "(", "$", "this", "->", "_name", ",", "$", "defaultCurrentValue", ")", ";", "ret...
Check whether a property is defined in the internal bag @param string $property @return bool
[ "Check", "whether", "a", "property", "is", "defined", "in", "the", "internal", "bag" ]
b9a15c7f8f5d4770cacbea43f26914765bfcb248
https://github.com/manaphp/framework/blob/b9a15c7f8f5d4770cacbea43f26914765bfcb248/Http/Session/Bag.php#L83-L89
train
brightnucleus/boilerplate
_scripts/Task/MoveTemplateFilesToRootFolder.php
MoveTemplateFilesToRootFolder.getTargetPath
protected function getTargetPath($pathname) { $filesystem = new Filesystem(); $templatesFolder = $this->getConfigKey('Folders', 'templates'); $folderDiff = '/' . $filesystem->findShortestPath( SetupHelper::getRootFolder(), $templatesFolder ); return (string)$this->removeTemplateExtension(str_replace($folderDiff, '', $pathname)); }
php
protected function getTargetPath($pathname) { $filesystem = new Filesystem(); $templatesFolder = $this->getConfigKey('Folders', 'templates'); $folderDiff = '/' . $filesystem->findShortestPath( SetupHelper::getRootFolder(), $templatesFolder ); return (string)$this->removeTemplateExtension(str_replace($folderDiff, '', $pathname)); }
[ "protected", "function", "getTargetPath", "(", "$", "pathname", ")", "{", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "$", "templatesFolder", "=", "$", "this", "->", "getConfigKey", "(", "'Folders'", ",", "'templates'", ")", ";", "$", "fold...
Get the target path for a rendered file from a template file. @since 0.1.0 @param string $pathname The path and file name to the template file. @return string The target path and file name to use for the rendered file.
[ "Get", "the", "target", "path", "for", "a", "rendered", "file", "from", "a", "template", "file", "." ]
27092790349481e1bece8f79eaccaa15cc35d845
https://github.com/brightnucleus/boilerplate/blob/27092790349481e1bece8f79eaccaa15cc35d845/_scripts/Task/MoveTemplateFilesToRootFolder.php#L58-L68
train
fezfez/codeGenerator
src/CrudGenerator/Utils/ClassAwake.php
ClassAwake.wakeByInterfaces
public function wakeByInterfaces(array $directories, $interfaceNames) { $classCollection = $this->awake($directories); $classes = array(); foreach ($classCollection as $className) { $reflectionClass = new ReflectionClass($className); $interfaces = $reflectionClass->getInterfaces(); if (is_array($interfaces) === true && isset($interfaces[$interfaceNames]) === true) { $class = str_replace('\\', '', strrchr($className, '\\')); $classes[$class] = $className; } } return $classes; }
php
public function wakeByInterfaces(array $directories, $interfaceNames) { $classCollection = $this->awake($directories); $classes = array(); foreach ($classCollection as $className) { $reflectionClass = new ReflectionClass($className); $interfaces = $reflectionClass->getInterfaces(); if (is_array($interfaces) === true && isset($interfaces[$interfaceNames]) === true) { $class = str_replace('\\', '', strrchr($className, '\\')); $classes[$class] = $className; } } return $classes; }
[ "public", "function", "wakeByInterfaces", "(", "array", "$", "directories", ",", "$", "interfaceNames", ")", "{", "$", "classCollection", "=", "$", "this", "->", "awake", "(", "$", "directories", ")", ";", "$", "classes", "=", "array", "(", ")", ";", "fo...
Awake classes by interface @param string[] $directories Target directory @param string $interfaceNames Interface name @return array
[ "Awake", "classes", "by", "interface" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Utils/ClassAwake.php#L30-L46
train
fezfez/codeGenerator
src/CrudGenerator/Utils/ClassAwake.php
ClassAwake.awake
private function awake(array $directories) { $includedFiles = array(); self::$included = array_merge(self::$included, get_included_files()); foreach ($directories as $directorie) { $iterator = new \RegexIterator( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($directorie, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY ), '/^.+' . preg_quote('.php') . '$/i', \RecursiveRegexIterator::GET_MATCH ); foreach ($iterator as $file) { $sourceFile = realpath($file[0]); if (in_array($sourceFile, self::$included) === false) { require_once $sourceFile; } self::$included[] = $sourceFile; $includedFiles[] = $sourceFile; } } $classes = array(); $declared = get_declared_classes(); foreach ($declared as $className) { $rc = new \ReflectionClass($className); $sourceFile = $rc->getFileName(); if (in_array($sourceFile, $includedFiles) === true) { $classes[] = $className; } } return $classes; }
php
private function awake(array $directories) { $includedFiles = array(); self::$included = array_merge(self::$included, get_included_files()); foreach ($directories as $directorie) { $iterator = new \RegexIterator( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($directorie, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY ), '/^.+' . preg_quote('.php') . '$/i', \RecursiveRegexIterator::GET_MATCH ); foreach ($iterator as $file) { $sourceFile = realpath($file[0]); if (in_array($sourceFile, self::$included) === false) { require_once $sourceFile; } self::$included[] = $sourceFile; $includedFiles[] = $sourceFile; } } $classes = array(); $declared = get_declared_classes(); foreach ($declared as $className) { $rc = new \ReflectionClass($className); $sourceFile = $rc->getFileName(); if (in_array($sourceFile, $includedFiles) === true) { $classes[] = $className; } } return $classes; }
[ "private", "function", "awake", "(", "array", "$", "directories", ")", "{", "$", "includedFiles", "=", "array", "(", ")", ";", "self", "::", "$", "included", "=", "array_merge", "(", "self", "::", "$", "included", ",", "get_included_files", "(", ")", ")"...
Find classes on directory @param string[] $directories Target directory @return array
[ "Find", "classes", "on", "directory" ]
559f22bcc525c3157ecb17fe96818dd7b7ee58c2
https://github.com/fezfez/codeGenerator/blob/559f22bcc525c3157ecb17fe96818dd7b7ee58c2/src/CrudGenerator/Utils/ClassAwake.php#L53-L94
train