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
melisplatform/melis-core
src/Service/MelisCoreModulesService.php
MelisCoreModulesService.getVendorModules
public function getVendorModules() { $repos = $this->getComposer()->getRepositoryManager()->getLocalRepository(); $packages = array_filter($repos->getPackages(), function ($package) { /** @var CompletePackage $package */ return $package->getType() === 'melisplatform-module' && array_key_exists('module-name', $package->getExtra()); }); $modules = array_map(function ($package) { /** @var CompletePackage $package */ return $package->getExtra()['module-name']; }, $packages); sort($modules); return $modules; }
php
public function getVendorModules() { $repos = $this->getComposer()->getRepositoryManager()->getLocalRepository(); $packages = array_filter($repos->getPackages(), function ($package) { /** @var CompletePackage $package */ return $package->getType() === 'melisplatform-module' && array_key_exists('module-name', $package->getExtra()); }); $modules = array_map(function ($package) { /** @var CompletePackage $package */ return $package->getExtra()['module-name']; }, $packages); sort($modules); return $modules; }
[ "public", "function", "getVendorModules", "(", ")", "{", "$", "repos", "=", "$", "this", "->", "getComposer", "(", ")", "->", "getRepositoryManager", "(", ")", "->", "getLocalRepository", "(", ")", ";", "$", "packages", "=", "array_filter", "(", "$", "repo...
Returns all melisplatform-module packages loaded by composer @return array
[ "Returns", "all", "melisplatform", "-", "module", "packages", "loaded", "by", "composer" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreModulesService.php#L255-L273
train
melisplatform/melis-core
src/Service/MelisCoreModulesService.php
MelisCoreModulesService.getChildDependencies
public function getChildDependencies($moduleName, $convertPackageNameToNamespace = true, $getOnlyActiveModules = true) { $modules = $this->getAllModules(); $matchModule = $convertPackageNameToNamespace ? $moduleName : $this->convertToPackageName($moduleName); $dependents = []; foreach ($modules as $module) { $dependencies = $this->getDependencies($module, $convertPackageNameToNamespace); if ($dependencies) { if (in_array($matchModule, $dependencies)) { $dependents[] = $convertPackageNameToNamespace ? $module : $this->convertToPackageName($module); } } } if (true === $getOnlyActiveModules) { $activeModules = $this->getActiveModules(); $modules = []; foreach ($dependents as $module) { $modules[] = $module; } $dependents = $modules; } return $dependents; }
php
public function getChildDependencies($moduleName, $convertPackageNameToNamespace = true, $getOnlyActiveModules = true) { $modules = $this->getAllModules(); $matchModule = $convertPackageNameToNamespace ? $moduleName : $this->convertToPackageName($moduleName); $dependents = []; foreach ($modules as $module) { $dependencies = $this->getDependencies($module, $convertPackageNameToNamespace); if ($dependencies) { if (in_array($matchModule, $dependencies)) { $dependents[] = $convertPackageNameToNamespace ? $module : $this->convertToPackageName($module); } } } if (true === $getOnlyActiveModules) { $activeModules = $this->getActiveModules(); $modules = []; foreach ($dependents as $module) { $modules[] = $module; } $dependents = $modules; } return $dependents; }
[ "public", "function", "getChildDependencies", "(", "$", "moduleName", ",", "$", "convertPackageNameToNamespace", "=", "true", ",", "$", "getOnlyActiveModules", "=", "true", ")", "{", "$", "modules", "=", "$", "this", "->", "getAllModules", "(", ")", ";", "$", ...
Returns an array of modules or packages that is dependent to the module name provided @param $moduleName @param bool $convertPackageNameToNamespace @param bool $getOnlyActiveModules - returns only the active modules @return array
[ "Returns", "an", "array", "of", "modules", "or", "packages", "that", "is", "dependent", "to", "the", "module", "name", "provided" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreModulesService.php#L284-L313
train
melisplatform/melis-core
src/Service/MelisCoreModulesService.php
MelisCoreModulesService.getDependencies
public function getDependencies($moduleName, $convertPackageNameToNamespace = true) { $modulePath = $this->getModulePath($moduleName); $dependencies = []; if ($modulePath) { $defaultDependencies = ['melis-core']; $dependencies = $defaultDependencies; $composerPossiblePath = [$modulePath . '/composer.json']; $composerFile = null; // search for the composer.json file foreach ($composerPossiblePath as $file) { if (file_exists($file)) { $composerFile = file_get_contents($file); } } // if composer.json is found if ($composerFile) { $composer = json_decode($composerFile, true); $requires = isset($composer['require']) ? $composer['require'] : null; if ($requires) { $requires = array_map(function ($a) { // remove melisplatform prefix return str_replace(['melisplatform/', ' '], '', trim($a)); }, array_keys($requires)); $dependencies = $requires; } } if ($convertPackageNameToNamespace) { $tmpDependencies = []; $toolSvc = $this->getServiceLocator()->get('MelisCoreTool'); foreach ($dependencies as $dependency) { $tmpDependencies[] = ucfirst($toolSvc->convertToNormalFunction($dependency)); } $dependencies = $tmpDependencies; } } return $dependencies; }
php
public function getDependencies($moduleName, $convertPackageNameToNamespace = true) { $modulePath = $this->getModulePath($moduleName); $dependencies = []; if ($modulePath) { $defaultDependencies = ['melis-core']; $dependencies = $defaultDependencies; $composerPossiblePath = [$modulePath . '/composer.json']; $composerFile = null; // search for the composer.json file foreach ($composerPossiblePath as $file) { if (file_exists($file)) { $composerFile = file_get_contents($file); } } // if composer.json is found if ($composerFile) { $composer = json_decode($composerFile, true); $requires = isset($composer['require']) ? $composer['require'] : null; if ($requires) { $requires = array_map(function ($a) { // remove melisplatform prefix return str_replace(['melisplatform/', ' '], '', trim($a)); }, array_keys($requires)); $dependencies = $requires; } } if ($convertPackageNameToNamespace) { $tmpDependencies = []; $toolSvc = $this->getServiceLocator()->get('MelisCoreTool'); foreach ($dependencies as $dependency) { $tmpDependencies[] = ucfirst($toolSvc->convertToNormalFunction($dependency)); } $dependencies = $tmpDependencies; } } return $dependencies; }
[ "public", "function", "getDependencies", "(", "$", "moduleName", ",", "$", "convertPackageNameToNamespace", "=", "true", ")", "{", "$", "modulePath", "=", "$", "this", "->", "getModulePath", "(", "$", "moduleName", ")", ";", "$", "dependencies", "=", "[", "]...
Returns the dependencies of the module @param $moduleName @param bool $convertPackageNameToNamespace - set to "true" to convert all package name into their actual Module name @return array
[ "Returns", "the", "dependencies", "of", "the", "module" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreModulesService.php#L337-L384
train
melisplatform/melis-core
src/Service/MelisCoreModulesService.php
MelisCoreModulesService.getModulePath
public function getModulePath($moduleName, $returnFullPath = true) { $path = $this->getUserModulePath($moduleName, $returnFullPath); if ($path == '') { $path = $this->getComposerModulePath($moduleName, $returnFullPath); } return $path; }
php
public function getModulePath($moduleName, $returnFullPath = true) { $path = $this->getUserModulePath($moduleName, $returnFullPath); if ($path == '') { $path = $this->getComposerModulePath($moduleName, $returnFullPath); } return $path; }
[ "public", "function", "getModulePath", "(", "$", "moduleName", ",", "$", "returnFullPath", "=", "true", ")", "{", "$", "path", "=", "$", "this", "->", "getUserModulePath", "(", "$", "moduleName", ",", "$", "returnFullPath", ")", ";", "if", "(", "$", "pat...
Returns the full path of the module @param $moduleName @param bool $returnFullPath @return string
[ "Returns", "the", "full", "path", "of", "the", "module" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreModulesService.php#L394-L402
train
melisplatform/melis-core
src/Service/MelisCoreModulesService.php
MelisCoreModulesService.getActiveModules
public function getActiveModules($exclude = []) { $mm = $this->getServiceLocator()->get('ModuleManager'); $loadedModules = array_keys($mm->getLoadedModules()); $pluginModules = $this->getModulePlugins(); $modules = []; foreach ($loadedModules as $module) { if (in_array($module, $pluginModules)) { if (!in_array($module, $exclude)) { $modules[] = $module; } } } return $modules; }
php
public function getActiveModules($exclude = []) { $mm = $this->getServiceLocator()->get('ModuleManager'); $loadedModules = array_keys($mm->getLoadedModules()); $pluginModules = $this->getModulePlugins(); $modules = []; foreach ($loadedModules as $module) { if (in_array($module, $pluginModules)) { if (!in_array($module, $exclude)) { $modules[] = $module; } } } return $modules; }
[ "public", "function", "getActiveModules", "(", "$", "exclude", "=", "[", "]", ")", "{", "$", "mm", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'ModuleManager'", ")", ";", "$", "loadedModules", "=", "array_keys", "(", "$", ...
Returns all the modules that has been loaded in zend @param array $exclude @return array
[ "Returns", "all", "the", "modules", "that", "has", "been", "loaded", "in", "zend" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreModulesService.php#L476-L491
train
melisplatform/melis-core
src/Controller/MelisCoreMicroServiceController.php
MelisCoreMicroServiceController.microServicesListAction
public function microServicesListAction() { $view = new ViewModel(); $translator = $this->getServiceLocator()->get('translator'); $apiKey = trim($this->params()->fromRoute('api_key', '')); $userExists = false; $microservice = array(); $userApiData = $this->getMicroServiceAuthTable()->getUserByApiKey($apiKey)->current(); $apiStatus = ''; $toolTranslator = $this->getServiceLocator()->get('MelisCoreTranslation'); if($userApiData) { $apiStatus = $userApiData->msoa_status; // to validate the API key if it's Active or Inactvie if($apiStatus){ $config = $this->getServiceLocator()->get('MelisCoreConfig'); $microservice = $config->getItem('microservice'); // set the langauge $melisLangTable = $this->serviceLocator->get('MelisCore\Model\Tables\MelisLangTable'); $langData = $melisLangTable->getEntryById($userApiData->usr_lang_id)->current(); if($langData) { $container = new Container('meliscore'); $container['melis-lang-locale'] = $langData->lang_locale; } //Exclude array 'conf' key if(array_key_exists('conf',$microservice)){ unset($microservice['conf']); } $userExists = true; }else{ $message = 'tr_meliscore_microservice_api_key_inactive'; echo "  " .$translator->translate($message); } } else{ } $view->userExists = $userExists; $view->microservice = $microservice; $view->apiKey = $apiKey; $view->title = 'tr_meliscore_microservice_title'; return $view; }
php
public function microServicesListAction() { $view = new ViewModel(); $translator = $this->getServiceLocator()->get('translator'); $apiKey = trim($this->params()->fromRoute('api_key', '')); $userExists = false; $microservice = array(); $userApiData = $this->getMicroServiceAuthTable()->getUserByApiKey($apiKey)->current(); $apiStatus = ''; $toolTranslator = $this->getServiceLocator()->get('MelisCoreTranslation'); if($userApiData) { $apiStatus = $userApiData->msoa_status; // to validate the API key if it's Active or Inactvie if($apiStatus){ $config = $this->getServiceLocator()->get('MelisCoreConfig'); $microservice = $config->getItem('microservice'); // set the langauge $melisLangTable = $this->serviceLocator->get('MelisCore\Model\Tables\MelisLangTable'); $langData = $melisLangTable->getEntryById($userApiData->usr_lang_id)->current(); if($langData) { $container = new Container('meliscore'); $container['melis-lang-locale'] = $langData->lang_locale; } //Exclude array 'conf' key if(array_key_exists('conf',$microservice)){ unset($microservice['conf']); } $userExists = true; }else{ $message = 'tr_meliscore_microservice_api_key_inactive'; echo "  " .$translator->translate($message); } } else{ } $view->userExists = $userExists; $view->microservice = $microservice; $view->apiKey = $apiKey; $view->title = 'tr_meliscore_microservice_title'; return $view; }
[ "public", "function", "microServicesListAction", "(", ")", "{", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", "translator", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'translator'", ")", ";", "$", "apiKey", "=",...
generate all available list of Microservices
[ "generate", "all", "available", "list", "of", "Microservices" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreMicroServiceController.php#L534-L587
train
orchestral/kernel
src/Notifications/Messages/TitleForSubject.php
TitleForSubject.title
public function title(string $title) { $name = config('app.name'); if (empty($this->subject) && ! is_null($name)) { $this->subject(sprintf('[%s] %s', $name, $title)); } $this->title = $title; return $this; }
php
public function title(string $title) { $name = config('app.name'); if (empty($this->subject) && ! is_null($name)) { $this->subject(sprintf('[%s] %s', $name, $title)); } $this->title = $title; return $this; }
[ "public", "function", "title", "(", "string", "$", "title", ")", "{", "$", "name", "=", "config", "(", "'app.name'", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "subject", ")", "&&", "!", "is_null", "(", "$", "name", ")", ")", "{", "$",...
Get the title of the notification. @param string $title @return $this
[ "Get", "the", "title", "of", "the", "notification", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Notifications/Messages/TitleForSubject.php#L21-L32
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/HandlerConfig.php
HandlerConfig.setTemplate
public function setTemplate($template) { if (empty($template)) { $this->template = null; return $this; } if (!is_string($template)) { throw new InvalidArgumentException( 'Handler view template must be a string identifier.' ); } $this->template = $template; return $this; }
php
public function setTemplate($template) { if (empty($template)) { $this->template = null; return $this; } if (!is_string($template)) { throw new InvalidArgumentException( 'Handler view template must be a string identifier.' ); } $this->template = $template; return $this; }
[ "public", "function", "setTemplate", "(", "$", "template", ")", "{", "if", "(", "empty", "(", "$", "template", ")", ")", "{", "$", "this", "->", "template", "=", "null", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", ...
Set the template view. @param string|null $template The template identifier. @throws InvalidArgumentException If the template view is invalid. @return HandlerConfig Chainable
[ "Set", "the", "template", "view", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/HandlerConfig.php#L95-L110
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/HandlerConfig.php
HandlerConfig.setController
public function setController($controller) { if (empty($controller)) { $this->controller = null; return $this; } if (!is_string($controller)) { throw new InvalidArgumentException( 'Handler view controller must be a string.' ); } $this->controller = $controller; return $this; }
php
public function setController($controller) { if (empty($controller)) { $this->controller = null; return $this; } if (!is_string($controller)) { throw new InvalidArgumentException( 'Handler view controller must be a string.' ); } $this->controller = $controller; return $this; }
[ "public", "function", "setController", "(", "$", "controller", ")", "{", "if", "(", "empty", "(", "$", "controller", ")", ")", "{", "$", "this", "->", "controller", "=", "null", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", ...
Set the template controller. @param string|null $controller Handler controller name. @throws InvalidArgumentException If the template controller is invalid. @return self
[ "Set", "the", "template", "controller", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/HandlerConfig.php#L133-L148
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/HandlerConfig.php
HandlerConfig.setEngine
public function setEngine($engine) { if (empty($engine)) { $this->engine = null; return $this; } if (!is_string($engine)) { throw new InvalidArgumentException( 'Engine must be a string (the engine ident)' ); } $this->engine = $engine; return $this; }
php
public function setEngine($engine) { if (empty($engine)) { $this->engine = null; return $this; } if (!is_string($engine)) { throw new InvalidArgumentException( 'Engine must be a string (the engine ident)' ); } $this->engine = $engine; return $this; }
[ "public", "function", "setEngine", "(", "$", "engine", ")", "{", "if", "(", "empty", "(", "$", "engine", ")", ")", "{", "$", "this", "->", "engine", "=", "null", ";", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", "engine...
Set the template rendering engine. @param string|null $engine The view engine identifier. @throws InvalidArgumentException If the engine is invalid. @return self
[ "Set", "the", "template", "rendering", "engine", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/HandlerConfig.php#L190-L205
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/TemplateableHandlerTrait.php
TemplateableHandlerTrait.renderHtmlTemplate
protected function renderHtmlTemplate() { if ($this->cacheEnabled()) { $cachePool = $this->container['cache']; $cacheKey = 'template/'.str_replace('/', '.', $this->cacheIdent()); $cacheItem = $cachePool->getItem($cacheKey); $output = $cacheItem->get(); if ($cacheItem->isMiss()) { $output = $this->renderHtmlTemplateContent(); $cacheItem->set($output, $this->cacheTtl()); $cachePool->save($cacheItem); } } else { $output = $this->renderHtmlTemplateContent(); } return $output; }
php
protected function renderHtmlTemplate() { if ($this->cacheEnabled()) { $cachePool = $this->container['cache']; $cacheKey = 'template/'.str_replace('/', '.', $this->cacheIdent()); $cacheItem = $cachePool->getItem($cacheKey); $output = $cacheItem->get(); if ($cacheItem->isMiss()) { $output = $this->renderHtmlTemplateContent(); $cacheItem->set($output, $this->cacheTtl()); $cachePool->save($cacheItem); } } else { $output = $this->renderHtmlTemplateContent(); } return $output; }
[ "protected", "function", "renderHtmlTemplate", "(", ")", "{", "if", "(", "$", "this", "->", "cacheEnabled", "(", ")", ")", "{", "$", "cachePool", "=", "$", "this", "->", "container", "[", "'cache'", "]", ";", "$", "cacheKey", "=", "'template/'", ".", "...
Render HTML handler. @see \Charcoal\App\Route\TemplateRoute::templateContent() Equivalent @return string
[ "Render", "HTML", "handler", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/TemplateableHandlerTrait.php#L42-L61
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/TemplateableHandlerTrait.php
TemplateableHandlerTrait.renderHtmlTemplateContent
protected function renderHtmlTemplateContent() { $config = $this->config(); $factory = $this->templateFactory(); $factory->setDefaultClass($config['default_controller']); $controller = $factory->create($config['controller']); $controller->init($this->httpRequest()); $controller['app_handler'] = $this; $controller->setData($this->getTemplateData()); foreach ($config['partials'] as $varName => $templateIdent) { $this->view()->setDynamicTemplate($varName, $templateIdent); } return $this->view()->render($config['template'], $controller); }
php
protected function renderHtmlTemplateContent() { $config = $this->config(); $factory = $this->templateFactory(); $factory->setDefaultClass($config['default_controller']); $controller = $factory->create($config['controller']); $controller->init($this->httpRequest()); $controller['app_handler'] = $this; $controller->setData($this->getTemplateData()); foreach ($config['partials'] as $varName => $templateIdent) { $this->view()->setDynamicTemplate($varName, $templateIdent); } return $this->view()->render($config['template'], $controller); }
[ "protected", "function", "renderHtmlTemplateContent", "(", ")", "{", "$", "config", "=", "$", "this", "->", "config", "(", ")", ";", "$", "factory", "=", "$", "this", "->", "templateFactory", "(", ")", ";", "$", "factory", "->", "setDefaultClass", "(", "...
Render HTML template. @see \Charcoal\App\Route\TemplateRoute::renderTemplate() Equivalent @see \Charcoal\App\Route\TemplateRoute::createTemplate() Equivalent @return string
[ "Render", "HTML", "template", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/TemplateableHandlerTrait.php#L70-L87
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/AbstractError.php
AbstractError.renderHtmlErrorDetails
public function renderHtmlErrorDetails() { $error = $this->getThrown(); $html = $this->renderHtmlError($error); while ($error = $error->getPrevious()) { $html .= '<h2>'.$this->translator()->translate('Previous error').'</h2>'; $html .= $this->renderHtmlError($error); } return $html; }
php
public function renderHtmlErrorDetails() { $error = $this->getThrown(); $html = $this->renderHtmlError($error); while ($error = $error->getPrevious()) { $html .= '<h2>'.$this->translator()->translate('Previous error').'</h2>'; $html .= $this->renderHtmlError($error); } return $html; }
[ "public", "function", "renderHtmlErrorDetails", "(", ")", "{", "$", "error", "=", "$", "this", "->", "getThrown", "(", ")", ";", "$", "html", "=", "$", "this", "->", "renderHtmlError", "(", "$", "error", ")", ";", "while", "(", "$", "error", "=", "$"...
Render the HTML error details. @return string
[ "Render", "the", "HTML", "error", "details", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/AbstractError.php#L73-L84
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/AbstractError.php
AbstractError.getMessage
public function getMessage() { if ($this->displayErrorDetails() && $this->hasThrown()) { return $this->getThrown()->getMessage(); } else { return $this->translator()->translate( 'The server encountered a problem. Sorry for the temporary inconvenience.', [], 'charcoal' ); } }
php
public function getMessage() { if ($this->displayErrorDetails() && $this->hasThrown()) { return $this->getThrown()->getMessage(); } else { return $this->translator()->translate( 'The server encountered a problem. Sorry for the temporary inconvenience.', [], 'charcoal' ); } }
[ "public", "function", "getMessage", "(", ")", "{", "if", "(", "$", "this", "->", "displayErrorDetails", "(", ")", "&&", "$", "this", "->", "hasThrown", "(", ")", ")", "{", "return", "$", "this", "->", "getThrown", "(", ")", "->", "getMessage", "(", "...
Retrieve the handler's message. @return string
[ "Retrieve", "the", "handler", "s", "message", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/AbstractError.php#L111-L122
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/AbstractError.php
AbstractError.logError
protected function logError($message) { if ($this->logger instanceof LoggerInterface) { $this->logger->error($message); } else { error_log($message); } }
php
protected function logError($message) { if ($this->logger instanceof LoggerInterface) { $this->logger->error($message); } else { error_log($message); } }
[ "protected", "function", "logError", "(", "$", "message", ")", "{", "if", "(", "$", "this", "->", "logger", "instanceof", "LoggerInterface", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "message", ")", ";", "}", "else", "{", "error_l...
Wraps the error_log function so that this can be easily tested @param string $message The message to log. @return void
[ "Wraps", "the", "error_log", "function", "so", "that", "this", "can", "be", "easily", "tested" ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/AbstractError.php#L242-L249
train
locomotivemtl/charcoal-app
src/Charcoal/App/Handler/AbstractError.php
AbstractError.parseTemplateData
protected function parseTemplateData($data = []) { $error = $this->getThrown(); $html = $this->renderHtmlError($error); while ($error = $error->getPrevious()) { $html .= '<h2>'.$this->translator()->translate('Previous error').'</h2>'; $html .= $this->renderHtmlError($error); } $data['htmlErrorDetails'] = $html; $data['displayErrorDetails'] = $this->displayErrorDetails() && !empty($html); return parent::parseTemplateData($data); }
php
protected function parseTemplateData($data = []) { $error = $this->getThrown(); $html = $this->renderHtmlError($error); while ($error = $error->getPrevious()) { $html .= '<h2>'.$this->translator()->translate('Previous error').'</h2>'; $html .= $this->renderHtmlError($error); } $data['htmlErrorDetails'] = $html; $data['displayErrorDetails'] = $this->displayErrorDetails() && !empty($html); return parent::parseTemplateData($data); }
[ "protected", "function", "parseTemplateData", "(", "$", "data", "=", "[", "]", ")", "{", "$", "error", "=", "$", "this", "->", "getThrown", "(", ")", ";", "$", "html", "=", "$", "this", "->", "renderHtmlError", "(", "$", "error", ")", ";", "while", ...
Prepare the template data for rendering. @param mixed $data Raw template data. @return array Expanded and processed template data.
[ "Prepare", "the", "template", "data", "for", "rendering", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/AbstractError.php#L386-L400
train
locomotivemtl/charcoal-app
src/Charcoal/App/Script/ArgScriptTrait.php
ArgScriptTrait.parseAsArray
protected function parseAsArray($var, $delimiter = '[\s,]+') { if (is_string($var)) { if (!is_string($delimiter)) { throw new InvalidArgumentException('The delimiter must be a string.'); } $var = preg_split('#(?<!\\\\)'.$delimiter.'#', $var); } if (is_array($var) || $var instanceof Traversable) { return $var; } throw new InvalidArgumentException('The value cannot be split.'); }
php
protected function parseAsArray($var, $delimiter = '[\s,]+') { if (is_string($var)) { if (!is_string($delimiter)) { throw new InvalidArgumentException('The delimiter must be a string.'); } $var = preg_split('#(?<!\\\\)'.$delimiter.'#', $var); } if (is_array($var) || $var instanceof Traversable) { return $var; } throw new InvalidArgumentException('The value cannot be split.'); }
[ "protected", "function", "parseAsArray", "(", "$", "var", ",", "$", "delimiter", "=", "'[\\s,]+'", ")", "{", "if", "(", "is_string", "(", "$", "var", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "delimiter", ")", ")", "{", "throw", "new", ...
Resolve the given value as a collection of values. If the given value is a string, it will be split. @param mixed $var An argument to split. @param string $delimiter The boundary string. @throws InvalidArgumentException If the value cannot be parsed into an array. @return array|Traversable
[ "Resolve", "the", "given", "value", "as", "a", "collection", "of", "values", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/ArgScriptTrait.php#L24-L39
train
locomotivemtl/charcoal-app
src/Charcoal/App/Script/ArgScriptTrait.php
ArgScriptTrait.parseArguments
protected function parseArguments() { $cli = $this->climate(); $args = $cli->arguments; $ask = $args->defined('interactive'); $params = $this->arguments(); foreach ($params as $key => $param) { $setter = $this->setter($key); if (!is_callable([ $this, $setter ])) { continue; } $value = $args->get($key); if (!empty($value) || is_numeric($value)) { $this->{$setter}($value); } if ($ask) { if (isset($param['prompt'])) { $label = $param['prompt']; } else { continue; } $value = $this->input($key); if (!empty($value) || is_numeric($value)) { $this->{$setter}($value); } } } return $this; }
php
protected function parseArguments() { $cli = $this->climate(); $args = $cli->arguments; $ask = $args->defined('interactive'); $params = $this->arguments(); foreach ($params as $key => $param) { $setter = $this->setter($key); if (!is_callable([ $this, $setter ])) { continue; } $value = $args->get($key); if (!empty($value) || is_numeric($value)) { $this->{$setter}($value); } if ($ask) { if (isset($param['prompt'])) { $label = $param['prompt']; } else { continue; } $value = $this->input($key); if (!empty($value) || is_numeric($value)) { $this->{$setter}($value); } } } return $this; }
[ "protected", "function", "parseArguments", "(", ")", "{", "$", "cli", "=", "$", "this", "->", "climate", "(", ")", ";", "$", "args", "=", "$", "cli", "->", "arguments", ";", "$", "ask", "=", "$", "args", "->", "defined", "(", "'interactive'", ")", ...
Parse command line arguments into script properties. @throws RuntimeException If a checkbox/radio argument has no options. @return self
[ "Parse", "command", "line", "arguments", "into", "script", "properties", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/ArgScriptTrait.php#L47-L81
train
Magicalex/WriteiniFile
src/ReadiniFile.php
ReadiniFile.get
public static function get($ini_file, $scanner_mode = INI_SCANNER_RAW) { self::$path_to_ini_file = $ini_file; if (file_exists(self::$path_to_ini_file) === true) { self::$data_ini_file = @parse_ini_file(self::$path_to_ini_file, true, $scanner_mode); } else { throw new \Exception(sprintf('File ini does not exist: %s', self::$path_to_ini_file)); } if (self::$data_ini_file === false) { throw new \Exception(sprintf('Unable to parse file ini: %s', self::$path_to_ini_file)); } return self::$data_ini_file; }
php
public static function get($ini_file, $scanner_mode = INI_SCANNER_RAW) { self::$path_to_ini_file = $ini_file; if (file_exists(self::$path_to_ini_file) === true) { self::$data_ini_file = @parse_ini_file(self::$path_to_ini_file, true, $scanner_mode); } else { throw new \Exception(sprintf('File ini does not exist: %s', self::$path_to_ini_file)); } if (self::$data_ini_file === false) { throw new \Exception(sprintf('Unable to parse file ini: %s', self::$path_to_ini_file)); } return self::$data_ini_file; }
[ "public", "static", "function", "get", "(", "$", "ini_file", ",", "$", "scanner_mode", "=", "INI_SCANNER_RAW", ")", "{", "self", "::", "$", "path_to_ini_file", "=", "$", "ini_file", ";", "if", "(", "file_exists", "(", "self", "::", "$", "path_to_ini_file", ...
method for get data of ini file. @param string $ini_file path of ini file @param int $scanner_mode scanner mode INI_SCANNER_RAW INI_SCANNER_TYPED or INI_SCANNER_NORMAL @return array ini file data in a array
[ "method", "for", "get", "data", "of", "ini", "file", "." ]
19fe9bd3041219fecdd63e1f0ae14f86cb6800cb
https://github.com/Magicalex/WriteiniFile/blob/19fe9bd3041219fecdd63e1f0ae14f86cb6800cb/src/ReadiniFile.php#L28-L43
train
orchestral/kernel
src/Publisher/MigrateManager.php
MigrateManager.createMigrationRepository
protected function createMigrationRepository(): void { $repository = $this->migrator->getRepository(); if (! $repository->repositoryExists()) { $repository->createRepository(); } }
php
protected function createMigrationRepository(): void { $repository = $this->migrator->getRepository(); if (! $repository->repositoryExists()) { $repository->createRepository(); } }
[ "protected", "function", "createMigrationRepository", "(", ")", ":", "void", "{", "$", "repository", "=", "$", "this", "->", "migrator", "->", "getRepository", "(", ")", ";", "if", "(", "!", "$", "repository", "->", "repositoryExists", "(", ")", ")", "{", ...
Create migration repository if it's not available. @return void
[ "Create", "migration", "repository", "if", "it", "s", "not", "available", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Publisher/MigrateManager.php#L42-L49
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.renderToolUserAction
public function renderToolUserAction() { $translator = $this->getServiceLocator()->get('translator'); $melisKey = $this->params()->fromRoute('melisKey', ''); $noAccessPrompt = 'tr_meliscore_no_access_to_tool'; $hasAccess = $this->hasAccess($this::TOOL_KEY); if(!$hasAccess) { $noAccessPrompt = $translator->translate('tr_tool_no_access'); } $melisKey = $this->params()->fromRoute('melisKey', ''); $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->title = $melisTool->getTitle(); $view->melisKey = $melisKey; $view->hasAccess = $hasAccess; return $view; }
php
public function renderToolUserAction() { $translator = $this->getServiceLocator()->get('translator'); $melisKey = $this->params()->fromRoute('melisKey', ''); $noAccessPrompt = 'tr_meliscore_no_access_to_tool'; $hasAccess = $this->hasAccess($this::TOOL_KEY); if(!$hasAccess) { $noAccessPrompt = $translator->translate('tr_tool_no_access'); } $melisKey = $this->params()->fromRoute('melisKey', ''); $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->title = $melisTool->getTitle(); $view->melisKey = $melisKey; $view->hasAccess = $hasAccess; return $view; }
[ "public", "function", "renderToolUserAction", "(", ")", "{", "$", "translator", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'translator'", ")", ";", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRou...
Renders the main container of the tool @return \Zend\View\Model\ViewModel
[ "Renders", "the", "main", "container", "of", "the", "tool" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L30-L52
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.renderToolUserContentAction
public function renderToolUserContentAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation'); $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); $translator = $this->getServiceLocator()->get('translator'); $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $moduleSvc = $this->getServiceLocator()->get('ModulesService'); $modules = $moduleSvc->getAllModules(); $request = $this->getRequest(); $uri = $request->getUri(); $domain = isset($get['domain']) ? $get['domain'] : null; $scheme = isset($get['scheme']) ? $get['scheme'] : null; $columns = $melisTool->getColumns(); // add action column $columns['actions'] = array('text' => $translator->translate('tr_meliscore_global_action'), 'css' => 'width:10%'); $netStatus = $melisTool->isConnected(); $view = new ViewModel(); $view->melisKey = $melisKey; $view->tableColumns = $columns; $view->getToolDataTableConfig = $melisTool->getDataTableConfiguration(); $melisTool->setMelisToolKey('meliscore', 'user_view_date_connection_tool'); $view->getToolDataTableConfigForDateConnection = $melisTool->getDataTableConfiguration('#tableUserViewDateConnection', null, null, array('order' => '[[ 0, "desc" ]]')); $view->modules = serialize($modules); $view->scheme = $scheme; $view->domain = $domain; $view->netStatus = $netStatus; return $view; }
php
public function renderToolUserContentAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation'); $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); $translator = $this->getServiceLocator()->get('translator'); $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $moduleSvc = $this->getServiceLocator()->get('ModulesService'); $modules = $moduleSvc->getAllModules(); $request = $this->getRequest(); $uri = $request->getUri(); $domain = isset($get['domain']) ? $get['domain'] : null; $scheme = isset($get['scheme']) ? $get['scheme'] : null; $columns = $melisTool->getColumns(); // add action column $columns['actions'] = array('text' => $translator->translate('tr_meliscore_global_action'), 'css' => 'width:10%'); $netStatus = $melisTool->isConnected(); $view = new ViewModel(); $view->melisKey = $melisKey; $view->tableColumns = $columns; $view->getToolDataTableConfig = $melisTool->getDataTableConfiguration(); $melisTool->setMelisToolKey('meliscore', 'user_view_date_connection_tool'); $view->getToolDataTableConfigForDateConnection = $melisTool->getDataTableConfiguration('#tableUserViewDateConnection', null, null, array('order' => '[[ 0, "desc" ]]')); $view->modules = serialize($modules); $view->scheme = $scheme; $view->domain = $domain; $view->netStatus = $netStatus; return $view; }
[ "public", "function", "renderToolUserContentAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "melisTranslation", "=", "$", "this", "->", "getServiceLocator", ...
Renders the content of the tool @return \Zend\View\Model\ViewModel
[ "Renders", "the", "content", "of", "the", "tool" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L118-L155
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.renderToolUserModalHandlerNewAction
public function renderToolUserModalHandlerNewAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->melisKey = $melisKey; $view->newUserModal = $melisTool->getModal('meliscore_tool_user_new_modal'); return $view; }
php
public function renderToolUserModalHandlerNewAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->melisKey = $melisKey; $view->newUserModal = $melisTool->getModal('meliscore_tool_user_new_modal'); return $view; }
[ "public", "function", "renderToolUserModalHandlerNewAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "// declare the Tool service that we will be using to completely create ou...
Handles the rights if Add Modal Content should be displayed for the user @return \Zend\View\Model\ViewModel
[ "Handles", "the", "rights", "if", "Add", "Modal", "Content", "should", "be", "displayed", "for", "the", "user" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L225-L240
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.renderTooluserModalNewAction
public function renderTooluserModalNewAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->melisKey = $melisKey; $view->setVariable('meliscore_tool_user_form_new', $melisTool->getForm('meliscore_tool_user_form_new')); return $view; }
php
public function renderTooluserModalNewAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->melisKey = $melisKey; $view->setVariable('meliscore_tool_user_form_new', $melisTool->getForm('meliscore_tool_user_form_new')); return $view; }
[ "public", "function", "renderTooluserModalNewAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "// declare the Tool service that we will be using to completely create our tool....
Renders to the New Form content for the modal @return \Zend\View\Model\ViewModel
[ "Renders", "to", "the", "New", "Form", "content", "for", "the", "modal" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L246-L262
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.renderToolUserModalHandlerNewRightsAction
public function renderToolUserModalHandlerNewRightsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->melisKey = $melisKey; $view->newRightsModal = $melisTool->getModal('meliscore_tool_user_new_rights_modal'); return $view; }
php
public function renderToolUserModalHandlerNewRightsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey('meliscore', $this::TOOL_KEY); $view = new ViewModel(); $view->melisKey = $melisKey; $view->newRightsModal = $melisTool->getModal('meliscore_tool_user_new_rights_modal'); return $view; }
[ "public", "function", "renderToolUserModalHandlerNewRightsAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "// declare the Tool service that we will be using to completely cre...
Handles the rights if New User Content should be displayed for the user @return \Zend\View\Model\ViewModel
[ "Handles", "the", "rights", "if", "New", "User", "Content", "should", "be", "displayed", "for", "the", "user" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L334-L349
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.renderToolUserModalRightsAction
public function renderToolUserModalRightsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
php
public function renderToolUserModalRightsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
[ "public", "function", "renderToolUserModalRightsAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", "v...
Renders to the Edit Rights Form content for the modal @return \Zend\View\Model\ViewModel
[ "Renders", "to", "the", "Edit", "Rights", "Form", "content", "for", "the", "modal" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L356-L365
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.renderToolUserModalNewRightsAction
public function renderToolUserModalNewRightsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
php
public function renderToolUserModalNewRightsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
[ "public", "function", "renderToolUserModalNewRightsAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", ...
Renders to the New Rights Form content for the modal @return \Zend\View\Model\ViewModel
[ "Renders", "to", "the", "New", "Rights", "Form", "content", "for", "the", "modal" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L371-L380
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.addNewUserAction
public function addNewUserAction() { $container = new Container('meliscore'); $response = []; $this->getEventManager()->trigger('meliscore_tooluser_savenew_start', $this, $response); $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $appConfigForm = $melisMelisCoreConfig->getItem('meliscore/tools/meliscore_tool_user/forms/meliscore_tool_user_form_new'); $appConfigForm = $appConfigForm['elements']; $success = 0; $errors = []; $datas = []; $textTitle = 'tr_meliscore_tool_user'; if (!empty($container['action-tool-user-tmp'])) { if (!empty($container['action-tool-user-tmp']['success'])) { $success = $container['action-tool-user-tmp']['success']; } if (!empty($container['action-tool-user-tmp']['errors'])) { $errors = $container['action-tool-user-tmp']['errors']; } if (!empty($container['action-tool-user-tmp']['datas'])) { $datas = $container['action-tool-user-tmp']['datas']; } } unset($container['action-tool-user-tmp']); unset($container['action-tool-user-setrights-tmp']); foreach ($errors as $keyError => $valueError) { foreach ($appConfigForm as $keyForm => $valueForm) { if ($valueForm['spec']['name'] == $keyError && !empty($valueForm['spec']['options']['label'])) { $errors[$keyError]['label'] = $valueForm['spec']['options']['label']; } } } if ($success == 0) { $textMessage = 'tr_meliscore_tool_user_new_fail_info'; } else { $textMessage = 'tr_meliscore_tool_user_new_success_info'; } $userId = null; if (!empty($datas['usr_id'])) { $userId = $datas['usr_id']; unset($datas['usr_id']); } $response = [ 'success' => $success, 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'errors' => $errors, 'datas' => $datas ]; $this->getEventManager()->trigger('meliscore_tooluser_savenew_end', $this, array_merge($response, ['typeCode' => 'CORE_USER_ADD', 'itemId' => $userId])); unset($response['datas']); return new JsonModel($response); }
php
public function addNewUserAction() { $container = new Container('meliscore'); $response = []; $this->getEventManager()->trigger('meliscore_tooluser_savenew_start', $this, $response); $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $appConfigForm = $melisMelisCoreConfig->getItem('meliscore/tools/meliscore_tool_user/forms/meliscore_tool_user_form_new'); $appConfigForm = $appConfigForm['elements']; $success = 0; $errors = []; $datas = []; $textTitle = 'tr_meliscore_tool_user'; if (!empty($container['action-tool-user-tmp'])) { if (!empty($container['action-tool-user-tmp']['success'])) { $success = $container['action-tool-user-tmp']['success']; } if (!empty($container['action-tool-user-tmp']['errors'])) { $errors = $container['action-tool-user-tmp']['errors']; } if (!empty($container['action-tool-user-tmp']['datas'])) { $datas = $container['action-tool-user-tmp']['datas']; } } unset($container['action-tool-user-tmp']); unset($container['action-tool-user-setrights-tmp']); foreach ($errors as $keyError => $valueError) { foreach ($appConfigForm as $keyForm => $valueForm) { if ($valueForm['spec']['name'] == $keyError && !empty($valueForm['spec']['options']['label'])) { $errors[$keyError]['label'] = $valueForm['spec']['options']['label']; } } } if ($success == 0) { $textMessage = 'tr_meliscore_tool_user_new_fail_info'; } else { $textMessage = 'tr_meliscore_tool_user_new_success_info'; } $userId = null; if (!empty($datas['usr_id'])) { $userId = $datas['usr_id']; unset($datas['usr_id']); } $response = [ 'success' => $success, 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'errors' => $errors, 'datas' => $datas ]; $this->getEventManager()->trigger('meliscore_tooluser_savenew_end', $this, array_merge($response, ['typeCode' => 'CORE_USER_ADD', 'itemId' => $userId])); unset($response['datas']); return new JsonModel($response); }
[ "public", "function", "addNewUserAction", "(", ")", "{", "$", "container", "=", "new", "Container", "(", "'meliscore'", ")", ";", "$", "response", "=", "[", "]", ";", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "'meliscore_tooluse...
Adds a new user to the database @return JsonModel
[ "Adds", "a", "new", "user", "to", "the", "database" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L439-L505
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.deleteUserAction
public function deleteUserAction() { $response = array(); $this->getEventManager()->trigger('meliscore_tooluser_delete_start', $this, $response); $translator = $this->getServiceLocator()->get('translator'); $id = null; $success = 0; $textTitle = 'tr_meliscore_tool_user_delete'; $textMessage = 'tr_meliscore_tool_user_delete_unable'; $userTable = $this->getServiceLocator()->get('MelisCoreTableUser'); if($this->getRequest()->isPost()) { $id = $this->getRequest()->getPost('id'); if(is_numeric($id)) { $userTable->deleteById($id); $success = 1; $textMessage = 'tr_meliscore_tool_user_delete_success'; } } $response = array( 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'success' => $success ); $this->getEventManager()->trigger('meliscore_tooluser_delete_end', $this, array_merge($response, array('typeCode' => 'CORE_USER_DELETE', 'itemId' => $id))); return new JsonModel($response); }
php
public function deleteUserAction() { $response = array(); $this->getEventManager()->trigger('meliscore_tooluser_delete_start', $this, $response); $translator = $this->getServiceLocator()->get('translator'); $id = null; $success = 0; $textTitle = 'tr_meliscore_tool_user_delete'; $textMessage = 'tr_meliscore_tool_user_delete_unable'; $userTable = $this->getServiceLocator()->get('MelisCoreTableUser'); if($this->getRequest()->isPost()) { $id = $this->getRequest()->getPost('id'); if(is_numeric($id)) { $userTable->deleteById($id); $success = 1; $textMessage = 'tr_meliscore_tool_user_delete_success'; } } $response = array( 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'success' => $success ); $this->getEventManager()->trigger('meliscore_tooluser_delete_end', $this, array_merge($response, array('typeCode' => 'CORE_USER_DELETE', 'itemId' => $id))); return new JsonModel($response); }
[ "public", "function", "deleteUserAction", "(", ")", "{", "$", "response", "=", "array", "(", ")", ";", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "'meliscore_tooluser_delete_start'", ",", "$", "this", ",", "$", "response", ")", "...
Handles the Delete User event @return \Zend\View\Model\JsonModel
[ "Handles", "the", "Delete", "User", "event" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L676-L708
train
melisplatform/melis-core
src/Controller/ToolUserController.php
ToolUserController.updateUserAction
public function updateUserAction() { $response = []; $this->getEventManager()->trigger('meliscore_tooluser_save_start', $this, $response); $container = new Container('meliscore'); $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $appConfigForm = $melisMelisCoreConfig->getItem('meliscore/tools/meliscore_tool_user/forms/meliscore_tool_user_form_edit'); $appConfigForm = $appConfigForm['elements']; $success = 0; $errors = []; $datas = []; $textTitle = 'tr_meliscore_tool_user'; //$textMessage = ''; if (!empty($container['action-tool-user-tmp'])) { if (!empty($container['action-tool-user-tmp']['success'])) { $success = $container['action-tool-user-tmp']['success']; } if (!empty($container['action-tool-user-tmp']['errors'])) { $errors = $container['action-tool-user-tmp']['errors']; } if (!empty($container['action-tool-user-tmp']['datas'])) { $datas = $container['action-tool-user-tmp']['datas']; } } foreach ($errors as $keyError => $valueError) { foreach ($appConfigForm as $keyForm => $valueForm) { if ($valueForm['spec']['name'] == $keyError && !empty($valueForm['spec']['options']['label'])) { $errors[$keyError]['label'] = $valueForm['spec']['options']['label']; } } } unset($container['action-tool-user-tmp']); unset($container['action-tool-user-setrights-tmp']); if ($success == 0) { $textMessage = 'tr_meliscore_tool_user_update_fail_info'; } else { $textMessage = 'tr_meliscore_tool_user_update_success_info'; } $userId = null; $request = $this->getRequest(); $postData = $request->getPost()->toArray(); if (!empty($postData['usr_id'])) { $userId = $postData['usr_id']; } $response = [ 'success' => $success, 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'errors' => $errors, 'datas' => $datas ]; $this->getEventManager()->trigger('meliscore_tooluser_save_end', $this, array_merge($response, ['typeCode' => 'CORE_USER_UPDATE', 'itemId' => $userId])); return new JsonModel($response); }
php
public function updateUserAction() { $response = []; $this->getEventManager()->trigger('meliscore_tooluser_save_start', $this, $response); $container = new Container('meliscore'); $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $appConfigForm = $melisMelisCoreConfig->getItem('meliscore/tools/meliscore_tool_user/forms/meliscore_tool_user_form_edit'); $appConfigForm = $appConfigForm['elements']; $success = 0; $errors = []; $datas = []; $textTitle = 'tr_meliscore_tool_user'; //$textMessage = ''; if (!empty($container['action-tool-user-tmp'])) { if (!empty($container['action-tool-user-tmp']['success'])) { $success = $container['action-tool-user-tmp']['success']; } if (!empty($container['action-tool-user-tmp']['errors'])) { $errors = $container['action-tool-user-tmp']['errors']; } if (!empty($container['action-tool-user-tmp']['datas'])) { $datas = $container['action-tool-user-tmp']['datas']; } } foreach ($errors as $keyError => $valueError) { foreach ($appConfigForm as $keyForm => $valueForm) { if ($valueForm['spec']['name'] == $keyError && !empty($valueForm['spec']['options']['label'])) { $errors[$keyError]['label'] = $valueForm['spec']['options']['label']; } } } unset($container['action-tool-user-tmp']); unset($container['action-tool-user-setrights-tmp']); if ($success == 0) { $textMessage = 'tr_meliscore_tool_user_update_fail_info'; } else { $textMessage = 'tr_meliscore_tool_user_update_success_info'; } $userId = null; $request = $this->getRequest(); $postData = $request->getPost()->toArray(); if (!empty($postData['usr_id'])) { $userId = $postData['usr_id']; } $response = [ 'success' => $success, 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'errors' => $errors, 'datas' => $datas ]; $this->getEventManager()->trigger('meliscore_tooluser_save_end', $this, array_merge($response, ['typeCode' => 'CORE_USER_UPDATE', 'itemId' => $userId])); return new JsonModel($response); }
[ "public", "function", "updateUserAction", "(", ")", "{", "$", "response", "=", "[", "]", ";", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "'meliscore_tooluser_save_start'", ",", "$", "this", ",", "$", "response", ")", ";", "$", ...
Saves user account details @return JsonModel
[ "Saves", "user", "account", "details" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ToolUserController.php#L1212-L1280
train
locomotivemtl/charcoal-app
src/Charcoal/App/Script/AbstractScript.php
AbstractScript.input
protected function input($name) { $cli = $this->climate(); $arg = $this->argument($name); if ($arg) { $type = (isset($arg['inputType']) ? $arg['inputType'] : 'input'); if (isset($arg['prompt'])) { $label = $arg['prompt']; } elseif (isset($arg['description'])) { $label = $arg['description']; } else { $label = $name; } if (isset($arg['choices'])) { $arg['options'] = $arg['choices']; $arg['acceptValue'] = $arg['choices']; } $accept = true; } else { $type = 'input'; $label = $name; $accept = false; } $prompt = 'prompt'; switch ($type) { case 'checkboxes': case 'radio': if (!isset($arg['options'])) { throw new RuntimeException( sprintf('The [%s] argument has no options.', $name) ); } $accept = false; $input = $cli->{$type}($label, $arg['options'], $this->climateReader); break; case 'confirm': $prompt = 'confirmed'; $input = $cli->confirm($label, $this->climateReader); break; case 'password': $input = $cli->password($label, $this->climateReader); $input->multiLine(); break; case 'multiline': $input = $cli->input($label, $this->climateReader); $input->multiLine(); break; default: $input = $cli->input($label, $this->climateReader); break; } if ($accept) { if (isset($arg['acceptValue'])) { if (is_array($arg['acceptValue']) || is_callable($arg['acceptValue'])) { $input->accept($arg['acceptValue']); } } } return $input->{$prompt}(); }
php
protected function input($name) { $cli = $this->climate(); $arg = $this->argument($name); if ($arg) { $type = (isset($arg['inputType']) ? $arg['inputType'] : 'input'); if (isset($arg['prompt'])) { $label = $arg['prompt']; } elseif (isset($arg['description'])) { $label = $arg['description']; } else { $label = $name; } if (isset($arg['choices'])) { $arg['options'] = $arg['choices']; $arg['acceptValue'] = $arg['choices']; } $accept = true; } else { $type = 'input'; $label = $name; $accept = false; } $prompt = 'prompt'; switch ($type) { case 'checkboxes': case 'radio': if (!isset($arg['options'])) { throw new RuntimeException( sprintf('The [%s] argument has no options.', $name) ); } $accept = false; $input = $cli->{$type}($label, $arg['options'], $this->climateReader); break; case 'confirm': $prompt = 'confirmed'; $input = $cli->confirm($label, $this->climateReader); break; case 'password': $input = $cli->password($label, $this->climateReader); $input->multiLine(); break; case 'multiline': $input = $cli->input($label, $this->climateReader); $input->multiLine(); break; default: $input = $cli->input($label, $this->climateReader); break; } if ($accept) { if (isset($arg['acceptValue'])) { if (is_array($arg['acceptValue']) || is_callable($arg['acceptValue'])) { $input->accept($arg['acceptValue']); } } } return $input->{$prompt}(); }
[ "protected", "function", "input", "(", "$", "name", ")", "{", "$", "cli", "=", "$", "this", "->", "climate", "(", ")", ";", "$", "arg", "=", "$", "this", "->", "argument", "(", "$", "name", ")", ";", "if", "(", "$", "arg", ")", "{", "$", "typ...
Request a value from the user for the given argument. @param string $name An argument identifier. @throws RuntimeException If a radio or checkbox prompt has no options. @return mixed Returns the prompt value.
[ "Request", "a", "value", "from", "the", "user", "for", "the", "given", "argument", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/AbstractScript.php#L430-L501
train
orchestral/kernel
src/Routing/Concerns/ControllerResponse.php
ControllerResponse.redirectWithMessage
public function redirectWithMessage( string $to, ?string $message = null, string $type = 'success' ): RedirectResponse { return \redirect_with_message($to, $message, $type); }
php
public function redirectWithMessage( string $to, ?string $message = null, string $type = 'success' ): RedirectResponse { return \redirect_with_message($to, $message, $type); }
[ "public", "function", "redirectWithMessage", "(", "string", "$", "to", ",", "?", "string", "$", "message", "=", "null", ",", "string", "$", "type", "=", "'success'", ")", ":", "RedirectResponse", "{", "return", "\\", "redirect_with_message", "(", "$", "to", ...
Queue notification and redirect. @param string $to @param string|null $message @param string $type @return \Illuminate\Http\RedirectResponse
[ "Queue", "notification", "and", "redirect", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Routing/Concerns/ControllerResponse.php#L20-L26
train
orchestral/kernel
src/Publisher/CommandServiceProvider.php
CommandServiceProvider.registerAssetPublishCommand
protected function registerAssetPublishCommand(): void { $this->app->singleton('command.asset.publish', function (Application $app) { return new AssetPublishCommand($app->make('asset.publisher')); }); }
php
protected function registerAssetPublishCommand(): void { $this->app->singleton('command.asset.publish', function (Application $app) { return new AssetPublishCommand($app->make('asset.publisher')); }); }
[ "protected", "function", "registerAssetPublishCommand", "(", ")", ":", "void", "{", "$", "this", "->", "app", "->", "singleton", "(", "'command.asset.publish'", ",", "function", "(", "Application", "$", "app", ")", "{", "return", "new", "AssetPublishCommand", "(...
Register the asset publish console command. @return void
[ "Register", "the", "asset", "publish", "console", "command", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Publisher/CommandServiceProvider.php#L122-L127
train
orchestral/kernel
src/Publisher/CommandServiceProvider.php
CommandServiceProvider.registerConfigPublishCommand
protected function registerConfigPublishCommand(): void { $this->app->singleton('command.config.publish', function (Application $app) { return new ConfigPublishCommand($app->make('config.publisher')); }); }
php
protected function registerConfigPublishCommand(): void { $this->app->singleton('command.config.publish', function (Application $app) { return new ConfigPublishCommand($app->make('config.publisher')); }); }
[ "protected", "function", "registerConfigPublishCommand", "(", ")", ":", "void", "{", "$", "this", "->", "app", "->", "singleton", "(", "'command.config.publish'", ",", "function", "(", "Application", "$", "app", ")", "{", "return", "new", "ConfigPublishCommand", ...
Register the configuration publish console command. @return void
[ "Register", "the", "configuration", "publish", "console", "command", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Publisher/CommandServiceProvider.php#L134-L139
train
orchestral/kernel
src/Publisher/CommandServiceProvider.php
CommandServiceProvider.registerViewPublishCommand
protected function registerViewPublishCommand(): void { $this->app->singleton('command.view.publish', function (Application $app) { return new ViewPublishCommand($app->make('view.publisher')); }); }
php
protected function registerViewPublishCommand(): void { $this->app->singleton('command.view.publish', function (Application $app) { return new ViewPublishCommand($app->make('view.publisher')); }); }
[ "protected", "function", "registerViewPublishCommand", "(", ")", ":", "void", "{", "$", "this", "->", "app", "->", "singleton", "(", "'command.view.publish'", ",", "function", "(", "Application", "$", "app", ")", "{", "return", "new", "ViewPublishCommand", "(", ...
Register the view publish console command. @return void
[ "Register", "the", "view", "publish", "console", "command", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Publisher/CommandServiceProvider.php#L146-L151
train
orchestral/kernel
src/Config/NamespacedItemResolver.php
NamespacedItemResolver.parsePackageSegments
protected function parsePackageSegments($key, $namespace, $item) { $itemSegments = explode('.', $item); // If the configuration file doesn't exist for the given package group we can // assume that we should implicitly use the config file matching the name // of the namespace. Generally packages should use one type or another. if (! $this->getLoader()->exists($itemSegments[0], $namespace)) { return [$namespace, 'config', $item]; } return parent::parseNamespacedSegments($key); }
php
protected function parsePackageSegments($key, $namespace, $item) { $itemSegments = explode('.', $item); // If the configuration file doesn't exist for the given package group we can // assume that we should implicitly use the config file matching the name // of the namespace. Generally packages should use one type or another. if (! $this->getLoader()->exists($itemSegments[0], $namespace)) { return [$namespace, 'config', $item]; } return parent::parseNamespacedSegments($key); }
[ "protected", "function", "parsePackageSegments", "(", "$", "key", ",", "$", "namespace", ",", "$", "item", ")", "{", "$", "itemSegments", "=", "explode", "(", "'.'", ",", "$", "item", ")", ";", "// If the configuration file doesn't exist for the given package group ...
Parse the segments of a package namespace. @param string $key @param string $namespace @param string $item @return array
[ "Parse", "the", "segments", "of", "a", "package", "namespace", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Config/NamespacedItemResolver.php#L92-L104
train
chillerlan/php-authenticator
src/Authenticator.php
Authenticator.getUri
public function getUri(string $label, string $issuer, int $hotpCounter = null):string{ $values = [ 'secret' => $this->getSecret(), 'issuer' => $issuer, 'digits' => $this->options->digits, 'algorithm' => $this->options->algorithm, ]; if($this->options->mode === 'totp'){ $values['period'] = $this->options->period; } if($this->options->mode === 'hotp' && $hotpCounter !== null){ $values['counter'] = $hotpCounter; } return 'otpauth://'.$this->options->mode.'/'.rawurlencode($label).'?'.http_build_query($values, '', '&', PHP_QUERY_RFC3986); }
php
public function getUri(string $label, string $issuer, int $hotpCounter = null):string{ $values = [ 'secret' => $this->getSecret(), 'issuer' => $issuer, 'digits' => $this->options->digits, 'algorithm' => $this->options->algorithm, ]; if($this->options->mode === 'totp'){ $values['period'] = $this->options->period; } if($this->options->mode === 'hotp' && $hotpCounter !== null){ $values['counter'] = $hotpCounter; } return 'otpauth://'.$this->options->mode.'/'.rawurlencode($label).'?'.http_build_query($values, '', '&', PHP_QUERY_RFC3986); }
[ "public", "function", "getUri", "(", "string", "$", "label", ",", "string", "$", "issuer", ",", "int", "$", "hotpCounter", "=", "null", ")", ":", "string", "{", "$", "values", "=", "[", "'secret'", "=>", "$", "this", "->", "getSecret", "(", ")", ",",...
Creates an URI for use in QR codes for example @link https://github.com/google/google-authenticator/wiki/Key-Uri-Format#parameters @param string $label @param string $issuer @param int|null $hotpCounter @return string
[ "Creates", "an", "URI", "for", "use", "in", "QR", "codes", "for", "example" ]
3d13f35038c4a71e9e101110f821ca7e0679f5ea
https://github.com/chillerlan/php-authenticator/blob/3d13f35038c4a71e9e101110f821ca7e0679f5ea/src/Authenticator.php#L206-L224
train
melisplatform/melis-core
src/Service/MelisCoreFlashMessengerService.php
MelisCoreFlashMessengerService.getFlashMessengerMessages
public function getFlashMessengerMessages() { $this->fmContainer = new Container('fms'); $flashMessages = $this->fmContainer->flashMessages; if(!empty($flashMessages)) { $flashMessages = array_reverse($flashMessages); } return Json::encode($flashMessages); }
php
public function getFlashMessengerMessages() { $this->fmContainer = new Container('fms'); $flashMessages = $this->fmContainer->flashMessages; if(!empty($flashMessages)) { $flashMessages = array_reverse($flashMessages); } return Json::encode($flashMessages); }
[ "public", "function", "getFlashMessengerMessages", "(", ")", "{", "$", "this", "->", "fmContainer", "=", "new", "Container", "(", "'fms'", ")", ";", "$", "flashMessages", "=", "$", "this", "->", "fmContainer", "->", "flashMessages", ";", "if", "(", "!", "e...
Returns all the messages stored in Melis Flash Messenger @return Json
[ "Returns", "all", "the", "messages", "stored", "in", "Melis", "Flash", "Messenger" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreFlashMessengerService.php#L102-L113
train
melisplatform/melis-core
src/Controller/TreeToolsController.php
TreeToolsController.moveToolsToOthersCategory
private function moveToolsToOthersCategory(): array { $leftMenu = $this->getConfig()->getItem('meliscore/interface/meliscore_leftmenu/interface'); $mergeToOthers = []; foreach ($leftMenu as $melisKey => $item) { if (!in_array($melisKey, $this->getAllowedLeftMenuConfig())) { $mergeToOthers[$melisKey] = $item; } } return $mergeToOthers; }
php
private function moveToolsToOthersCategory(): array { $leftMenu = $this->getConfig()->getItem('meliscore/interface/meliscore_leftmenu/interface'); $mergeToOthers = []; foreach ($leftMenu as $melisKey => $item) { if (!in_array($melisKey, $this->getAllowedLeftMenuConfig())) { $mergeToOthers[$melisKey] = $item; } } return $mergeToOthers; }
[ "private", "function", "moveToolsToOthersCategory", "(", ")", ":", "array", "{", "$", "leftMenu", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getItem", "(", "'meliscore/interface/meliscore_leftmenu/interface'", ")", ";", "$", "mergeToOthers", "=", "[", ...
Retrieves all configuration under left menu configuration with an exception to those allowable left menu configurations @return array
[ "Retrieves", "all", "configuration", "under", "left", "menu", "configuration", "with", "an", "exception", "to", "those", "allowable", "left", "menu", "configurations" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/TreeToolsController.php#L208-L220
train
orchestral/kernel
src/Routing/VersionedHelpers.php
VersionedHelpers.transform
protected function transform($instance, string $transformer, ?string $serializer = null, array $options = []) { if (\is_null($serializer)) { $serializer = $transformer; } return $this->serializeWith( $this->transformWith($instance, $transformer, $options), $serializer, $options ); }
php
protected function transform($instance, string $transformer, ?string $serializer = null, array $options = []) { if (\is_null($serializer)) { $serializer = $transformer; } return $this->serializeWith( $this->transformWith($instance, $transformer, $options), $serializer, $options ); }
[ "protected", "function", "transform", "(", "$", "instance", ",", "string", "$", "transformer", ",", "?", "string", "$", "serializer", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "\\", "is_null", "(", "$", "serializer"...
Transform and serialize the instance. @param \Orchestra\Model\Eloquent|\Illuminate\Support\Collection $instance @param string $transformer @param string|null $serializer @param array $options @return array
[ "Transform", "and", "serialize", "the", "instance", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Routing/VersionedHelpers.php#L23-L34
train
orchestral/kernel
src/Routing/VersionedHelpers.php
VersionedHelpers.processWith
protected function processWith($instance, string $name, string $method, ...$parameters) { $processor = $this->getVersionedResourceClassName('Processors', $name); return \app($processor)->{$method}($this, $instance, ...$parameters); }
php
protected function processWith($instance, string $name, string $method, ...$parameters) { $processor = $this->getVersionedResourceClassName('Processors', $name); return \app($processor)->{$method}($this, $instance, ...$parameters); }
[ "protected", "function", "processWith", "(", "$", "instance", ",", "string", "$", "name", ",", "string", "$", "method", ",", "...", "$", "parameters", ")", "{", "$", "processor", "=", "$", "this", "->", "getVersionedResourceClassName", "(", "'Processors'", "...
Process the instance. @param \Orchestra\Model\Eloquent|\Illuminate\Support\Collection $instance @param string $name @param string $method @param mixed $parameters @return mixed
[ "Process", "the", "instance", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Routing/VersionedHelpers.php#L46-L51
train
orchestral/kernel
src/Routing/VersionedHelpers.php
VersionedHelpers.transformWith
protected function transformWith($instance, string $name, array $options = []) { $transformer = $this->getVersionedResourceClassName('Transformers', $name); if (\class_exists($transformer)) { $transformer = \resolve($transformer); if ($transformer instanceof Transformer) { return $transformer->options($options)->handle($instance); } if ($transformer instanceof BaseTransformer) { return $transformer->handle($instance); } return $instance->transform($transformer); } return $instance; }
php
protected function transformWith($instance, string $name, array $options = []) { $transformer = $this->getVersionedResourceClassName('Transformers', $name); if (\class_exists($transformer)) { $transformer = \resolve($transformer); if ($transformer instanceof Transformer) { return $transformer->options($options)->handle($instance); } if ($transformer instanceof BaseTransformer) { return $transformer->handle($instance); } return $instance->transform($transformer); } return $instance; }
[ "protected", "function", "transformWith", "(", "$", "instance", ",", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "transformer", "=", "$", "this", "->", "getVersionedResourceClassName", "(", "'Transformers'", ",", "$", ...
Transform the instance. @param \Orchestra\Model\Eloquent|\Illuminate\Support\Collection $instance @param string $name @param array $options @return mixed
[ "Transform", "the", "instance", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Routing/VersionedHelpers.php#L62-L81
train
orchestral/kernel
src/Routing/VersionedHelpers.php
VersionedHelpers.serializeWith
protected function serializeWith($instance, string $name) { $serializer = $this->getVersionedResourceClassName('Serializers', $name); if (\class_exists($serializer)) { return \call_user_func(app($serializer), $instance); } if ($instance instanceof Fluent) { return $instance->getAttributes(); } elseif ($instance instanceof Collection) { return $instance->all(); } elseif ($instance instanceof Arrayable) { return $instance->toArray(); } return $instance; }
php
protected function serializeWith($instance, string $name) { $serializer = $this->getVersionedResourceClassName('Serializers', $name); if (\class_exists($serializer)) { return \call_user_func(app($serializer), $instance); } if ($instance instanceof Fluent) { return $instance->getAttributes(); } elseif ($instance instanceof Collection) { return $instance->all(); } elseif ($instance instanceof Arrayable) { return $instance->toArray(); } return $instance; }
[ "protected", "function", "serializeWith", "(", "$", "instance", ",", "string", "$", "name", ")", "{", "$", "serializer", "=", "$", "this", "->", "getVersionedResourceClassName", "(", "'Serializers'", ",", "$", "name", ")", ";", "if", "(", "\\", "class_exists...
Serialize the instance. @param mixed $instance @param string $name @return array
[ "Serialize", "the", "instance", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Routing/VersionedHelpers.php#L91-L108
train
orchestral/kernel
src/Config/FileLoader.php
FileLoader.cascadePackage
public function cascadePackage(string $env, string $package, string $group, array $items): array { // First we will look for a configuration file in the packages configuration // folder. If it exists, we will load it and merge it with these original // options so that we will easily "cascade" a package's configurations. $file = "packages/{$package}/{$group}.php"; if ($this->files->exists($path = $this->defaultPath.'/'.$file)) { $items = \array_merge($items, $this->getRequire($path)); } // Once we have merged the regular package configuration we need to look for // an environment specific configuration file. If one exists, we will get // the contents and merge them on top of this array of options we have. $path = $this->getPackagePath($env, $package, $group); if ($this->files->exists($path)) { $items = \array_merge($items, $this->getRequire($path)); } return $items; }
php
public function cascadePackage(string $env, string $package, string $group, array $items): array { // First we will look for a configuration file in the packages configuration // folder. If it exists, we will load it and merge it with these original // options so that we will easily "cascade" a package's configurations. $file = "packages/{$package}/{$group}.php"; if ($this->files->exists($path = $this->defaultPath.'/'.$file)) { $items = \array_merge($items, $this->getRequire($path)); } // Once we have merged the regular package configuration we need to look for // an environment specific configuration file. If one exists, we will get // the contents and merge them on top of this array of options we have. $path = $this->getPackagePath($env, $package, $group); if ($this->files->exists($path)) { $items = \array_merge($items, $this->getRequire($path)); } return $items; }
[ "public", "function", "cascadePackage", "(", "string", "$", "env", ",", "string", "$", "package", ",", "string", "$", "group", ",", "array", "$", "items", ")", ":", "array", "{", "// First we will look for a configuration file in the packages configuration", "// folde...
Apply any cascades to an array of package options. @param string $env @param string $package @param string $group @param array $items @return array
[ "Apply", "any", "cascades", "to", "an", "array", "of", "package", "options", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Config/FileLoader.php#L151-L172
train
orchestral/kernel
src/Config/FileLoader.php
FileLoader.getPackagePath
protected function getPackagePath(string $env, string $package, string $group): string { $file = "packages/{$package}/{$env}/{$group}.php"; return $this->defaultPath.'/'.$file; }
php
protected function getPackagePath(string $env, string $package, string $group): string { $file = "packages/{$package}/{$env}/{$group}.php"; return $this->defaultPath.'/'.$file; }
[ "protected", "function", "getPackagePath", "(", "string", "$", "env", ",", "string", "$", "package", ",", "string", "$", "group", ")", ":", "string", "{", "$", "file", "=", "\"packages/{$package}/{$env}/{$group}.php\"", ";", "return", "$", "this", "->", "defau...
Get the package path for an environment and group. @param string $env @param string $package @param string $group @return string
[ "Get", "the", "package", "path", "for", "an", "environment", "and", "group", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Config/FileLoader.php#L183-L188
train
orchestral/kernel
src/Config/FileLoader.php
FileLoader.getPath
protected function getPath(?string $namespace): ?string { if (\is_null($namespace)) { return $this->defaultPath; } elseif (isset($this->hints[$namespace])) { return $this->hints[$namespace]; } return null; }
php
protected function getPath(?string $namespace): ?string { if (\is_null($namespace)) { return $this->defaultPath; } elseif (isset($this->hints[$namespace])) { return $this->hints[$namespace]; } return null; }
[ "protected", "function", "getPath", "(", "?", "string", "$", "namespace", ")", ":", "?", "string", "{", "if", "(", "\\", "is_null", "(", "$", "namespace", ")", ")", "{", "return", "$", "this", "->", "defaultPath", ";", "}", "elseif", "(", "isset", "(...
Get the configuration path for a namespace. @param string|null $namespace @return string|null
[ "Get", "the", "configuration", "path", "for", "a", "namespace", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Config/FileLoader.php#L197-L206
train
melisplatform/melis-core
public/js/filemanager/uploader/jupload.php
JUpload.tobytes
private function tobytes($val) { $val = trim($val); $last = fix_strtolower($val{strlen($val)-1}); switch($last) { case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; }
php
private function tobytes($val) { $val = trim($val); $last = fix_strtolower($val{strlen($val)-1}); switch($last) { case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; }
[ "private", "function", "tobytes", "(", "$", "val", ")", "{", "$", "val", "=", "trim", "(", "$", "val", ")", ";", "$", "last", "=", "fix_strtolower", "(", "$", "val", "{", "strlen", "(", "$", "val", ")", "-", "1", "}", ")", ";", "switch", "(", ...
Convert a value ending in 'G','M' or 'K' to bytes
[ "Convert", "a", "value", "ending", "in", "G", "M", "or", "K", "to", "bytes" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/uploader/jupload.php#L240-L252
train
melisplatform/melis-core
public/js/filemanager/uploader/jupload.php
JUpload.str_applet
private function str_applet() { $N = "\n"; $params = $this->appletparams; // return the actual applet tag $ret = '<object classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"'.$N; $ret .= ' codebase = "http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,3"'.$N; $ret .= ' width = "'.$params['width'].'"'.$N; $ret .= ' height = "'.$params['height'].'"'.$N; $ret .= ' name = "'.$params['name'].'">'.$N; foreach ($params as $key => $val) { if ($key != 'width' && $key != 'height') $ret .= ' <param name = "'.$key.'" value = "'.$val.'" />'.$N; } $ret .= ' <comment>'.$N; $ret .= ' <embed'.$N; $ret .= ' type = "application/x-java-applet;version=1.5"'.$N; foreach ($params as $key => $val) $ret .= ' '.$key.' = "'.$val.'"'.$N; $ret .= ' pluginspage = "http://java.sun.com/products/plugin/index.html#download">'.$N; $ret .= ' <noembed>'.$N; $ret .= ' Java 1.5 or higher plugin required.'.$N; $ret .= ' </noembed>'.$N; $ret .= ' </embed>'.$N; $ret .= ' </comment>'.$N; $ret .= '</object>'; return $ret; }
php
private function str_applet() { $N = "\n"; $params = $this->appletparams; // return the actual applet tag $ret = '<object classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"'.$N; $ret .= ' codebase = "http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,3"'.$N; $ret .= ' width = "'.$params['width'].'"'.$N; $ret .= ' height = "'.$params['height'].'"'.$N; $ret .= ' name = "'.$params['name'].'">'.$N; foreach ($params as $key => $val) { if ($key != 'width' && $key != 'height') $ret .= ' <param name = "'.$key.'" value = "'.$val.'" />'.$N; } $ret .= ' <comment>'.$N; $ret .= ' <embed'.$N; $ret .= ' type = "application/x-java-applet;version=1.5"'.$N; foreach ($params as $key => $val) $ret .= ' '.$key.' = "'.$val.'"'.$N; $ret .= ' pluginspage = "http://java.sun.com/products/plugin/index.html#download">'.$N; $ret .= ' <noembed>'.$N; $ret .= ' Java 1.5 or higher plugin required.'.$N; $ret .= ' </noembed>'.$N; $ret .= ' </embed>'.$N; $ret .= ' </comment>'.$N; $ret .= '</object>'; return $ret; }
[ "private", "function", "str_applet", "(", ")", "{", "$", "N", "=", "\"\\n\"", ";", "$", "params", "=", "$", "this", "->", "appletparams", ";", "// return the actual applet tag", "$", "ret", "=", "'<object classid = \"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\"'", "."...
Build a string, containing the applet tag with all parameters. @return A string, containing the applet tag
[ "Build", "a", "string", "containing", "the", "applet", "tag", "with", "all", "parameters", "." ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/uploader/jupload.php#L284-L310
train
melisplatform/melis-core
public/js/filemanager/uploader/jupload.php
JUpload.defaultAfterUploadManagement
public function defaultAfterUploadManagement() { $flist = '[defaultAfterUploadManagement] Nb uploaded files is: ' . sizeof($this->files); $flist = $this->classparams['http_flist_start']; foreach ($this->files as $f) { //$f is an array, that contains all info about the uploaded file. $this->logDebug('defaultAfterUploadManagement', " Reading file ${f['name']}"); $flist .= $this->classparams['http_flist_file_before']; $flist .= $f['name']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['size']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['relativePath']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['fullName']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['md5sum']; $addBR = false; foreach ($f as $key=>$value) { //If it's a specific key, let's display it: if ($key != 'name' && $key != 'size' && $key != 'relativePath' && $key != 'fullName' && $key != 'md5sum') { if ($addBR) { $flist .= "<br>"; } else { // First line. We must add a new 'official' list separator. $flist .= $this->classparams['http_flist_file_between']; $addBR = true; } $flist .= "$key => $value"; } } $flist .= $this->classparams['http_flist_file_after']; } $flist .= $this->classparams['http_flist_end']; return $flist; }
php
public function defaultAfterUploadManagement() { $flist = '[defaultAfterUploadManagement] Nb uploaded files is: ' . sizeof($this->files); $flist = $this->classparams['http_flist_start']; foreach ($this->files as $f) { //$f is an array, that contains all info about the uploaded file. $this->logDebug('defaultAfterUploadManagement', " Reading file ${f['name']}"); $flist .= $this->classparams['http_flist_file_before']; $flist .= $f['name']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['size']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['relativePath']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['fullName']; $flist .= $this->classparams['http_flist_file_between']; $flist .= $f['md5sum']; $addBR = false; foreach ($f as $key=>$value) { //If it's a specific key, let's display it: if ($key != 'name' && $key != 'size' && $key != 'relativePath' && $key != 'fullName' && $key != 'md5sum') { if ($addBR) { $flist .= "<br>"; } else { // First line. We must add a new 'official' list separator. $flist .= $this->classparams['http_flist_file_between']; $addBR = true; } $flist .= "$key => $value"; } } $flist .= $this->classparams['http_flist_file_after']; } $flist .= $this->classparams['http_flist_end']; return $flist; }
[ "public", "function", "defaultAfterUploadManagement", "(", ")", "{", "$", "flist", "=", "'[defaultAfterUploadManagement] Nb uploaded files is: '", ".", "sizeof", "(", "$", "this", "->", "files", ")", ";", "$", "flist", "=", "$", "this", "->", "classparams", "[", ...
Example function to process the files uploaded. This one simply displays the files' data.
[ "Example", "function", "to", "process", "the", "files", "uploaded", ".", "This", "one", "simply", "displays", "the", "files", "data", "." ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/uploader/jupload.php#L424-L459
train
melisplatform/melis-core
public/js/filemanager/uploader/jupload.php
JUpload.receive_debug_log
private function receive_debug_log() { // handle error report if (isset($_POST['description']) && isset($_POST['log'])) { $msg = $_POST['log']; mail($this->classparams['errormail'], $_POST['description'], $msg); } else { if (isset($_SERVER['SERVER_ADMIN'])) mail($_SERVER['SERVER_ADMIN'], 'Empty jupload error log', 'An empty log has just been posted.'); $this->logPHPDebug('receive_debug_log', 'Empty error log received'); } exit; }
php
private function receive_debug_log() { // handle error report if (isset($_POST['description']) && isset($_POST['log'])) { $msg = $_POST['log']; mail($this->classparams['errormail'], $_POST['description'], $msg); } else { if (isset($_SERVER['SERVER_ADMIN'])) mail($_SERVER['SERVER_ADMIN'], 'Empty jupload error log', 'An empty log has just been posted.'); $this->logPHPDebug('receive_debug_log', 'Empty error log received'); } exit; }
[ "private", "function", "receive_debug_log", "(", ")", "{", "// handle error report", "if", "(", "isset", "(", "$", "_POST", "[", "'description'", "]", ")", "&&", "isset", "(", "$", "_POST", "[", "'log'", "]", ")", ")", "{", "$", "msg", "=", "$", "_POST...
This method manages the receiving of the debug log, when an error occurs.
[ "This", "method", "manages", "the", "receiving", "of", "the", "debug", "log", "when", "an", "error", "occurs", "." ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/uploader/jupload.php#L507-L519
train
melisplatform/melis-core
src/Controller/PluginViewController.php
PluginViewController.generateAction
public function generateAction() { /** * Determine if it comes from an ajax call * so we can send back different datas with the html */ $isXmlHttpRequest = false; if ($this->getRequest()->isXmlHttpRequest()) { $isXmlHttpRequest = true; } /** * Get the params from php call */ $appconfigpath = $this->params()->fromRoute('appconfigpath', '/'); $keyView = $this->params()->fromRoute('keyview', 'melis'); /** * Else get the params from GET if ajax */ $datasParameters = []; if ($isXmlHttpRequest) { $appconfigpath = $this->getRequest()->getQuery('cpath'); $lastKey = explode('/', $appconfigpath); $keyView = $lastKey[count($lastKey) - 1]; } /** * Forcing to set the request to http request */ if ($this->getRequest()->getQuery('forceFlagXmlHttpRequestTofalse', false)) $isXmlHttpRequest = false; /** * Get the appConfig */ $melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig'); /** * Get the real path, from the MelisKey, if needed */ $melisKeys = $melisAppConfig->getMelisKeys(); if (!empty($melisKeys[$appconfigpath])) { $appconfigpath = $melisKeys[$appconfigpath]; } $appsConfig = $melisAppConfig->getItem($appconfigpath); if ($isXmlHttpRequest && !empty($appsConfig['interface'])) { $appsConfig['interface'] = $this->orderInterfaceChildren($keyView, $appsConfig['interface']); } list($jsCallBacks, $datasCallback) = $melisAppConfig->getJsCallbacksDatas($appsConfig); /** * Generate the views recursively * and add the corresponding appConfig part to make it accessible in the view */ $zoneView = $this->generateRec($keyView, $appconfigpath, $datasParameters); $zoneView->setVariable('zoneconfig', $appsConfig); $zoneView->setVariable('parameters', $datasParameters); $zoneView->setVariable('keyInterface', $keyView); /** * Add JS calls and datas found in config, * so that it will be added in head when generating */ if (!empty($zoneView->getVariable('jsCallBacks')) && is_array($zoneView->getVariable('jsCallBacks'))) { $jsCallBacks = ArrayUtils::merge($zoneView->getVariable('jsCallBacks'), $jsCallBacks); } $zoneView->setVariable('jsCallBacks', $jsCallBacks); if (!empty($zoneView->getVariable('datasCallback')) && is_array($zoneView->getVariable('datasCallback'))) { $datasCallback = ArrayUtils::merge($zoneView->getVariable('datasCallback'), $datasCallback); } $zoneView->setVariable('datasCallback', $datasCallback); /** * If ajax, return json * else, return the normal view */ if ($isXmlHttpRequest) { $htmlZoneView = $this->renderViewRec($zoneView); $jsonModel = new JsonModel(); $jsonModel->setVariables([ 'html' => $htmlZoneView, 'jsCallbacks' => $jsCallBacks, 'jsDatas' => $datasCallback, ]); return $jsonModel; } else { /** * Return view */ return $zoneView; } }
php
public function generateAction() { /** * Determine if it comes from an ajax call * so we can send back different datas with the html */ $isXmlHttpRequest = false; if ($this->getRequest()->isXmlHttpRequest()) { $isXmlHttpRequest = true; } /** * Get the params from php call */ $appconfigpath = $this->params()->fromRoute('appconfigpath', '/'); $keyView = $this->params()->fromRoute('keyview', 'melis'); /** * Else get the params from GET if ajax */ $datasParameters = []; if ($isXmlHttpRequest) { $appconfigpath = $this->getRequest()->getQuery('cpath'); $lastKey = explode('/', $appconfigpath); $keyView = $lastKey[count($lastKey) - 1]; } /** * Forcing to set the request to http request */ if ($this->getRequest()->getQuery('forceFlagXmlHttpRequestTofalse', false)) $isXmlHttpRequest = false; /** * Get the appConfig */ $melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig'); /** * Get the real path, from the MelisKey, if needed */ $melisKeys = $melisAppConfig->getMelisKeys(); if (!empty($melisKeys[$appconfigpath])) { $appconfigpath = $melisKeys[$appconfigpath]; } $appsConfig = $melisAppConfig->getItem($appconfigpath); if ($isXmlHttpRequest && !empty($appsConfig['interface'])) { $appsConfig['interface'] = $this->orderInterfaceChildren($keyView, $appsConfig['interface']); } list($jsCallBacks, $datasCallback) = $melisAppConfig->getJsCallbacksDatas($appsConfig); /** * Generate the views recursively * and add the corresponding appConfig part to make it accessible in the view */ $zoneView = $this->generateRec($keyView, $appconfigpath, $datasParameters); $zoneView->setVariable('zoneconfig', $appsConfig); $zoneView->setVariable('parameters', $datasParameters); $zoneView->setVariable('keyInterface', $keyView); /** * Add JS calls and datas found in config, * so that it will be added in head when generating */ if (!empty($zoneView->getVariable('jsCallBacks')) && is_array($zoneView->getVariable('jsCallBacks'))) { $jsCallBacks = ArrayUtils::merge($zoneView->getVariable('jsCallBacks'), $jsCallBacks); } $zoneView->setVariable('jsCallBacks', $jsCallBacks); if (!empty($zoneView->getVariable('datasCallback')) && is_array($zoneView->getVariable('datasCallback'))) { $datasCallback = ArrayUtils::merge($zoneView->getVariable('datasCallback'), $datasCallback); } $zoneView->setVariable('datasCallback', $datasCallback); /** * If ajax, return json * else, return the normal view */ if ($isXmlHttpRequest) { $htmlZoneView = $this->renderViewRec($zoneView); $jsonModel = new JsonModel(); $jsonModel->setVariables([ 'html' => $htmlZoneView, 'jsCallbacks' => $jsCallBacks, 'jsDatas' => $datasCallback, ]); return $jsonModel; } else { /** * Return view */ return $zoneView; } }
[ "public", "function", "generateAction", "(", ")", "{", "/**\n * Determine if it comes from an ajax call\n * so we can send back different datas with the html\n */", "$", "isXmlHttpRequest", "=", "false", ";", "if", "(", "$", "this", "->", "getRequest", "("...
Generate a view of the appConfig and returns it @routeParam appconfigpath Path in the appConfig file (ex: /meliscore/interface/meliscore_header) @routeParam keyview Name of the child view for further rendering @return \Zend\View\Model\ViewModel
[ "Generate", "a", "view", "of", "the", "appConfig", "and", "returns", "it" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PluginViewController.php#L65-L167
train
melisplatform/melis-core
src/Controller/PluginViewController.php
PluginViewController.orderInterfaceChildren
public function orderInterfaceChildren($parentKey, $childrenInterface) { $melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $orderInterface = $melisAppConfig->getOrderInterfaceConfig($parentKey); if (empty($orderInterface)) { // No order defined, items are displayed directly like found in interface config // meaning order is made uppon config merge return $childrenInterface; } else { $resultOrdered = []; // We first reorder depending on order defined foreach ($orderInterface as $orderKey) { if (is_array($orderKey)) { $resultOrdered = $orderInterface; break; } if (!empty($childrenInterface[$orderKey])) { $resultOrdered[$orderKey] = $childrenInterface[$orderKey]; unset($childrenInterface[$orderKey]); } } // We add items at the end that are in the config but not present in the custom order foreach ($childrenInterface as $keyInterface => $childinterface) { $resultOrdered[$keyInterface] = $childinterface; } return $resultOrdered; } }
php
public function orderInterfaceChildren($parentKey, $childrenInterface) { $melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $orderInterface = $melisAppConfig->getOrderInterfaceConfig($parentKey); if (empty($orderInterface)) { // No order defined, items are displayed directly like found in interface config // meaning order is made uppon config merge return $childrenInterface; } else { $resultOrdered = []; // We first reorder depending on order defined foreach ($orderInterface as $orderKey) { if (is_array($orderKey)) { $resultOrdered = $orderInterface; break; } if (!empty($childrenInterface[$orderKey])) { $resultOrdered[$orderKey] = $childrenInterface[$orderKey]; unset($childrenInterface[$orderKey]); } } // We add items at the end that are in the config but not present in the custom order foreach ($childrenInterface as $keyInterface => $childinterface) { $resultOrdered[$keyInterface] = $childinterface; } return $resultOrdered; } }
[ "public", "function", "orderInterfaceChildren", "(", "$", "parentKey", ",", "$", "childrenInterface", ")", "{", "$", "melisAppConfig", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreConfig'", ")", ";", "$", "orderInterface", ...
This function takes the list of children and reorders them by comparing the order list available in MelisModuleConfig. @param string $parentKey @param array $childrenInterface @return array
[ "This", "function", "takes", "the", "list", "of", "children", "and", "reorders", "them", "by", "comparing", "the", "order", "list", "available", "in", "MelisModuleConfig", "." ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PluginViewController.php#L178-L210
train
melisplatform/melis-core
src/Service/MelisCoreGdprService.php
MelisCoreGdprService.extractSelected
public function extractSelected($idsToBeExtractedArray = []) { //created selected index $arrayParameters['selected'] = $idsToBeExtractedArray; // Sending service start event $arrayParameters = $this->sendEvent('melis_core_gdpr_user_extract_event', $arrayParameters); $xml = ''; if (isset($arrayParameters['results']) && count($arrayParameters['results']) > 0) { // Generate and structure the xml $xmlDoc = new \DOMDocument('1.0', 'UTF-8'); $xmlDoc->formatOutput = true; $root = $xmlDoc->appendChild($xmlDoc->createElement("xml")); $doc = new \DOMDocument(); $doc->formatOutput = true; foreach ($arrayParameters['results'] as $key => $value) { $doc->loadXML($value); //remove root element xml so that we won't have multiple xml elements on the final output $module = $doc->documentElement->getElementsByTagName('*')->item(0); $doc->replaceChild($module, $doc->documentElement); $xml = $doc->saveXML($doc->documentElement); //append each modules xml to one final xml $fragment = $xmlDoc->createDocumentFragment(); $fragment->appendXML($xml); $xmlDoc->documentElement->appendChild($fragment); } $xml = $xmlDoc->saveXML(); } // Sending service end event //$arrayParameters = $this->sendEvent('melis_core_gdpr_user_extract_event_end', $xml); return $xml; }
php
public function extractSelected($idsToBeExtractedArray = []) { //created selected index $arrayParameters['selected'] = $idsToBeExtractedArray; // Sending service start event $arrayParameters = $this->sendEvent('melis_core_gdpr_user_extract_event', $arrayParameters); $xml = ''; if (isset($arrayParameters['results']) && count($arrayParameters['results']) > 0) { // Generate and structure the xml $xmlDoc = new \DOMDocument('1.0', 'UTF-8'); $xmlDoc->formatOutput = true; $root = $xmlDoc->appendChild($xmlDoc->createElement("xml")); $doc = new \DOMDocument(); $doc->formatOutput = true; foreach ($arrayParameters['results'] as $key => $value) { $doc->loadXML($value); //remove root element xml so that we won't have multiple xml elements on the final output $module = $doc->documentElement->getElementsByTagName('*')->item(0); $doc->replaceChild($module, $doc->documentElement); $xml = $doc->saveXML($doc->documentElement); //append each modules xml to one final xml $fragment = $xmlDoc->createDocumentFragment(); $fragment->appendXML($xml); $xmlDoc->documentElement->appendChild($fragment); } $xml = $xmlDoc->saveXML(); } // Sending service end event //$arrayParameters = $this->sendEvent('melis_core_gdpr_user_extract_event_end', $xml); return $xml; }
[ "public", "function", "extractSelected", "(", "$", "idsToBeExtractedArray", "=", "[", "]", ")", "{", "//created selected index", "$", "arrayParameters", "[", "'selected'", "]", "=", "$", "idsToBeExtractedArray", ";", "// Sending service start event", "$", "arrayParamete...
This function will Retrieve xml string of user's info based on the ids passed and Returns a xml string containing all modules that matched the ids passed This event will take in the IDs of the selected items on the table as the parameters so please follow this structure. Parameter for the event value structure: array( 'selected' => array( 'MelisCmsProspects' => array(13,15), 'MelisCmsNewsletter' => 'array(2), ), ) The modules that will catch the event will then provide their own results using this structure. Return value structure: array( 'selected' => array( 'MelisCmsProspects' => '<xml><MelisCmsProspects>...</MelisCmsProspects></xml>', 'MelisCmsNewsletter' => '<xml><MelisCmsNewsletter>...</MelisCmsNewsletter></xml>', ), ) @param (array) $arrayParameters @return (string) xml string
[ "This", "function", "will", "Retrieve", "xml", "string", "of", "user", "s", "info", "based", "on", "the", "ids", "passed", "and", "Returns", "a", "xml", "string", "containing", "all", "modules", "that", "matched", "the", "ids", "passed" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreGdprService.php#L127-L167
train
melisplatform/melis-core
src/Service/MelisCoreGdprService.php
MelisCoreGdprService.deleteSelected
public function deleteSelected($idsToBeDeletedArray = []) { // Create selected index for the array $arrayParameters['selected'] = $idsToBeDeletedArray; // Sending service start event $arrayParameters = $this->sendEvent('melis_core_gdpr_user_delete_event', $arrayParameters); // Sending service end event $arrayParameters = $this->sendEvent('melis_core_gdpr_user_delete_event_end', $arrayParameters); return $arrayParameters; }
php
public function deleteSelected($idsToBeDeletedArray = []) { // Create selected index for the array $arrayParameters['selected'] = $idsToBeDeletedArray; // Sending service start event $arrayParameters = $this->sendEvent('melis_core_gdpr_user_delete_event', $arrayParameters); // Sending service end event $arrayParameters = $this->sendEvent('melis_core_gdpr_user_delete_event_end', $arrayParameters); return $arrayParameters; }
[ "public", "function", "deleteSelected", "(", "$", "idsToBeDeletedArray", "=", "[", "]", ")", "{", "// Create selected index for the array", "$", "arrayParameters", "[", "'selected'", "]", "=", "$", "idsToBeDeletedArray", ";", "// Sending service start event", "$", "arra...
This function will delete all ids passed and This event will take in the IDs of the selected items on the table as the parameters so please follow this structure. Parameter for the event value structure: array( 'selected' => array( 'MelisCmsProspects' => array(13,15), 'MelisCmsNewsletter' => 'array(2), ), ) * The modules that will catch the event will then return an acknowledgement message if the items are succesfully deleted. Return value structure: array( 'results' => array( 'MelisCmsProspects' => true, 'MelisCmsNewsletter' => true, ), ) @param $arrayParameters @return array
[ "This", "function", "will", "delete", "all", "ids", "passed", "and" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreGdprService.php#L195-L207
train
melisplatform/melis-core
src/Controller/MelisAuthController.php
MelisAuthController.loginAction
public function loginAction() { $isChecked = false; $pathAppConfigForm = '/meliscore/forms/meliscore_login'; $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm); $factory = new \Zend\Form\Factory(); $loginForm = $factory->createForm($appConfigForm); $loginDataConfig = $melisMelisCoreConfig->getItem('meliscore_login/datas'); // change to layout login $isRemembered = !empty($_COOKIE['remember']) ? (int) $_COOKIE['remember'] : 0; $user = ''; $pass = ''; if ($isRemembered == 1) { $user = $this->crypt($_COOKIE['cookie1'], 'decrypt'); $loginForm->get('usr_login')->setValue($user); $loginForm->get('usr_password')->setValue($pass); $isChecked = true; } $view = new ViewModel(); $view->setVariable('meliscore_login', $loginForm); $view->setVariable('login_logo', $loginDataConfig['login_logo']); $view->isChecked = $isChecked; return $view; }
php
public function loginAction() { $isChecked = false; $pathAppConfigForm = '/meliscore/forms/meliscore_login'; $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm); $factory = new \Zend\Form\Factory(); $loginForm = $factory->createForm($appConfigForm); $loginDataConfig = $melisMelisCoreConfig->getItem('meliscore_login/datas'); // change to layout login $isRemembered = !empty($_COOKIE['remember']) ? (int) $_COOKIE['remember'] : 0; $user = ''; $pass = ''; if ($isRemembered == 1) { $user = $this->crypt($_COOKIE['cookie1'], 'decrypt'); $loginForm->get('usr_login')->setValue($user); $loginForm->get('usr_password')->setValue($pass); $isChecked = true; } $view = new ViewModel(); $view->setVariable('meliscore_login', $loginForm); $view->setVariable('login_logo', $loginDataConfig['login_logo']); $view->isChecked = $isChecked; return $view; }
[ "public", "function", "loginAction", "(", ")", "{", "$", "isChecked", "=", "false", ";", "$", "pathAppConfigForm", "=", "'/meliscore/forms/meliscore_login'", ";", "$", "melisMelisCoreConfig", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "'MelisCoreC...
Shows login form @return \Zend\View\Model\ViewModel
[ "Shows", "login", "form" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisAuthController.php#L69-L99
train
melisplatform/melis-core
src/Controller/MelisAuthController.php
MelisAuthController.crypt
protected function crypt($data, $type = 'encrypt') { $melisConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $datas = $melisConfig->getItemPerPlatform('meliscore/datas'); $hashMethod = $datas['accounts']['hash_method']; $salt = $datas['accounts']['salt']; if ($type == 'encrypt') { return base64_encode($data); } if ($type == 'decrypt') { return base64_decode($data); } return; }
php
protected function crypt($data, $type = 'encrypt') { $melisConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $datas = $melisConfig->getItemPerPlatform('meliscore/datas'); $hashMethod = $datas['accounts']['hash_method']; $salt = $datas['accounts']['salt']; if ($type == 'encrypt') { return base64_encode($data); } if ($type == 'decrypt') { return base64_decode($data); } return; }
[ "protected", "function", "crypt", "(", "$", "data", ",", "$", "type", "=", "'encrypt'", ")", "{", "$", "melisConfig", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreConfig'", ")", ";", "$", "datas", "=", "$", "melis...
Encryption of passwords for melis @param array $data @param string $type @return string
[ "Encryption", "of", "passwords", "for", "melis" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisAuthController.php#L109-L126
train
melisplatform/melis-core
src/Controller/MelisAuthController.php
MelisAuthController.rememberMe
protected function rememberMe($username, $password) { $melisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $authCookieConfig = $melisCoreConfig->getItem('meliscore/datas/default/auth_cookies'); $remember = $authCookieConfig['remember']; $user = new SetCookie('cookie1', $this->crypt($username), strtotime($remember)); $pass = new SetCookie('cookie2', $this->crypt($password), strtotime($remember)); $remember = new SetCookie('remember', 1, strtotime($remember)); $this->getResponse()->getHeaders()->addHeader($user); $this->getResponse()->getHeaders()->addHeader($pass); $this->getResponse()->getHeaders()->addHeader($remember); // add code here for the session $melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $autoLogoutTimeConf = $melisCoreConfig->getItem('meliscore/datas/default/auto_logout'); $autoLogoutTime = (int) $autoLogoutTimeConf['after']; // automatic logout $sessionManager = new SessionManager(); $sessionManager->rememberMe($autoLogoutTime); Container::setDefaultManager($sessionManager); }
php
protected function rememberMe($username, $password) { $melisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $authCookieConfig = $melisCoreConfig->getItem('meliscore/datas/default/auth_cookies'); $remember = $authCookieConfig['remember']; $user = new SetCookie('cookie1', $this->crypt($username), strtotime($remember)); $pass = new SetCookie('cookie2', $this->crypt($password), strtotime($remember)); $remember = new SetCookie('remember', 1, strtotime($remember)); $this->getResponse()->getHeaders()->addHeader($user); $this->getResponse()->getHeaders()->addHeader($pass); $this->getResponse()->getHeaders()->addHeader($remember); // add code here for the session $melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $autoLogoutTimeConf = $melisCoreConfig->getItem('meliscore/datas/default/auto_logout'); $autoLogoutTime = (int) $autoLogoutTimeConf['after']; // automatic logout $sessionManager = new SessionManager(); $sessionManager->rememberMe($autoLogoutTime); Container::setDefaultManager($sessionManager); }
[ "protected", "function", "rememberMe", "(", "$", "username", ",", "$", "password", ")", "{", "$", "melisCoreConfig", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "'MelisCoreConfig'", ")", ";", "$", "authCookieConfig", "=", "$", "melisCoreConfig"...
Remember me function creation cookie @param string $username @param string $password
[ "Remember", "me", "function", "creation", "cookie" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisAuthController.php#L358-L381
train
melisplatform/melis-core
src/Controller/MelisAuthController.php
MelisAuthController.forgetMe
protected function forgetMe($username, $password) { $melisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $authCookieConfig = $melisCoreConfig->getItem('meliscore/datas/default/auth_cookies'); $expire = $authCookieConfig['expire']; $user = new SetCookie('cookie1', $this->crypt($username), strtotime($expire, time())); $remember = new SetCookie('remember', 0, strtotime($expire, time())); $this->getResponse()->getHeaders()->addHeader($user); $this->getResponse()->getHeaders()->addHeader($remember); // add code here to remove session $sessionManager = new SessionManager(); $sessionManager->forgetMe(); Container::setDefaultManager($sessionManager); }
php
protected function forgetMe($username, $password) { $melisCoreConfig = $this->serviceLocator->get('MelisCoreConfig'); $authCookieConfig = $melisCoreConfig->getItem('meliscore/datas/default/auth_cookies'); $expire = $authCookieConfig['expire']; $user = new SetCookie('cookie1', $this->crypt($username), strtotime($expire, time())); $remember = new SetCookie('remember', 0, strtotime($expire, time())); $this->getResponse()->getHeaders()->addHeader($user); $this->getResponse()->getHeaders()->addHeader($remember); // add code here to remove session $sessionManager = new SessionManager(); $sessionManager->forgetMe(); Container::setDefaultManager($sessionManager); }
[ "protected", "function", "forgetMe", "(", "$", "username", ",", "$", "password", ")", "{", "$", "melisCoreConfig", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "'MelisCoreConfig'", ")", ";", "$", "authCookieConfig", "=", "$", "melisCoreConfig", ...
Forget me function @param string $username @param string $password
[ "Forget", "me", "function" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisAuthController.php#L389-L406
train
melisplatform/melis-core
src/Controller/MelisAuthController.php
MelisAuthController.headerLogoutAction
public function headerLogoutAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
php
public function headerLogoutAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
[ "public", "function", "headerLogoutAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", "view", "->",...
Shows logout button in header @return \Zend\View\Model\ViewModel
[ "Shows", "logout", "button", "in", "header" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisAuthController.php#L413-L421
train
melisplatform/melis-core
src/Controller/MelisAuthController.php
MelisAuthController.identityMenuAction
public function identityMenuAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth'); $userAuthDatas = $melisCoreAuth->getStorage()->read(); $view = new ViewModel(); $view->melisKey = $melisKey; $view->setVariable('userAuthDatas', $userAuthDatas); return $view; }
php
public function identityMenuAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth'); $userAuthDatas = $melisCoreAuth->getStorage()->read(); $view = new ViewModel(); $view->melisKey = $melisKey; $view->setVariable('userAuthDatas', $userAuthDatas); return $view; }
[ "public", "function", "identityMenuAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "melisCoreAuth", "=", "$", "this", "->", "serviceLocator", "->", "get"...
Shows identity zone in the left menu @return \Zend\View\Model\ViewModel
[ "Shows", "identity", "zone", "in", "the", "left", "menu" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisAuthController.php#L428-L441
train
melisplatform/melis-core
src/Controller/MelisAuthController.php
MelisAuthController.getProfilePictureAction
public function getProfilePictureAction() { $melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth'); $moduleSvc = $this->getServiceLocator()->get('ModulesService'); $user = $melisCoreAuth->getIdentity(); $imageDefault = $moduleSvc->getModulePath('MelisCore') . '/public/images/profile/default_picture.jpg'; if (!empty($user) && !empty($user->usr_image)) { $image = $user->usr_image; } else { $image = file_get_contents($imageDefault); } $response = $this->getResponse(); $response->setContent($image); $response->getHeaders() ->addHeaderLine('Content-Transfer-Encoding', 'binary') ->addHeaderLine('Content-Type', 'image/jpg'); return $response; }
php
public function getProfilePictureAction() { $melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth'); $moduleSvc = $this->getServiceLocator()->get('ModulesService'); $user = $melisCoreAuth->getIdentity(); $imageDefault = $moduleSvc->getModulePath('MelisCore') . '/public/images/profile/default_picture.jpg'; if (!empty($user) && !empty($user->usr_image)) { $image = $user->usr_image; } else { $image = file_get_contents($imageDefault); } $response = $this->getResponse(); $response->setContent($image); $response->getHeaders() ->addHeaderLine('Content-Transfer-Encoding', 'binary') ->addHeaderLine('Content-Type', 'image/jpg'); return $response; }
[ "public", "function", "getProfilePictureAction", "(", ")", "{", "$", "melisCoreAuth", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "'MelisCoreAuth'", ")", ";", "$", "moduleSvc", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get...
Get the profile picture @return \Zend\Stdlib\ResponseInterface
[ "Get", "the", "profile", "picture" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisAuthController.php#L488-L509
train
locomotivemtl/charcoal-app
src/Charcoal/App/Middleware/IpMiddleware.php
IpMiddleware.isIpBlacklisted
private function isIpBlacklisted($ip) { if (empty($this->blacklist)) { return false; } return $this->isIpInRange($ip, $this->blacklist); }
php
private function isIpBlacklisted($ip) { if (empty($this->blacklist)) { return false; } return $this->isIpInRange($ip, $this->blacklist); }
[ "private", "function", "isIpBlacklisted", "(", "$", "ip", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "blacklist", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "isIpInRange", "(", "$", "ip", ",", "$", "this", "...
Check wether a certain IP is explicitely blacklisted. If the blacklist is null or empty, then nothing is ever blacklisted (return false). Note: this method only performs an exact string match on IP address, no IP masking / range features. @param string $ip The IP address to check against the blacklist. @return boolean
[ "Check", "wether", "a", "certain", "IP", "is", "explicitely", "blacklisted", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Middleware/IpMiddleware.php#L137-L143
train
locomotivemtl/charcoal-app
src/Charcoal/App/Middleware/IpMiddleware.php
IpMiddleware.isIpWhitelisted
private function isIpWhitelisted($ip) { if (empty($this->whitelist)) { return true; } return $this->isIpInRange($ip, $this->whitelist); }
php
private function isIpWhitelisted($ip) { if (empty($this->whitelist)) { return true; } return $this->isIpInRange($ip, $this->whitelist); }
[ "private", "function", "isIpWhitelisted", "(", "$", "ip", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "whitelist", ")", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "isIpInRange", "(", "$", "ip", ",", "$", "this", "-...
Check wether a certain IP is explicitely whitelisted. If the whitelist is null or empty, then all IPs are whitelisted (return true). Note; This method only performs an exact string match on IP address, no IP masking / range features. @param string $ip The IP address to check against the whitelist. @return boolean
[ "Check", "wether", "a", "certain", "IP", "is", "explicitely", "whitelisted", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Middleware/IpMiddleware.php#L155-L161
train
locomotivemtl/charcoal-app
src/Charcoal/App/Module/AbstractModule.php
AbstractModule.config
public function config($key = null) { if ($this->config === null) { throw new InvalidArgumentException( 'Configuration not set.' ); } if ($key !== null) { return $this->config->get($key); } else { return $this->config; } }
php
public function config($key = null) { if ($this->config === null) { throw new InvalidArgumentException( 'Configuration not set.' ); } if ($key !== null) { return $this->config->get($key); } else { return $this->config; } }
[ "public", "function", "config", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "this", "->", "config", "===", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Configuration not set.'", ")", ";", "}", "if", "(", "$", "key", ...
Retrieve the module's configuration container, or one of its entry. If a key is provided, return the configuration key value instead of the full object. @param string $key Optional. If provided, the config key value will be returned, instead of the full object. @throws InvalidArgumentException If a config has not been defined. @return \Charcoal\Config\ConfigInterface|mixed
[ "Retrieve", "the", "module", "s", "configuration", "container", "or", "one", "of", "its", "entry", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Module/AbstractModule.php#L77-L90
train
locomotivemtl/charcoal-app
src/Charcoal/App/Module/AbstractModule.php
AbstractModule.setupRoutes
public function setupRoutes() { if (!isset($this->routeManager)) { $config = $this->config(); $routes = (isset($config['routes']) ? $config['routes'] : [] ); $this->routeManager = new RouteManager([ 'config' => $routes, 'app' => $this->app(), 'logger' => $this->logger ]); $this->routeManager->setupRoutes(); } return $this; }
php
public function setupRoutes() { if (!isset($this->routeManager)) { $config = $this->config(); $routes = (isset($config['routes']) ? $config['routes'] : [] ); $this->routeManager = new RouteManager([ 'config' => $routes, 'app' => $this->app(), 'logger' => $this->logger ]); $this->routeManager->setupRoutes(); } return $this; }
[ "public", "function", "setupRoutes", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "routeManager", ")", ")", "{", "$", "config", "=", "$", "this", "->", "config", "(", ")", ";", "$", "routes", "=", "(", "isset", "(", "$", "confi...
Set up the module's routes, via a RouteManager @return self
[ "Set", "up", "the", "module", "s", "routes", "via", "a", "RouteManager" ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Module/AbstractModule.php#L109-L125
train
locomotivemtl/charcoal-app
src/Charcoal/App/Route/TemplateRouteConfig.php
TemplateRouteConfig.setTemplateData
public function setTemplateData(array $templateData) { if (!isset($this->templateData)) { $this->templateData = []; } $this->templateData = array_merge($this->templateData, $templateData); return $this; }
php
public function setTemplateData(array $templateData) { if (!isset($this->templateData)) { $this->templateData = []; } $this->templateData = array_merge($this->templateData, $templateData); return $this; }
[ "public", "function", "setTemplateData", "(", "array", "$", "templateData", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "templateData", ")", ")", "{", "$", "this", "->", "templateData", "=", "[", "]", ";", "}", "$", "this", "->", "temp...
Set the template data for the view. @param array $templateData The route template data. @return TemplateRouteConfig Chainable
[ "Set", "the", "template", "data", "for", "the", "view", "." ]
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/TemplateRouteConfig.php#L161-L170
train
Magicalex/WriteiniFile
src/WriteiniFile.php
WriteiniFile.rm
public function rm(array $rm_value) { $this->data_ini_file = self::arrayDiffRecursive($this->data_ini_file, $rm_value); return $this; }
php
public function rm(array $rm_value) { $this->data_ini_file = self::arrayDiffRecursive($this->data_ini_file, $rm_value); return $this; }
[ "public", "function", "rm", "(", "array", "$", "rm_value", ")", "{", "$", "this", "->", "data_ini_file", "=", "self", "::", "arrayDiffRecursive", "(", "$", "this", "->", "data_ini_file", ",", "$", "rm_value", ")", ";", "return", "$", "this", ";", "}" ]
method for remove some values in the ini file. @param array $rm_value @return $this
[ "method", "for", "remove", "some", "values", "in", "the", "ini", "file", "." ]
19fe9bd3041219fecdd63e1f0ae14f86cb6800cb
https://github.com/Magicalex/WriteiniFile/blob/19fe9bd3041219fecdd63e1f0ae14f86cb6800cb/src/WriteiniFile.php#L102-L107
train
Magicalex/WriteiniFile
src/WriteiniFile.php
WriteiniFile.write
public function write() { $file_content = null; foreach ($this->data_ini_file as $key_1 => $groupe) { $file_content .= PHP_EOL.'['.$key_1.']'.PHP_EOL; foreach ($groupe as $key_2 => $value_2) { if (is_array($value_2)) { foreach ($value_2 as $key_3 => $value_3) { $file_content .= $key_2.'['.$key_3.']='.self::encode($value_3).PHP_EOL; } } else { $file_content .= $key_2.'='.self::encode($value_2).PHP_EOL; } } } $file_content = preg_replace('#^'.PHP_EOL.'#', '', $file_content); $result = @file_put_contents($this->path_to_ini_file, $file_content); if (false === $result) { throw new \Exception(sprintf('Unable to write in the file ini: %s', $this->path_to_ini_file)); } return ($result !== false) ? true : false; }
php
public function write() { $file_content = null; foreach ($this->data_ini_file as $key_1 => $groupe) { $file_content .= PHP_EOL.'['.$key_1.']'.PHP_EOL; foreach ($groupe as $key_2 => $value_2) { if (is_array($value_2)) { foreach ($value_2 as $key_3 => $value_3) { $file_content .= $key_2.'['.$key_3.']='.self::encode($value_3).PHP_EOL; } } else { $file_content .= $key_2.'='.self::encode($value_2).PHP_EOL; } } } $file_content = preg_replace('#^'.PHP_EOL.'#', '', $file_content); $result = @file_put_contents($this->path_to_ini_file, $file_content); if (false === $result) { throw new \Exception(sprintf('Unable to write in the file ini: %s', $this->path_to_ini_file)); } return ($result !== false) ? true : false; }
[ "public", "function", "write", "(", ")", "{", "$", "file_content", "=", "null", ";", "foreach", "(", "$", "this", "->", "data_ini_file", "as", "$", "key_1", "=>", "$", "groupe", ")", "{", "$", "file_content", ".=", "PHP_EOL", ".", "'['", ".", "$", "k...
method for write data in the ini file. @return bool
[ "method", "for", "write", "data", "in", "the", "ini", "file", "." ]
19fe9bd3041219fecdd63e1f0ae14f86cb6800cb
https://github.com/Magicalex/WriteiniFile/blob/19fe9bd3041219fecdd63e1f0ae14f86cb6800cb/src/WriteiniFile.php#L114-L138
train
UseMuffin/Tokenize
src/Model/Entity/Token.php
Token.random
public static function random($length = null) { if ($length === null) { $length = Configure::read('Muffin/Tokenize.length', self::DEFAULT_LENGTH); } return bin2hex(Security::randomBytes($length / 2)); }
php
public static function random($length = null) { if ($length === null) { $length = Configure::read('Muffin/Tokenize.length', self::DEFAULT_LENGTH); } return bin2hex(Security::randomBytes($length / 2)); }
[ "public", "static", "function", "random", "(", "$", "length", "=", "null", ")", "{", "if", "(", "$", "length", "===", "null", ")", "{", "$", "length", "=", "Configure", "::", "read", "(", "'Muffin/Tokenize.length'", ",", "self", "::", "DEFAULT_LENGTH", "...
Creates a secure random token. @param int|null $length Token length @return string @see http://stackoverflow.com/a/29137661/2020428
[ "Creates", "a", "secure", "random", "token", "." ]
a7ecf4114782abe12b0ab36e8a32504428fe91ec
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Entity/Token.php#L49-L56
train
flash-global/api-client
src/AbstractApiClient.php
AbstractApiClient.getAppropriateTransport
protected function getAppropriateTransport($flags) { if ($flags & ApiRequestOption::NO_RESPONSE) { $transport = $this->getAsyncTransport(); if (is_null($transport)) { $transport = $this->getTransport(); } else { $fallback = $this->getTransport(); if ($fallback) { $this->setFallbackTransport($fallback); } } } else { $transport = $this->getTransport(); } return $transport; }
php
protected function getAppropriateTransport($flags) { if ($flags & ApiRequestOption::NO_RESPONSE) { $transport = $this->getAsyncTransport(); if (is_null($transport)) { $transport = $this->getTransport(); } else { $fallback = $this->getTransport(); if ($fallback) { $this->setFallbackTransport($fallback); } } } else { $transport = $this->getTransport(); } return $transport; }
[ "protected", "function", "getAppropriateTransport", "(", "$", "flags", ")", "{", "if", "(", "$", "flags", "&", "ApiRequestOption", "::", "NO_RESPONSE", ")", "{", "$", "transport", "=", "$", "this", "->", "getAsyncTransport", "(", ")", ";", "if", "(", "is_n...
Returns the most appropriate transport according to request flags @param $flags @return AsyncTransportInterface|TransportInterface
[ "Returns", "the", "most", "appropriate", "transport", "according", "to", "request", "flags" ]
5e54dea5c37ef7b5736d46f9997ea6c245c4949f
https://github.com/flash-global/api-client/blob/5e54dea5c37ef7b5736d46f9997ea6c245c4949f/src/AbstractApiClient.php#L380-L397
train
flash-global/api-client
src/ApiClientException.php
ApiClientException.getRequestException
public function getRequestException() { if (!is_null($this->requestException)) { return $this->requestException; } $search = function (\Exception $exception = null) use (&$search) { $previous = $exception->getPrevious(); if (is_null($previous)) { return null; } if ($previous instanceof RequestException) { return $this->requestException = $previous; } return $search($previous); }; return $search($this); }
php
public function getRequestException() { if (!is_null($this->requestException)) { return $this->requestException; } $search = function (\Exception $exception = null) use (&$search) { $previous = $exception->getPrevious(); if (is_null($previous)) { return null; } if ($previous instanceof RequestException) { return $this->requestException = $previous; } return $search($previous); }; return $search($this); }
[ "public", "function", "getRequestException", "(", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "requestException", ")", ")", "{", "return", "$", "this", "->", "requestException", ";", "}", "$", "search", "=", "function", "(", "\\", "Excep...
Return the response body of the exception @return null|RequestException
[ "Return", "the", "response", "body", "of", "the", "exception" ]
5e54dea5c37ef7b5736d46f9997ea6c245c4949f
https://github.com/flash-global/api-client/blob/5e54dea5c37ef7b5736d46f9997ea6c245c4949f/src/ApiClientException.php#L23-L44
train
n2n/n2n
src/app/n2n/core/err/ThrowableInfoFactory.php
ThrowableInfoFactory.findCallPos
public static function findCallPos(\Throwable $t, string &$filePath = null, int &$lineNo = null) { if (!($t instanceof \TypeError || $t instanceof WarningError || $t instanceof RecoverableError)) { return; } $message = $t->getMessage(); if (false !== strpos($message, '{closure}')) { return; } $fmatches = array(); $lmatches = array(); if (preg_match('/(?<=called in )[^ \(]+/', $message, $fmatches) && preg_match('/((?<=on line )|(?<=\())[0-9]+/', $message, $lmatches)) { $filePath = $fmatches[0]; $lineNo = $lmatches[0]; } $fmatches = array(); $lmatches = array(); if (preg_match('/(?<=passed in )[^ \(]+/', $message, $fmatches) && preg_match('/((?<=on line )|(?<=\())[0-9]+/', $message, $lmatches)) { $filePath = $fmatches[0]; $lineNo = $lmatches[0]; } }
php
public static function findCallPos(\Throwable $t, string &$filePath = null, int &$lineNo = null) { if (!($t instanceof \TypeError || $t instanceof WarningError || $t instanceof RecoverableError)) { return; } $message = $t->getMessage(); if (false !== strpos($message, '{closure}')) { return; } $fmatches = array(); $lmatches = array(); if (preg_match('/(?<=called in )[^ \(]+/', $message, $fmatches) && preg_match('/((?<=on line )|(?<=\())[0-9]+/', $message, $lmatches)) { $filePath = $fmatches[0]; $lineNo = $lmatches[0]; } $fmatches = array(); $lmatches = array(); if (preg_match('/(?<=passed in )[^ \(]+/', $message, $fmatches) && preg_match('/((?<=on line )|(?<=\())[0-9]+/', $message, $lmatches)) { $filePath = $fmatches[0]; $lineNo = $lmatches[0]; } }
[ "public", "static", "function", "findCallPos", "(", "\\", "Throwable", "$", "t", ",", "string", "&", "$", "filePath", "=", "null", ",", "int", "&", "$", "lineNo", "=", "null", ")", "{", "if", "(", "!", "(", "$", "t", "instanceof", "\\", "TypeError", ...
Makes error infos more user friendly @param string $errmsg; @param string $filePath @param string $lineNo
[ "Makes", "error", "infos", "more", "user", "friendly" ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ThrowableInfoFactory.php#L73-L98
train
thebuggenie/b2db
src/Core.php
Core.initialize
public static function initialize($configuration = array(), $cache_object = null) { try { if (array_key_exists('dsn', $configuration) && $configuration['dsn']) self::setDSN($configuration['dsn']); if (array_key_exists('driver', $configuration) && $configuration['driver']) self::setDriver($configuration['driver']); if (array_key_exists('hostname', $configuration) && $configuration['hostname']) self::setHostname($configuration['hostname']); if (array_key_exists('port', $configuration) && $configuration['port']) self::setPort($configuration['port']); if (array_key_exists('username', $configuration) && $configuration['username']) self::setUsername($configuration['username']); if (array_key_exists('password', $configuration) && $configuration['password']) self::setPassword($configuration['password']); if (array_key_exists('database', $configuration) && $configuration['database']) self::setDatabaseName($configuration['database']); if (array_key_exists('tableprefix', $configuration) && $configuration['tableprefix']) self::setTablePrefix($configuration['tableprefix']); if (array_key_exists('debug', $configuration)) self::setDebugMode((bool) $configuration['debug']); if (array_key_exists('caching', $configuration)) self::setCacheEntities((bool) $configuration['caching']); if ($cache_object !== null) { if (is_callable($cache_object)) { self::$cache_object = call_user_func($cache_object); } else { self::$cache_object = $cache_object; } } if (!self::$cache_object) { self::$cache_object = new Cache(Cache::TYPE_DUMMY); self::$cache_object->disable(); } } catch (\Exception $e) { throw $e; } }
php
public static function initialize($configuration = array(), $cache_object = null) { try { if (array_key_exists('dsn', $configuration) && $configuration['dsn']) self::setDSN($configuration['dsn']); if (array_key_exists('driver', $configuration) && $configuration['driver']) self::setDriver($configuration['driver']); if (array_key_exists('hostname', $configuration) && $configuration['hostname']) self::setHostname($configuration['hostname']); if (array_key_exists('port', $configuration) && $configuration['port']) self::setPort($configuration['port']); if (array_key_exists('username', $configuration) && $configuration['username']) self::setUsername($configuration['username']); if (array_key_exists('password', $configuration) && $configuration['password']) self::setPassword($configuration['password']); if (array_key_exists('database', $configuration) && $configuration['database']) self::setDatabaseName($configuration['database']); if (array_key_exists('tableprefix', $configuration) && $configuration['tableprefix']) self::setTablePrefix($configuration['tableprefix']); if (array_key_exists('debug', $configuration)) self::setDebugMode((bool) $configuration['debug']); if (array_key_exists('caching', $configuration)) self::setCacheEntities((bool) $configuration['caching']); if ($cache_object !== null) { if (is_callable($cache_object)) { self::$cache_object = call_user_func($cache_object); } else { self::$cache_object = $cache_object; } } if (!self::$cache_object) { self::$cache_object = new Cache(Cache::TYPE_DUMMY); self::$cache_object->disable(); } } catch (\Exception $e) { throw $e; } }
[ "public", "static", "function", "initialize", "(", "$", "configuration", "=", "array", "(", ")", ",", "$", "cache_object", "=", "null", ")", "{", "try", "{", "if", "(", "array_key_exists", "(", "'dsn'", ",", "$", "configuration", ")", "&&", "$", "configu...
Initialize B2DB and load related B2DB classes @param array $configuration [optional] Configuration to load @param \b2db\interfaces\Cache $cache_object
[ "Initialize", "B2DB", "and", "load", "related", "B2DB", "classes" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L147-L186
train
thebuggenie/b2db
src/Core.php
Core.saveConnectionParameters
public static function saveConnectionParameters($bootstrap_location) { $string = "b2db:\n"; $string .= " driver: " . self::getDriver() . "\n"; $string .= " username: " . self::getUsername() . "\n"; $string .= " password: \"" . self::getPassword() . "\"\n"; $string .= ' dsn: "' . self::getDSN() . "\"\n"; $string .= " tableprefix: '" . self::getTablePrefix() . "'\n"; $string .= "\n"; try { if (file_put_contents($bootstrap_location, $string) === false) { throw new Exception('Could not save the database connection details'); } } catch (\Exception $e) { throw $e; } }
php
public static function saveConnectionParameters($bootstrap_location) { $string = "b2db:\n"; $string .= " driver: " . self::getDriver() . "\n"; $string .= " username: " . self::getUsername() . "\n"; $string .= " password: \"" . self::getPassword() . "\"\n"; $string .= ' dsn: "' . self::getDSN() . "\"\n"; $string .= " tableprefix: '" . self::getTablePrefix() . "'\n"; $string .= "\n"; try { if (file_put_contents($bootstrap_location, $string) === false) { throw new Exception('Could not save the database connection details'); } } catch (\Exception $e) { throw $e; } }
[ "public", "static", "function", "saveConnectionParameters", "(", "$", "bootstrap_location", ")", "{", "$", "string", "=", "\"b2db:\\n\"", ";", "$", "string", ".=", "\" driver: \"", ".", "self", "::", "getDriver", "(", ")", ".", "\"\\n\"", ";", "$", "string"...
Store connection parameters @param string $bootstrap_location Where to save the connection parameters
[ "Store", "connection", "parameters" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L203-L219
train
thebuggenie/b2db
src/Core.php
Core.getTable
public static function getTable($table_name) { if (!isset(self::$tables[$table_name])) { self::loadNewTable(new $table_name()); } if (!isset(self::$tables[$table_name])) { throw new Exception('Table ' . $table_name . ' is not loaded'); } return self::$tables[$table_name]; }
php
public static function getTable($table_name) { if (!isset(self::$tables[$table_name])) { self::loadNewTable(new $table_name()); } if (!isset(self::$tables[$table_name])) { throw new Exception('Table ' . $table_name . ' is not loaded'); } return self::$tables[$table_name]; }
[ "public", "static", "function", "getTable", "(", "$", "table_name", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "tables", "[", "$", "table_name", "]", ")", ")", "{", "self", "::", "loadNewTable", "(", "new", "$", "table_name", "(", ")"...
Returns the Table object @param string $table_name The table class name to load @return Table
[ "Returns", "the", "Table", "object" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L228-L237
train
thebuggenie/b2db
src/Core.php
Core.simpleQuery
public static function simpleQuery($sql) { self::$sql_hits++; try { $res = self::getDBLink()->query($sql); } catch (PDOException $e) { throw new Exception($e->getMessage()); } return $res; }
php
public static function simpleQuery($sql) { self::$sql_hits++; try { $res = self::getDBLink()->query($sql); } catch (PDOException $e) { throw new Exception($e->getMessage()); } return $res; }
[ "public", "static", "function", "simpleQuery", "(", "$", "sql", ")", "{", "self", "::", "$", "sql_hits", "++", ";", "try", "{", "$", "res", "=", "self", "::", "getDBLink", "(", ")", "->", "query", "(", "$", "sql", ")", ";", "}", "catch", "(", "PD...
returns a PDO resultset @param string $sql @return \PDOStatement
[ "returns", "a", "PDO", "resultset" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L373-L382
train
thebuggenie/b2db
src/Core.php
Core.setDSN
public static function setDSN($dsn) { $dsn_details = parse_url($dsn); if (!is_array($dsn_details) || !array_key_exists('scheme', $dsn_details)) { throw new Exception('This does not look like a valid DSN - cannot read the database type'); } try { self::setDriver($dsn_details['scheme']); $details = explode(';', $dsn_details['path']); foreach ($details as $detail) { $detail_info = explode('=', $detail); if (count($detail_info) != 2) { throw new Exception('This does not look like a valid DSN - cannot read the connection details'); } switch ($detail_info[0]) { case 'host': self::setHostname($detail_info[1]); break; case 'port': self::setPort($detail_info[1]); break; case 'dbname': self::setDatabaseName($detail_info[1]); break; } } } catch (\Exception $e) { throw $e; } self::$dsn = $dsn; }
php
public static function setDSN($dsn) { $dsn_details = parse_url($dsn); if (!is_array($dsn_details) || !array_key_exists('scheme', $dsn_details)) { throw new Exception('This does not look like a valid DSN - cannot read the database type'); } try { self::setDriver($dsn_details['scheme']); $details = explode(';', $dsn_details['path']); foreach ($details as $detail) { $detail_info = explode('=', $detail); if (count($detail_info) != 2) { throw new Exception('This does not look like a valid DSN - cannot read the connection details'); } switch ($detail_info[0]) { case 'host': self::setHostname($detail_info[1]); break; case 'port': self::setPort($detail_info[1]); break; case 'dbname': self::setDatabaseName($detail_info[1]); break; } } } catch (\Exception $e) { throw $e; } self::$dsn = $dsn; }
[ "public", "static", "function", "setDSN", "(", "$", "dsn", ")", "{", "$", "dsn_details", "=", "parse_url", "(", "$", "dsn", ")", ";", "if", "(", "!", "is_array", "(", "$", "dsn_details", ")", "||", "!", "array_key_exists", "(", "'scheme'", ",", "$", ...
Set the DSN @param string $dsn
[ "Set", "the", "DSN" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L389-L419
train
thebuggenie/b2db
src/Core.php
Core.generateDSN
protected static function generateDSN() { $dsn = self::getDriver() . ":host=" . self::getHostname(); if (self::getPort()) { $dsn .= ';port=' . self::getPort(); } $dsn .= ';dbname=' . self::getDatabaseName(); self::$dsn = $dsn; }
php
protected static function generateDSN() { $dsn = self::getDriver() . ":host=" . self::getHostname(); if (self::getPort()) { $dsn .= ';port=' . self::getPort(); } $dsn .= ';dbname=' . self::getDatabaseName(); self::$dsn = $dsn; }
[ "protected", "static", "function", "generateDSN", "(", ")", "{", "$", "dsn", "=", "self", "::", "getDriver", "(", ")", ".", "\":host=\"", ".", "self", "::", "getHostname", "(", ")", ";", "if", "(", "self", "::", "getPort", "(", ")", ")", "{", "$", ...
Generate the DSN when needed
[ "Generate", "the", "DSN", "when", "needed" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L424-L432
train
thebuggenie/b2db
src/Core.php
Core.setDriver
public static function setDriver($driver) { if (self::isDriverSupported($driver) == false) { throw new Exception('The selected database is not supported: "' . $driver . '".'); } self::$driver = $driver; }
php
public static function setDriver($driver) { if (self::isDriverSupported($driver) == false) { throw new Exception('The selected database is not supported: "' . $driver . '".'); } self::$driver = $driver; }
[ "public", "static", "function", "setDriver", "(", "$", "driver", ")", "{", "if", "(", "self", "::", "isDriverSupported", "(", "$", "driver", ")", "==", "false", ")", "{", "throw", "new", "Exception", "(", "'The selected database is not supported: \"'", ".", "$...
Set the database type @param string $driver
[ "Set", "the", "database", "type" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L573-L579
train
thebuggenie/b2db
src/Core.php
Core.doConnect
public static function doConnect() { if (!\class_exists('\\PDO')) { throw new Exception('B2DB needs the PDO PHP libraries installed. See http://php.net/PDO for more information.'); } try { $uname = self::getUsername(); $pwd = self::getPassword(); $dsn = self::getDSN(); if (self::$db_connection instanceof PDO) { self::$db_connection = null; } self::$db_connection = new PDO($dsn, $uname, $pwd); if (!self::$db_connection instanceof PDO) { throw new Exception('Could not connect to the database, but not caught by PDO'); } switch (self::getDriver()) { case self::DRIVER_MYSQL: self::getDBLink()->query('SET NAMES UTF8'); break; case self::DRIVER_POSTGRES: self::getDBlink()->query('set client_encoding to UTF8'); break; } } catch (PDOException $e) { throw new Exception("Could not connect to the database [" . $e->getMessage() . "], dsn: ".self::getDSN()); } catch (Exception $e) { throw $e; } }
php
public static function doConnect() { if (!\class_exists('\\PDO')) { throw new Exception('B2DB needs the PDO PHP libraries installed. See http://php.net/PDO for more information.'); } try { $uname = self::getUsername(); $pwd = self::getPassword(); $dsn = self::getDSN(); if (self::$db_connection instanceof PDO) { self::$db_connection = null; } self::$db_connection = new PDO($dsn, $uname, $pwd); if (!self::$db_connection instanceof PDO) { throw new Exception('Could not connect to the database, but not caught by PDO'); } switch (self::getDriver()) { case self::DRIVER_MYSQL: self::getDBLink()->query('SET NAMES UTF8'); break; case self::DRIVER_POSTGRES: self::getDBlink()->query('set client_encoding to UTF8'); break; } } catch (PDOException $e) { throw new Exception("Could not connect to the database [" . $e->getMessage() . "], dsn: ".self::getDSN()); } catch (Exception $e) { throw $e; } }
[ "public", "static", "function", "doConnect", "(", ")", "{", "if", "(", "!", "\\", "class_exists", "(", "'\\\\PDO'", ")", ")", "{", "throw", "new", "Exception", "(", "'B2DB needs the PDO PHP libraries installed. See http://php.net/PDO for more information.'", ")", ";", ...
Try connecting to the database
[ "Try", "connecting", "to", "the", "database" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L599-L629
train
thebuggenie/b2db
src/Core.php
Core.getDrivers
public static function getDrivers() { $types = array(); if (class_exists('\PDO')) { $types[self::DRIVER_MYSQL] = 'MySQL / MariaDB'; $types[self::DRIVER_POSTGRES] = 'PostgreSQL'; $types[self::DRIVER_MS_SQL_SERVER] = 'Microsoft SQL Server'; } else { throw new Exception('You need to have PHP PDO installed to be able to use B2DB'); } return $types; }
php
public static function getDrivers() { $types = array(); if (class_exists('\PDO')) { $types[self::DRIVER_MYSQL] = 'MySQL / MariaDB'; $types[self::DRIVER_POSTGRES] = 'PostgreSQL'; $types[self::DRIVER_MS_SQL_SERVER] = 'Microsoft SQL Server'; } else { throw new Exception('You need to have PHP PDO installed to be able to use B2DB'); } return $types; }
[ "public", "static", "function", "getDrivers", "(", ")", "{", "$", "types", "=", "array", "(", ")", ";", "if", "(", "class_exists", "(", "'\\PDO'", ")", ")", "{", "$", "types", "[", "self", "::", "DRIVER_MYSQL", "]", "=", "'MySQL / MariaDB'", ";", "$", ...
Get available DB drivers @return array
[ "Get", "available", "DB", "drivers" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Core.php#L746-L759
train
thebuggenie/b2db
src/Statement.php
Statement.execute
public function execute() { $values = ($this->getQuery() instanceof QueryInterface) ? $this->getQuery()->getValues() : array(); if (Core::isDebugMode()) { if (Core::isDebugLoggingEnabled() && class_exists('\\caspar\\core\\Logging')) { \caspar\core\Logging::log('executing PDO query (' . Core::getSQLCount() . ') - ' . (($this->getQuery() instanceof Criteria) ? $this->getQuery()->getAction() : 'unknown'), 'B2DB'); } $previous_time = Core::getDebugTime(); } $res = $this->statement->execute($values); if (!$res) { $error = $this->statement->errorInfo(); if (Core::isDebugMode()) { Core::sqlHit($this, $previous_time); } throw new Exception($error[2], $this->printSQL()); } if (Core::isDebugLoggingEnabled() && class_exists('\\caspar\\core\\Logging')) { \caspar\core\Logging::log('done', 'B2DB'); } if ($this->getQuery() instanceof Query && $this->getQuery()->isInsert()) { if (Core::getDriver() == Core::DRIVER_MYSQL) { $this->insert_id = Core::getDBLink()->lastInsertId(); } elseif (Core::getDriver() == Core::DRIVER_POSTGRES) { $this->insert_id = Core::getDBLink()->lastInsertId(Core::getTablePrefix() . $this->getQuery()->getTable()->getB2DBName() . '_id_seq'); if (Core::isDebugLoggingEnabled() && class_exists('\\caspar\\core\\Logging')) { \caspar\core\Logging::log('sequence: ' . Core::getTablePrefix() . $this->getQuery()->getTable()->getB2DBName() . '_id_seq', 'b2db'); \caspar\core\Logging::log('id is: ' . $this->insert_id, 'b2db'); } } } $return_value = new Resultset($this); if (Core::isDebugMode()) { Core::sqlHit($this, $previous_time); } if (!$this->getQuery() || $this->getQuery()->isSelect()) { $this->statement->closeCursor(); } return $return_value; }
php
public function execute() { $values = ($this->getQuery() instanceof QueryInterface) ? $this->getQuery()->getValues() : array(); if (Core::isDebugMode()) { if (Core::isDebugLoggingEnabled() && class_exists('\\caspar\\core\\Logging')) { \caspar\core\Logging::log('executing PDO query (' . Core::getSQLCount() . ') - ' . (($this->getQuery() instanceof Criteria) ? $this->getQuery()->getAction() : 'unknown'), 'B2DB'); } $previous_time = Core::getDebugTime(); } $res = $this->statement->execute($values); if (!$res) { $error = $this->statement->errorInfo(); if (Core::isDebugMode()) { Core::sqlHit($this, $previous_time); } throw new Exception($error[2], $this->printSQL()); } if (Core::isDebugLoggingEnabled() && class_exists('\\caspar\\core\\Logging')) { \caspar\core\Logging::log('done', 'B2DB'); } if ($this->getQuery() instanceof Query && $this->getQuery()->isInsert()) { if (Core::getDriver() == Core::DRIVER_MYSQL) { $this->insert_id = Core::getDBLink()->lastInsertId(); } elseif (Core::getDriver() == Core::DRIVER_POSTGRES) { $this->insert_id = Core::getDBLink()->lastInsertId(Core::getTablePrefix() . $this->getQuery()->getTable()->getB2DBName() . '_id_seq'); if (Core::isDebugLoggingEnabled() && class_exists('\\caspar\\core\\Logging')) { \caspar\core\Logging::log('sequence: ' . Core::getTablePrefix() . $this->getQuery()->getTable()->getB2DBName() . '_id_seq', 'b2db'); \caspar\core\Logging::log('id is: ' . $this->insert_id, 'b2db'); } } } $return_value = new Resultset($this); if (Core::isDebugMode()) { Core::sqlHit($this, $previous_time); } if (!$this->getQuery() || $this->getQuery()->isSelect()) { $this->statement->closeCursor(); } return $return_value; }
[ "public", "function", "execute", "(", ")", "{", "$", "values", "=", "(", "$", "this", "->", "getQuery", "(", ")", "instanceof", "QueryInterface", ")", "?", "$", "this", "->", "getQuery", "(", ")", "->", "getValues", "(", ")", ":", "array", "(", ")", ...
Performs a query, then returns a resultset @return Resultset
[ "Performs", "a", "query", "then", "returns", "a", "resultset" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Statement.php#L79-L126
train
thebuggenie/b2db
src/Statement.php
Statement.fetch
public function fetch() { try { if ($this->values = $this->statement->fetch(\PDO::FETCH_ASSOC)) { return $this->values; } else { return false; } } catch (\PDOException $e) { throw new Exception('An error occured while trying to fetch the result: "' . $e->getMessage() . '"'); } }
php
public function fetch() { try { if ($this->values = $this->statement->fetch(\PDO::FETCH_ASSOC)) { return $this->values; } else { return false; } } catch (\PDOException $e) { throw new Exception('An error occured while trying to fetch the result: "' . $e->getMessage() . '"'); } }
[ "public", "function", "fetch", "(", ")", "{", "try", "{", "if", "(", "$", "this", "->", "values", "=", "$", "this", "->", "statement", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "return", "$", "this", "->", "values", ";", ...
Fetch the resultset
[ "Fetch", "the", "resultset" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Statement.php#L162-L173
train
thebuggenie/b2db
src/Statement.php
Statement.prepare
protected function prepare() { if (!Core::getDBlink() instanceof \PDO) { throw new Exception('Connection not up, can\'t prepare the statement'); } $this->statement = Core::getDBlink()->prepare($this->query->getSql()); }
php
protected function prepare() { if (!Core::getDBlink() instanceof \PDO) { throw new Exception('Connection not up, can\'t prepare the statement'); } $this->statement = Core::getDBlink()->prepare($this->query->getSql()); }
[ "protected", "function", "prepare", "(", ")", "{", "if", "(", "!", "Core", "::", "getDBlink", "(", ")", "instanceof", "\\", "PDO", ")", "{", "throw", "new", "Exception", "(", "'Connection not up, can\\'t prepare the statement'", ")", ";", "}", "$", "this", "...
Prepare the statement
[ "Prepare", "the", "statement" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Statement.php#L178-L185
train
n2n/n2n
src/app/n2n/core/module/ModuleManager.php
ModuleManager.getModuleOfTypeName
public function getModuleOfTypeName(string $typeName, bool $required = true) { $typeName = trim($typeName, '\\'); $module = null; $nsLength = 0; foreach ($this->modules as $curNamespace => $curModule) { if (!StringUtils::startsWith($curNamespace . '\\', $typeName)) continue; $curNsLength = strlen($curNamespace); if ($curNsLength > $nsLength) { $module = $curModule; $nsLength = $curNsLength; } } if (!$required || $module !== null) return $module; throw new UnknownModuleException('Type is not part of any installed modules: ' . $typeName); }
php
public function getModuleOfTypeName(string $typeName, bool $required = true) { $typeName = trim($typeName, '\\'); $module = null; $nsLength = 0; foreach ($this->modules as $curNamespace => $curModule) { if (!StringUtils::startsWith($curNamespace . '\\', $typeName)) continue; $curNsLength = strlen($curNamespace); if ($curNsLength > $nsLength) { $module = $curModule; $nsLength = $curNsLength; } } if (!$required || $module !== null) return $module; throw new UnknownModuleException('Type is not part of any installed modules: ' . $typeName); }
[ "public", "function", "getModuleOfTypeName", "(", "string", "$", "typeName", ",", "bool", "$", "required", "=", "true", ")", "{", "$", "typeName", "=", "trim", "(", "$", "typeName", ",", "'\\\\'", ")", ";", "$", "module", "=", "null", ";", "$", "nsLeng...
Returns the module which the passed type is part of. @param string $typeName @param bool $required @throws UnknownModuleException if $required is true and type is not part of any module. @return Module or null if $required is false and type is not part of any module.
[ "Returns", "the", "module", "which", "the", "passed", "type", "is", "part", "of", "." ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/module/ModuleManager.php#L64-L82
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.setLogMailRecipient
public function setLogMailRecipient(string $mailRecipient, string $mailAddresser) { $this->logMailRecipient = $mailRecipient; $this->logMailAddresser = $mailAddresser; }
php
public function setLogMailRecipient(string $mailRecipient, string $mailAddresser) { $this->logMailRecipient = $mailRecipient; $this->logMailAddresser = $mailAddresser; }
[ "public", "function", "setLogMailRecipient", "(", "string", "$", "mailRecipient", ",", "string", "$", "mailAddresser", ")", "{", "$", "this", "->", "logMailRecipient", "=", "$", "mailRecipient", ";", "$", "this", "->", "logMailAddresser", "=", "$", "mailAddresse...
If mailRecipient and mailAddresser are set, the exception handler sends an mail when an exception was handled by this exception handler. @param string $mailRecipient @param string $mailAddresser
[ "If", "mailRecipient", "and", "mailAddresser", "are", "set", "the", "exception", "handler", "sends", "an", "mail", "when", "an", "exception", "was", "handled", "by", "this", "exception", "handler", "." ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L146-L149
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.checkForFatalErrors
public function checkForFatalErrors() { // in case of memory size exhausted error gc_collect_cycles(); // $this->checkForPendingLogExceptions(); $error = error_get_last(); if (!isset($error) || $this->checkForError($error['type'], $error['file'], $error['line'], $error['message'])) { return; } // if ($error['type'] == E_WARNING && substr($error['message'], 0, 23) == 'DateTime::__construct()') { // return; // } // if (!$this->strictAttitude || ($error['type'] & self::STRICT_ATTITUTE_PHP_SEVERITIES)) { // return; // } try { $this->handleTriggeredError($error['type'], $error['message'], $error['file'], $error['line'], null, true); } catch (\Throwable $e) { $this->dispatchException($e); } $this->checkForPendingLogExceptions(); }
php
public function checkForFatalErrors() { // in case of memory size exhausted error gc_collect_cycles(); // $this->checkForPendingLogExceptions(); $error = error_get_last(); if (!isset($error) || $this->checkForError($error['type'], $error['file'], $error['line'], $error['message'])) { return; } // if ($error['type'] == E_WARNING && substr($error['message'], 0, 23) == 'DateTime::__construct()') { // return; // } // if (!$this->strictAttitude || ($error['type'] & self::STRICT_ATTITUTE_PHP_SEVERITIES)) { // return; // } try { $this->handleTriggeredError($error['type'], $error['message'], $error['file'], $error['line'], null, true); } catch (\Throwable $e) { $this->dispatchException($e); } $this->checkForPendingLogExceptions(); }
[ "public", "function", "checkForFatalErrors", "(", ")", "{", "// in case of memory size exhausted error\r", "gc_collect_cycles", "(", ")", ";", "// \t\t$this->checkForPendingLogExceptions();\r", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "!", "isset", ...
Is called from N2N after shutdown was performed to detect and handle fatal errors which weren't handled yet.
[ "Is", "called", "from", "N2N", "after", "shutdown", "was", "performed", "to", "detect", "and", "handle", "fatal", "errors", "which", "weren", "t", "handled", "yet", "." ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L302-L328
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.checkForPendingLogExceptions
private function checkForPendingLogExceptions() { foreach ($this->pendingLogException as $logException) { $this->log($logException); $this->dispatchException($logException); } $this->pendingLogException = array(); }
php
private function checkForPendingLogExceptions() { foreach ($this->pendingLogException as $logException) { $this->log($logException); $this->dispatchException($logException); } $this->pendingLogException = array(); }
[ "private", "function", "checkForPendingLogExceptions", "(", ")", "{", "foreach", "(", "$", "this", "->", "pendingLogException", "as", "$", "logException", ")", "{", "$", "this", "->", "log", "(", "$", "logException", ")", ";", "$", "this", "->", "dispatchExc...
Possible exceptions which were thrown while logging will be handled.
[ "Possible", "exceptions", "which", "were", "thrown", "while", "logging", "will", "be", "handled", "." ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L332-L338
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.createPhpError
private function createPhpError($errno, $errstr, $errfile, $errline) { switch($errno) { case E_ERROR: // if (!is_null($exception = $this->checkForTypeLoaderException($errno, $errstr, $errfile, $errline))) { // return $exception; // } case E_USER_ERROR: case E_COMPILE_ERROR: case E_CORE_ERROR: return new FatalError($errstr, $errno, $errfile, $errline); case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_CORE_WARNING: return new WarningError($errstr, $errno, $errfile, $errline); case E_NOTICE: case E_USER_NOTICE: return new NoticeError($errstr, $errno, $errfile, $errline); case E_RECOVERABLE_ERROR: return new RecoverableError($errstr, $errno, $errfile, $errline); case E_STRICT: return new StrictError($errstr, $errno, $errfile, $errline); case E_PARSE: return new ParseError($errstr, $errno, $errfile, $errline); case E_DEPRECATED: case E_USER_DEPRECATED: return new DeprecatedError($errstr, $errno, $errfile, $errline); default: return new FatalError($errstr, $errno, $errfile, $errline); } }
php
private function createPhpError($errno, $errstr, $errfile, $errline) { switch($errno) { case E_ERROR: // if (!is_null($exception = $this->checkForTypeLoaderException($errno, $errstr, $errfile, $errline))) { // return $exception; // } case E_USER_ERROR: case E_COMPILE_ERROR: case E_CORE_ERROR: return new FatalError($errstr, $errno, $errfile, $errline); case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_CORE_WARNING: return new WarningError($errstr, $errno, $errfile, $errline); case E_NOTICE: case E_USER_NOTICE: return new NoticeError($errstr, $errno, $errfile, $errline); case E_RECOVERABLE_ERROR: return new RecoverableError($errstr, $errno, $errfile, $errline); case E_STRICT: return new StrictError($errstr, $errno, $errfile, $errline); case E_PARSE: return new ParseError($errstr, $errno, $errfile, $errline); case E_DEPRECATED: case E_USER_DEPRECATED: return new DeprecatedError($errstr, $errno, $errfile, $errline); default: return new FatalError($errstr, $errno, $errfile, $errline); } }
[ "private", "function", "createPhpError", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "switch", "(", "$", "errno", ")", "{", "case", "E_ERROR", ":", "// \t\t\t\tif (!is_null($exception = $this->checkForTypeLoaderExcept...
Creates an exception based on a triggered error @param string $errno @param string $errstr @param string $errfile @param string $errline @return \Error created exception
[ "Creates", "an", "exception", "based", "on", "a", "triggered", "error" ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L349-L379
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.buildErrorHash
private function buildErrorHash($errno, $errfile, $errline, $errstr) { return sha1($errno . '-' . $errfile . '-' . $errline . '-' . $errstr); }
php
private function buildErrorHash($errno, $errfile, $errline, $errstr) { return sha1($errno . '-' . $errfile . '-' . $errline . '-' . $errstr); }
[ "private", "function", "buildErrorHash", "(", "$", "errno", ",", "$", "errfile", ",", "$", "errline", ",", "$", "errstr", ")", "{", "return", "sha1", "(", "$", "errno", ".", "'-'", ".", "$", "errfile", ".", "'-'", ".", "$", "errline", ".", "'-'", "...
An Error Hash is a unique hash of an triggered error. @param int $errno @param string $errfile @param int $errline @param string $errstr @return string
[ "An", "Error", "Hash", "is", "a", "unique", "hash", "of", "an", "triggered", "error", "." ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L467-L469
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.createSimpleLogMessage
private function createSimpleLogMessage(\Throwable $e) { $message = get_class($e) . ': ' . $e->getMessage(); if ($e instanceof \ErrorException || $e instanceof \Error) { $message .= ' in ' . $e->getFile() . ' on line ' . $e->getLine(); } return $message; }
php
private function createSimpleLogMessage(\Throwable $e) { $message = get_class($e) . ': ' . $e->getMessage(); if ($e instanceof \ErrorException || $e instanceof \Error) { $message .= ' in ' . $e->getFile() . ' on line ' . $e->getLine(); } return $message; }
[ "private", "function", "createSimpleLogMessage", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "message", "=", "get_class", "(", "$", "e", ")", ".", "': '", ".", "$", "e", "->", "getMessage", "(", ")", ";", "if", "(", "$", "e", "instanceof", "\\",...
Creates short description of an exception used for logging @param \Exception $e @return string short description
[ "Creates", "short", "description", "of", "an", "exception", "used", "for", "logging" ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L563-L569
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.dispatchException
private function dispatchException(\Throwable $t) { array_unshift($this->dispatchingThrowables, $t); $numDispatchingThrowables = sizeof($this->dispatchingThrowables); if (!N2N::isInitialized() || 2 < $numDispatchingThrowables || (2 == $numDispatchingThrowables && !($this->dispatchingThrowables[1] instanceof StatusException)) || !$this->stable) { if (!isset($_SERVER['HTTP_HOST'])) { $this->renderExceptionConsoleInfo($t); return; } $this->renderFatalExceptionsHtmlInfo($this->dispatchingThrowables); return; } if (!N2N::isHttpContextAvailable()) { $this->renderExceptionConsoleInfo($t); return; } try { $this->renderBeautifulExceptionView($t); } catch (\Throwable $t) { $this->handleThrowable($t); } }
php
private function dispatchException(\Throwable $t) { array_unshift($this->dispatchingThrowables, $t); $numDispatchingThrowables = sizeof($this->dispatchingThrowables); if (!N2N::isInitialized() || 2 < $numDispatchingThrowables || (2 == $numDispatchingThrowables && !($this->dispatchingThrowables[1] instanceof StatusException)) || !$this->stable) { if (!isset($_SERVER['HTTP_HOST'])) { $this->renderExceptionConsoleInfo($t); return; } $this->renderFatalExceptionsHtmlInfo($this->dispatchingThrowables); return; } if (!N2N::isHttpContextAvailable()) { $this->renderExceptionConsoleInfo($t); return; } try { $this->renderBeautifulExceptionView($t); } catch (\Throwable $t) { $this->handleThrowable($t); } }
[ "private", "function", "dispatchException", "(", "\\", "Throwable", "$", "t", ")", "{", "array_unshift", "(", "$", "this", "->", "dispatchingThrowables", ",", "$", "t", ")", ";", "$", "numDispatchingThrowables", "=", "sizeof", "(", "$", "this", "->", "dispat...
Decides what exception infos should be rendered. @param \Throwable $t
[ "Decides", "what", "exception", "infos", "should", "be", "rendered", "." ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L665-L690
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.renderFatalExceptionsHtmlInfo
private function renderFatalExceptionsHtmlInfo(array $exceptions) { if ($this->httpFatalExceptionSent) return; if (!$this->isObActive()) { $this->httpFatalExceptionSent = true; } $output = $this->fetchObDirty(); if (!headers_sent()) { header('Content-Type: text/html; charset=utf-8'); header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); } echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\r\n" . '<html xmlns="http://www.w3.org/1999/xhtml" lang="de">' . "\r\n" . '<head>' . "\r\n" . '<title>Fatal Error occurred</title>' . "\r\n" . '</head>' . "\r\n" . '<body>' . "\r\n" . '<h1>Fatal Error occurred</h1>' . "\r\n"; if (N2N::isLiveStageOn()) { echo '<p>Webmaster was informed. Please try later again.</p>' . "\r\n"; } else { $i = 0; foreach ($exceptions as $e) { if ($i++ == 0) { echo '<h2>' . htmlspecialchars(get_class($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</h2>' . "\r\n" . $this->buildDevelopmentExceptionHtmlContent($e); continue; } echo '<h2>caused by: ' . htmlspecialchars(get_class($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</h2>' . "\r\n" . $this->buildDevelopmentExceptionHtmlContent($e); } echo '<h2>Output</h2>' . "\r\n" . '<pre>' . htmlspecialchars($output, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</pre>' . "\r\n"; } echo '</body>' . "\r\n" . '</html>'; }
php
private function renderFatalExceptionsHtmlInfo(array $exceptions) { if ($this->httpFatalExceptionSent) return; if (!$this->isObActive()) { $this->httpFatalExceptionSent = true; } $output = $this->fetchObDirty(); if (!headers_sent()) { header('Content-Type: text/html; charset=utf-8'); header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); } echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\r\n" . '<html xmlns="http://www.w3.org/1999/xhtml" lang="de">' . "\r\n" . '<head>' . "\r\n" . '<title>Fatal Error occurred</title>' . "\r\n" . '</head>' . "\r\n" . '<body>' . "\r\n" . '<h1>Fatal Error occurred</h1>' . "\r\n"; if (N2N::isLiveStageOn()) { echo '<p>Webmaster was informed. Please try later again.</p>' . "\r\n"; } else { $i = 0; foreach ($exceptions as $e) { if ($i++ == 0) { echo '<h2>' . htmlspecialchars(get_class($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</h2>' . "\r\n" . $this->buildDevelopmentExceptionHtmlContent($e); continue; } echo '<h2>caused by: ' . htmlspecialchars(get_class($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</h2>' . "\r\n" . $this->buildDevelopmentExceptionHtmlContent($e); } echo '<h2>Output</h2>' . "\r\n" . '<pre>' . htmlspecialchars($output, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</pre>' . "\r\n"; } echo '</body>' . "\r\n" . '</html>'; }
[ "private", "function", "renderFatalExceptionsHtmlInfo", "(", "array", "$", "exceptions", ")", "{", "if", "(", "$", "this", "->", "httpFatalExceptionSent", ")", "return", ";", "if", "(", "!", "$", "this", "->", "isObActive", "(", ")", ")", "{", "$", "this",...
prints fatal exception infos in html @param array $exceptions
[ "prints", "fatal", "exception", "infos", "in", "html" ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L696-L738
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.renderBeautifulExceptionView
private function renderBeautifulExceptionView(\Throwable $e) { $request = N2N::getCurrentRequest(); $response = N2N::getCurrentResponse(); $status = null; $viewName = null; if ($e instanceof StatusException) { $status = $e->getStatus(); } else { $status = Response::STATUS_500_INTERNAL_SERVER_ERROR; } $throwableModel = null; // if ($e instanceof StatusException && isset($viewName)) { // $throwableModel = new ThrowableModel($e, null); // } else { $throwableModel = new ThrowableModel($e); $this->pendingOutputs[] = $response->fetchBufferedOutput(false); $that = $this; $throwableModel->setOutputCallback(function () use ($that) { $output = implode('', $this->pendingOutputs); $this->pendingOutputs = array(); return $output; }); // } $viewName = N2N::getAppConfig()->error()->getErrorViewName($status); if ($viewName === null) { if (!N2N::isDevelopmentModeOn()) { $viewName = self::DEFAULT_STATUS_LIVE_VIEW; } else { if ($status == Response::STATUS_500_INTERNAL_SERVER_ERROR) { $viewName = self::DEFAULT_500_DEV_VIEW; } else { $viewName = self::DEFAULT_STATUS_DEV_VIEW; } } } $view = N2N::getN2nContext()->lookup(ViewFactory::class)->create($viewName, array('throwableModel' => $throwableModel)); $view->setControllerContext(new ControllerContext($request->getCmdPath(), $request->getCmdContextPath())); $response->reset(); $response->setStatus($status); if ($e instanceof StatusException) { $e->prepareResponse($response); } $response->send($view); }
php
private function renderBeautifulExceptionView(\Throwable $e) { $request = N2N::getCurrentRequest(); $response = N2N::getCurrentResponse(); $status = null; $viewName = null; if ($e instanceof StatusException) { $status = $e->getStatus(); } else { $status = Response::STATUS_500_INTERNAL_SERVER_ERROR; } $throwableModel = null; // if ($e instanceof StatusException && isset($viewName)) { // $throwableModel = new ThrowableModel($e, null); // } else { $throwableModel = new ThrowableModel($e); $this->pendingOutputs[] = $response->fetchBufferedOutput(false); $that = $this; $throwableModel->setOutputCallback(function () use ($that) { $output = implode('', $this->pendingOutputs); $this->pendingOutputs = array(); return $output; }); // } $viewName = N2N::getAppConfig()->error()->getErrorViewName($status); if ($viewName === null) { if (!N2N::isDevelopmentModeOn()) { $viewName = self::DEFAULT_STATUS_LIVE_VIEW; } else { if ($status == Response::STATUS_500_INTERNAL_SERVER_ERROR) { $viewName = self::DEFAULT_500_DEV_VIEW; } else { $viewName = self::DEFAULT_STATUS_DEV_VIEW; } } } $view = N2N::getN2nContext()->lookup(ViewFactory::class)->create($viewName, array('throwableModel' => $throwableModel)); $view->setControllerContext(new ControllerContext($request->getCmdPath(), $request->getCmdContextPath())); $response->reset(); $response->setStatus($status); if ($e instanceof StatusException) { $e->prepareResponse($response); } $response->send($view); }
[ "private", "function", "renderBeautifulExceptionView", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "request", "=", "N2N", "::", "getCurrentRequest", "(", ")", ";", "$", "response", "=", "N2N", "::", "getCurrentResponse", "(", ")", ";", "$", "status", ...
Sends a nice detailed view to the Response @param \Exception $e
[ "Sends", "a", "nice", "detailed", "view", "to", "the", "Response" ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L756-L804
train
n2n/n2n
src/app/n2n/core/err/ExceptionHandler.php
ExceptionHandler.buildDevelopmentExceptionHtmlContent
private function buildDevelopmentExceptionHtmlContent(\Throwable $e) { $html = ''; $first = true; do { if ($first) $first = false; else { $html .= '<h3>caused by: ' . htmlspecialchars(get_class($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</h3>' . "\r\n"; } $html .= '<p>' . htmlspecialchars($e->getMessage(), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</p>' . "\r\n"; if ($e instanceof \ErrorException || $e instanceof \Error) { $filePath = $e->getFile(); $lineNo = $e->getLine(); ThrowableInfoFactory::findCallPos($e, $filePath, $lineNo); if ($filePath !== null) { $html .= '<p>File: <strong>' . htmlspecialchars($filePath, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</strong></p>' . "\r\n"; } if ($lineNo !== null) { $html .= '<p>Line: <strong>' . htmlspecialchars($lineNo, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</strong></p>' . "\r\n"; } } $html .= '<pre>' . htmlspecialchars(ThrowableInfoFactory::buildStackTraceString($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</pre>' . "\r\n"; } while (null != ($e = $e->getPrevious())); return $html; }
php
private function buildDevelopmentExceptionHtmlContent(\Throwable $e) { $html = ''; $first = true; do { if ($first) $first = false; else { $html .= '<h3>caused by: ' . htmlspecialchars(get_class($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</h3>' . "\r\n"; } $html .= '<p>' . htmlspecialchars($e->getMessage(), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</p>' . "\r\n"; if ($e instanceof \ErrorException || $e instanceof \Error) { $filePath = $e->getFile(); $lineNo = $e->getLine(); ThrowableInfoFactory::findCallPos($e, $filePath, $lineNo); if ($filePath !== null) { $html .= '<p>File: <strong>' . htmlspecialchars($filePath, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</strong></p>' . "\r\n"; } if ($lineNo !== null) { $html .= '<p>Line: <strong>' . htmlspecialchars($lineNo, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</strong></p>' . "\r\n"; } } $html .= '<pre>' . htmlspecialchars(ThrowableInfoFactory::buildStackTraceString($e), ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE) . '</pre>' . "\r\n"; } while (null != ($e = $e->getPrevious())); return $html; }
[ "private", "function", "buildDevelopmentExceptionHtmlContent", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "html", "=", "''", ";", "$", "first", "=", "true", ";", "do", "{", "if", "(", "$", "first", ")", "$", "first", "=", "false", ";", "else", ...
Create html description of an exception for fatal error view if development is enabled. @param \Exception $e @return string html description
[ "Create", "html", "description", "of", "an", "exception", "for", "fatal", "error", "view", "if", "development", "is", "enabled", "." ]
b3d45f9cccea5ee59592420dc2cacefd0d1c83ae
https://github.com/n2n/n2n/blob/b3d45f9cccea5ee59592420dc2cacefd0d1c83ae/src/app/n2n/core/err/ExceptionHandler.php#L812-L841
train
thebuggenie/b2db
src/Table.php
Table.addForeignKeyColumn
protected function addForeignKeyColumn($column, Table $table, $key = null) { $add_table = clone $table; $key = ($key !== null) ? $key : $add_table->getIdColumn(); $foreign_column = $add_table->getColumn($key); switch ($foreign_column['type']) { case 'integer': $this->addInteger($column, $foreign_column['length'], $foreign_column['default_value'], false, false, $foreign_column['unsigned']); break; case 'float': $this->addFloat($column, $foreign_column['precision'], $foreign_column['default_value'], false, false, $foreign_column['unsigned']); break; case 'varchar': $this->addVarchar($column, $foreign_column['length'], $foreign_column['default_value'], false); break; case 'text': case 'boolean': case 'blob': throw new Exception('Cannot use a text, blob or boolean column as a foreign key'); } $this->foreign_columns[$column] = array('class' => '\\'.get_class($table), 'key' => $key, 'name' => $column); }
php
protected function addForeignKeyColumn($column, Table $table, $key = null) { $add_table = clone $table; $key = ($key !== null) ? $key : $add_table->getIdColumn(); $foreign_column = $add_table->getColumn($key); switch ($foreign_column['type']) { case 'integer': $this->addInteger($column, $foreign_column['length'], $foreign_column['default_value'], false, false, $foreign_column['unsigned']); break; case 'float': $this->addFloat($column, $foreign_column['precision'], $foreign_column['default_value'], false, false, $foreign_column['unsigned']); break; case 'varchar': $this->addVarchar($column, $foreign_column['length'], $foreign_column['default_value'], false); break; case 'text': case 'boolean': case 'blob': throw new Exception('Cannot use a text, blob or boolean column as a foreign key'); } $this->foreign_columns[$column] = array('class' => '\\'.get_class($table), 'key' => $key, 'name' => $column); }
[ "protected", "function", "addForeignKeyColumn", "(", "$", "column", ",", "Table", "$", "table", ",", "$", "key", "=", "null", ")", "{", "$", "add_table", "=", "clone", "$", "table", ";", "$", "key", "=", "(", "$", "key", "!==", "null", ")", "?", "$...
Adds a foreign table @param string $column @param Table $table @param string $key
[ "Adds", "a", "foreign", "table" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Table.php#L164-L185
train
thebuggenie/b2db
src/Table.php
Table.rawSelectAll
public function rawSelectAll() { $query = new Query($this); $query->generateSelectSQL(true); return Statement::getPreparedStatement($query)->execute(); }
php
public function rawSelectAll() { $query = new Query($this); $query->generateSelectSQL(true); return Statement::getPreparedStatement($query)->execute(); }
[ "public", "function", "rawSelectAll", "(", ")", "{", "$", "query", "=", "new", "Query", "(", "$", "this", ")", ";", "$", "query", "->", "generateSelectSQL", "(", "true", ")", ";", "return", "Statement", "::", "getPreparedStatement", "(", "$", "query", ")...
Selects all records in this table @return Resultset
[ "Selects", "all", "records", "in", "this", "table" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Table.php#L337-L343
train
thebuggenie/b2db
src/Table.php
Table.rawSelectById
public function rawSelectById($id, Query $query = null, $join = 'all') { if (!$id) { return null; } if (!$query instanceof Query) { $query = new Query($this); } $query->where($this->id_column, $id); $query->setLimit(1); return $this->rawSelectOne($query, $join); }
php
public function rawSelectById($id, Query $query = null, $join = 'all') { if (!$id) { return null; } if (!$query instanceof Query) { $query = new Query($this); } $query->where($this->id_column, $id); $query->setLimit(1); return $this->rawSelectOne($query, $join); }
[ "public", "function", "rawSelectById", "(", "$", "id", ",", "Query", "$", "query", "=", "null", ",", "$", "join", "=", "'all'", ")", "{", "if", "(", "!", "$", "id", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "query", "instanceof",...
Returns one row from the current table based on a given id @param integer $id @param Query|null $query @param mixed $join @return \b2db\Row|null
[ "Returns", "one", "row", "from", "the", "current", "table", "based", "on", "a", "given", "id" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Table.php#L360-L372
train
thebuggenie/b2db
src/Table.php
Table.selectById
public function selectById($id, Query $query = null, $join = 'all') { if (!$this->hasCachedB2DBObject($id)) { $row = $this->rawSelectById($id, $query, $join); $object = $this->populateFromRow($row); } else { $object = $this->getB2DBCachedObject($id); } return $object; }
php
public function selectById($id, Query $query = null, $join = 'all') { if (!$this->hasCachedB2DBObject($id)) { $row = $this->rawSelectById($id, $query, $join); $object = $this->populateFromRow($row); } else { $object = $this->getB2DBCachedObject($id); } return $object; }
[ "public", "function", "selectById", "(", "$", "id", ",", "Query", "$", "query", "=", "null", ",", "$", "join", "=", "'all'", ")", "{", "if", "(", "!", "$", "this", "->", "hasCachedB2DBObject", "(", "$", "id", ")", ")", "{", "$", "row", "=", "$", ...
Select an object by its unique id @param integer $id @param Query $query (optional) Criteria with filters @param mixed $join @return Saveable @throws Exception
[ "Select", "an", "object", "by", "its", "unique", "id" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Table.php#L384-L393
train
thebuggenie/b2db
src/Table.php
Table.rawSelect
public function rawSelect(Query $query, $join = 'all') { if (!$query instanceof Query) { $query = new Query($this); } $query->setupJoinTables($join); $query->generateSelectSQL(); $resultset = Statement::getPreparedStatement($query)->execute(); return ($resultset->count()) ? $resultset : null; }
php
public function rawSelect(Query $query, $join = 'all') { if (!$query instanceof Query) { $query = new Query($this); } $query->setupJoinTables($join); $query->generateSelectSQL(); $resultset = Statement::getPreparedStatement($query)->execute(); return ($resultset->count()) ? $resultset : null; }
[ "public", "function", "rawSelect", "(", "Query", "$", "query", ",", "$", "join", "=", "'all'", ")", "{", "if", "(", "!", "$", "query", "instanceof", "Query", ")", "{", "$", "query", "=", "new", "Query", "(", "$", "this", ")", ";", "}", "$", "quer...
Selects rows based on given criteria @param Query $query @param string $join @return Resultset
[ "Selects", "rows", "based", "on", "given", "criteria" ]
8501d737cd824ff961659e059cd920dc0ebd17cf
https://github.com/thebuggenie/b2db/blob/8501d737cd824ff961659e059cd920dc0ebd17cf/src/Table.php#L419-L430
train