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/MelisCoreLostPasswordService.php | MelisCoreLostPasswordService.sendPasswordLostEmail | protected function sendPasswordLostEmail($login, $email)
{
$datas = array();
foreach($this->getPassRequestDataByLogin($login) as $data) {
$datas['rh_login'] = $data->rh_login;
$datas['rh_hash'] = $data->rh_hash;
}
$login = $datas['rh_login'];
$hash = $datas['rh_hash'];
$configPath = 'meliscore/datas';
$melisConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$cfg = $melisConfig->getItem('meliscore/datas/'.getenv('MELIS_PLATFORM'));
if (empty($cfg))
$cfg = $melisConfig->getItem('meliscore/datas/default');
$isActive = false;
if (!empty($cfg['emails']))
if (!empty($cfg['emails']['active']))
$isActive = true;
$url = $cfg['host'].'/melis/reset-password/'.$hash;
if($isActive){
// Tags to be replace at email content with the corresponding value
$tags = array(
'USER_Login' => $login,
'URL' => $url
);
$name_to = $login;
$email_to = $email;
// Fetching user language Id
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$userData = $userTable->getDataByLoginAndEmail($login, $email);
$userData = $userData->current();
$langId = $userData->usr_lang_id;
$melisEmailBO = $this->getServiceLocator()->get('MelisCoreBOEmailService');
$emailResult = $melisEmailBO->sendBoEmailByCode('LOSTPASSWORD', $tags, $email_to, $name_to, $langId);
if ($emailResult){
return true;
}else{
return false;
}
}else{
return false;
}
} | php | protected function sendPasswordLostEmail($login, $email)
{
$datas = array();
foreach($this->getPassRequestDataByLogin($login) as $data) {
$datas['rh_login'] = $data->rh_login;
$datas['rh_hash'] = $data->rh_hash;
}
$login = $datas['rh_login'];
$hash = $datas['rh_hash'];
$configPath = 'meliscore/datas';
$melisConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$cfg = $melisConfig->getItem('meliscore/datas/'.getenv('MELIS_PLATFORM'));
if (empty($cfg))
$cfg = $melisConfig->getItem('meliscore/datas/default');
$isActive = false;
if (!empty($cfg['emails']))
if (!empty($cfg['emails']['active']))
$isActive = true;
$url = $cfg['host'].'/melis/reset-password/'.$hash;
if($isActive){
// Tags to be replace at email content with the corresponding value
$tags = array(
'USER_Login' => $login,
'URL' => $url
);
$name_to = $login;
$email_to = $email;
// Fetching user language Id
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$userData = $userTable->getDataByLoginAndEmail($login, $email);
$userData = $userData->current();
$langId = $userData->usr_lang_id;
$melisEmailBO = $this->getServiceLocator()->get('MelisCoreBOEmailService');
$emailResult = $melisEmailBO->sendBoEmailByCode('LOSTPASSWORD', $tags, $email_to, $name_to, $langId);
if ($emailResult){
return true;
}else{
return false;
}
}else{
return false;
}
} | [
"protected",
"function",
"sendPasswordLostEmail",
"(",
"$",
"login",
",",
"$",
"email",
")",
"{",
"$",
"datas",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPassRequestDataByLogin",
"(",
"$",
"login",
")",
"as",
"$",
"data",
")",
... | Sends an email together with the link to the user
@param String $url
@param String $login
@param String $email | [
"Sends",
"an",
"email",
"together",
"with",
"the",
"link",
"to",
"the",
"user"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L226-L279 | train |
melisplatform/melis-core | src/Controller/PlatformSchemeController.php | PlatformSchemeController.toolContainerAction | public function toolContainerAction()
{
$form = $this->getForm();
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $this->getMelisKey();
$view->hasAccess = $this->hasAccess($melisKey);
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme();
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if ($colors) {
$form->setData($colors);
}
}
$view->setVariable('form', $form);
$view->schemes = $schemeData;
return $view;
} | php | public function toolContainerAction()
{
$form = $this->getForm();
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $this->getMelisKey();
$view->hasAccess = $this->hasAccess($melisKey);
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme();
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if ($colors) {
$form->setData($colors);
}
}
$view->setVariable('form', $form);
$view->schemes = $schemeData;
return $view;
} | [
"public",
"function",
"toolContainerAction",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
... | Tool display container
@return ViewModel | [
"Tool",
"display",
"container"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L34-L57 | train |
melisplatform/melis-core | src/Controller/PlatformSchemeController.php | PlatformSchemeController.getStyleColorCssAction | public function getStyleColorCssAction()
{
$primaryColor = null;
$secondaryColor = null;
$view = new ViewModel();
$response = $this->getResponse();
$view->setTerminal(true);
$response->getHeaders()
->addHeaderLine('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0')
->addHeaderLine('Pragma' , 'no-cache')
->addHeaderLine('Content-Type' , 'text/css;charset=UTF-8');
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme(true);
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if (is_array($colors)) {
foreach ($colors as $colorKey => $colorValue) {
$view->$colorKey = $colorValue;
}
}
}
return $view;
} | php | public function getStyleColorCssAction()
{
$primaryColor = null;
$secondaryColor = null;
$view = new ViewModel();
$response = $this->getResponse();
$view->setTerminal(true);
$response->getHeaders()
->addHeaderLine('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0')
->addHeaderLine('Pragma' , 'no-cache')
->addHeaderLine('Content-Type' , 'text/css;charset=UTF-8');
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme(true);
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if (is_array($colors)) {
foreach ($colors as $colorKey => $colorValue) {
$view->$colorKey = $colorValue;
}
}
}
return $view;
} | [
"public",
"function",
"getStyleColorCssAction",
"(",
")",
"{",
"$",
"primaryColor",
"=",
"null",
";",
"$",
"secondaryColor",
"=",
"null",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(... | Generates a dynamic CSS virtual file that will be rendered
in the platform
@return ViewModel | [
"Generates",
"a",
"dynamic",
"CSS",
"virtual",
"file",
"that",
"will",
"be",
"rendered",
"in",
"the",
"platform"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L406-L434 | train |
melisplatform/melis-core | src/Controller/PlatformSchemeController.php | PlatformSchemeController.formatErrorMessage | private function formatErrorMessage($errors = array())
{
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$appConfigForm = $melisMelisCoreConfig->getItem('meliscore/forms/melis_core_platform_scheme_form');
$appConfigForm = $appConfigForm['elements'];
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'];
}
}
return $errors;
} | php | private function formatErrorMessage($errors = array())
{
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$appConfigForm = $melisMelisCoreConfig->getItem('meliscore/forms/melis_core_platform_scheme_form');
$appConfigForm = $appConfigForm['elements'];
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'];
}
}
return $errors;
} | [
"private",
"function",
"formatErrorMessage",
"(",
"$",
"errors",
"=",
"array",
"(",
")",
")",
"{",
"$",
"melisMelisCoreConfig",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"appConfigForm",
"=",
"$",
"melisM... | Returns the a formatted error messages with its labels
@param array $errors
@return array | [
"Returns",
"the",
"a",
"formatted",
"error",
"messages",
"with",
"its",
"labels"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L473-L489 | train |
melisplatform/melis-core | src/Controller/PlatformSchemeController.php | PlatformSchemeController.getSchemeFolder | private function getSchemeFolder()
{
$uriPath = '/media/platform-scheme/';
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
if($path) {
$uriPath = isset($path['datas']['platform_scheme_dir']) ? $path['datas']['platform_scheme_dir'] : '/media/platform-scheme/';
}
$docRoot = $_SERVER['DOCUMENT_ROOT'] . '';
$schemeFolder = $docRoot.$uriPath;
// check if the folder exists
if(!file_exists($schemeFolder)) {
mkdir($schemeFolder, self::SCHEME_FOLDER_PERMISSION,true);
}
else {
// check writable permission
if(!is_writable($schemeFolder)) {
chmod($schemeFolder, self::SCHEME_FOLDER_PERMISSION);
}
}
return $uriPath;
} | php | private function getSchemeFolder()
{
$uriPath = '/media/platform-scheme/';
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
if($path) {
$uriPath = isset($path['datas']['platform_scheme_dir']) ? $path['datas']['platform_scheme_dir'] : '/media/platform-scheme/';
}
$docRoot = $_SERVER['DOCUMENT_ROOT'] . '';
$schemeFolder = $docRoot.$uriPath;
// check if the folder exists
if(!file_exists($schemeFolder)) {
mkdir($schemeFolder, self::SCHEME_FOLDER_PERMISSION,true);
}
else {
// check writable permission
if(!is_writable($schemeFolder)) {
chmod($schemeFolder, self::SCHEME_FOLDER_PERMISSION);
}
}
return $uriPath;
} | [
"private",
"function",
"getSchemeFolder",
"(",
")",
"{",
"$",
"uriPath",
"=",
"'/media/platform-scheme/'",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"path",
"=",
"$",
"c... | Returns the URI path of the platform scheme folder inside media folder
@return string | [
"Returns",
"the",
"URI",
"path",
"of",
"the",
"platform",
"scheme",
"folder",
"inside",
"media",
"folder"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L504-L529 | train |
melisplatform/melis-core | src/Controller/PlatformSchemeController.php | PlatformSchemeController.convertWithBytes | private function convertWithBytes($size)
{
$precision = 2;
$base = log($size, 1024);
$suffixes = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
return $bytes;
} | php | private function convertWithBytes($size)
{
$precision = 2;
$base = log($size, 1024);
$suffixes = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
return $bytes;
} | [
"private",
"function",
"convertWithBytes",
"(",
"$",
"size",
")",
"{",
"$",
"precision",
"=",
"2",
";",
"$",
"base",
"=",
"log",
"(",
"$",
"size",
",",
"1024",
")",
";",
"$",
"suffixes",
"=",
"array",
"(",
"'B'",
",",
"'KB'",
",",
"'MB'",
",",
"'... | Returns the formatted byte size
@param $size
@return string | [
"Returns",
"the",
"formatted",
"byte",
"size"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L559-L567 | train |
melisplatform/melis-core | src/Controller/PlatformSchemeController.php | PlatformSchemeController.getMaxImageSize | private function getMaxImageSize()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$imagesize = null;
if($path) {
$imageSize = isset($path['datas']['image_size_limit']) ? $path['datas']['image_size_limit'] : null;
}
return $imageSize;
} | php | private function getMaxImageSize()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$imagesize = null;
if($path) {
$imageSize = isset($path['datas']['image_size_limit']) ? $path['datas']['image_size_limit'] : null;
}
return $imageSize;
} | [
"private",
"function",
"getMaxImageSize",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"path",
"=",
"$",
"config",
"->",
"getItem",
"(",
"'meliscore/interface/melis... | Returns the maximum file image size from the configuration
@return null|long | [
"Returns",
"the",
"maximum",
"file",
"image",
"size",
"from",
"the",
"configuration"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L573-L585 | train |
melisplatform/melis-core | src/Controller/PlatformSchemeController.php | PlatformSchemeController.getAllowedUploadableExtension | public function getAllowedUploadableExtension()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$ext = null;
if($path) {
$ext = isset($path['datas']['allowed_file_extension']) ? $path['datas']['allowed_file_extension'] : 'jpeg,jpg,png,svg,ico,gif';
}
return $ext;
} | php | public function getAllowedUploadableExtension()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$ext = null;
if($path) {
$ext = isset($path['datas']['allowed_file_extension']) ? $path['datas']['allowed_file_extension'] : 'jpeg,jpg,png,svg,ico,gif';
}
return $ext;
} | [
"public",
"function",
"getAllowedUploadableExtension",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"path",
"=",
"$",
"config",
"->",
"getItem",
"(",
"'meliscore/in... | Returns the allowed extensions that can be uploaded
@return null|string | [
"Returns",
"the",
"allowed",
"extensions",
"that",
"can",
"be",
"uploaded"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L591-L603 | train |
melisplatform/melis-core | src/Service/MelisCoreTranslationService.php | MelisCoreTranslationService.getTranslationMessages | public function getTranslationMessages($locale = 'en_EN', $textDomain = 'default')
{
// Get the translation service, so we would be able to fetch the current configs
$translator = $this->getServiceLocator()->get('translator');
$translation = $translator->getTranslator();
$messages = array();
// process to access the private properties of translation service
$reflector = new \ReflectionObject($translation);
$property = $reflector->getProperty('files');
$property->setAccessible(true);
$files = (array)$property->getValue($translation);
if($files) {
// re-add translation file to a new Translation Class Object
if(isset($files['default']['*'])) {
foreach($files['default']['*'] as $transKey => $transValues)
{
$this->addTranslationFile('phparray', $transValues['filename'], 'default', $locale);
}
// Load Translation Messages
if (!isset($this->messages[$textDomain][$locale])) {
$this->loadMessages($textDomain, $locale);
}
// This is where the translated mesage are stored
$translatedMessages = (array)$this->messages[$textDomain][$locale];
$messages = array();
$key = '';
foreach($translatedMessages as $translationKey => $translationValues) {
$key = str_replace("'", "\'", $translationKey);
$messages[$key] = str_replace("'", "\'", $translationValues);
}
}
}
return $messages;
} | php | public function getTranslationMessages($locale = 'en_EN', $textDomain = 'default')
{
// Get the translation service, so we would be able to fetch the current configs
$translator = $this->getServiceLocator()->get('translator');
$translation = $translator->getTranslator();
$messages = array();
// process to access the private properties of translation service
$reflector = new \ReflectionObject($translation);
$property = $reflector->getProperty('files');
$property->setAccessible(true);
$files = (array)$property->getValue($translation);
if($files) {
// re-add translation file to a new Translation Class Object
if(isset($files['default']['*'])) {
foreach($files['default']['*'] as $transKey => $transValues)
{
$this->addTranslationFile('phparray', $transValues['filename'], 'default', $locale);
}
// Load Translation Messages
if (!isset($this->messages[$textDomain][$locale])) {
$this->loadMessages($textDomain, $locale);
}
// This is where the translated mesage are stored
$translatedMessages = (array)$this->messages[$textDomain][$locale];
$messages = array();
$key = '';
foreach($translatedMessages as $translationKey => $translationValues) {
$key = str_replace("'", "\'", $translationKey);
$messages[$key] = str_replace("'", "\'", $translationValues);
}
}
}
return $messages;
} | [
"public",
"function",
"getTranslationMessages",
"(",
"$",
"locale",
"=",
"'en_EN'",
",",
"$",
"textDomain",
"=",
"'default'",
")",
"{",
"// Get the translation service, so we would be able to fetch the current configs",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServi... | Re-imports translation files from all the modules and re-writes it
so it can be used in Javascript or any other scripts that would like
to use translation on their messages
@param String $locale
@param string $textDomain
@return Array | [
"Re",
"-",
"imports",
"translation",
"files",
"from",
"all",
"the",
"modules",
"and",
"re",
"-",
"writes",
"it",
"so",
"it",
"can",
"be",
"used",
"in",
"Javascript",
"or",
"any",
"other",
"scripts",
"that",
"would",
"like",
"to",
"use",
"translation",
"o... | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L54-L98 | train |
melisplatform/melis-core | src/Service/MelisCoreTranslationService.php | MelisCoreTranslationService.checkLanguageDirectory | private function checkLanguageDirectory($dir, $modulePath)
{
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$confLanguage = $melisCoreConfig->getItem('meliscore/datas/default/langauges/default_trans_files');
$defaultTransInterface = $confLanguage['defaultTransInterface'];
$defaultTransForms = $confLanguage['defaultTransForms'];
$result = true;
if (!file_exists($dir)) {
$result = mkdir($dir, 0777, true);
if(file_exists($modulePath.$defaultTransInterface)){
copy($modulePath.$defaultTransInterface, $dir.'/'.$defaultTransInterface);
}
if(file_exists($modulePath.$defaultTransForms)){
copy($modulePath.$defaultTransForms, $dir.'/'.$defaultTransForms);
}
}
return $result;
} | php | private function checkLanguageDirectory($dir, $modulePath)
{
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$confLanguage = $melisCoreConfig->getItem('meliscore/datas/default/langauges/default_trans_files');
$defaultTransInterface = $confLanguage['defaultTransInterface'];
$defaultTransForms = $confLanguage['defaultTransForms'];
$result = true;
if (!file_exists($dir)) {
$result = mkdir($dir, 0777, true);
if(file_exists($modulePath.$defaultTransInterface)){
copy($modulePath.$defaultTransInterface, $dir.'/'.$defaultTransInterface);
}
if(file_exists($modulePath.$defaultTransForms)){
copy($modulePath.$defaultTransForms, $dir.'/'.$defaultTransForms);
}
}
return $result;
} | [
"private",
"function",
"checkLanguageDirectory",
"(",
"$",
"dir",
",",
"$",
"modulePath",
")",
"{",
"$",
"melisCoreConfig",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"confLanguage",
"=",
"$",... | Checks the language directory if the path exist, creates a directory if with english translations if not existing
@param string $dir The directory path of the language directory
@param string $modulePath The directory path of melis english translations
@return boolean true if existing, otherwise false if failed to create | [
"Checks",
"the",
"language",
"directory",
"if",
"the",
"path",
"exist",
"creates",
"a",
"directory",
"if",
"with",
"english",
"translations",
"if",
"not",
"existing"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L374-L393 | train |
melisplatform/melis-core | src/Service/MelisCoreTranslationService.php | MelisCoreTranslationService.checkTranslationsDiff | public function checkTranslationsDiff($melisTrans, $currentTrans)
{
$new = include $melisTrans;
$new = is_array($new)? $new : array();
$current = include $currentTrans;
$current = is_array($current)? $current : array();
return array_diff_key($new, $current);
} | php | public function checkTranslationsDiff($melisTrans, $currentTrans)
{
$new = include $melisTrans;
$new = is_array($new)? $new : array();
$current = include $currentTrans;
$current = is_array($current)? $current : array();
return array_diff_key($new, $current);
} | [
"public",
"function",
"checkTranslationsDiff",
"(",
"$",
"melisTrans",
",",
"$",
"currentTrans",
")",
"{",
"$",
"new",
"=",
"include",
"$",
"melisTrans",
";",
"$",
"new",
"=",
"is_array",
"(",
"$",
"new",
")",
"?",
"$",
"new",
":",
"array",
"(",
")",
... | Checks if melis translations have new updates and returns the missing translations
@param string $melisTrans The path of the module translation
@param string $currentTrans The path of the current translation
returns array() Returns an array of missing translations with the keys and values | [
"Checks",
"if",
"melis",
"translations",
"have",
"new",
"updates",
"and",
"returns",
"the",
"missing",
"translations"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L502-L511 | train |
melisplatform/melis-core | src/Service/MelisCoreTranslationService.php | MelisCoreTranslationService.updateTranslations | public function updateTranslations($currentTrans, $transDiff)
{
$status = false;
$current = include $currentTrans;
$current = is_array($current)? $current : array();
$transUpdate = array_merge($current, $transDiff);
$content = "<?php". PHP_EOL . "\t return array(" . PHP_EOL;
foreach($transUpdate as $key => $value){
$content .= "\t\t'". addslashes($key) . "' => '" . addslashes($value) ."'," .PHP_EOL;
}
$content .= "\t );" . PHP_EOL;
if(file_put_contents($currentTrans, $content, LOCK_EX)){
$status = true;
}
return $status;
} | php | public function updateTranslations($currentTrans, $transDiff)
{
$status = false;
$current = include $currentTrans;
$current = is_array($current)? $current : array();
$transUpdate = array_merge($current, $transDiff);
$content = "<?php". PHP_EOL . "\t return array(" . PHP_EOL;
foreach($transUpdate as $key => $value){
$content .= "\t\t'". addslashes($key) . "' => '" . addslashes($value) ."'," .PHP_EOL;
}
$content .= "\t );" . PHP_EOL;
if(file_put_contents($currentTrans, $content, LOCK_EX)){
$status = true;
}
return $status;
} | [
"public",
"function",
"updateTranslations",
"(",
"$",
"currentTrans",
",",
"$",
"transDiff",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"current",
"=",
"include",
"$",
"currentTrans",
";",
"$",
"current",
"=",
"is_array",
"(",
"$",
"current",
")",
... | Updates the translation files
@param string $currentTrans The path of the current translation
@param array $transDiff array of translations to be added
@return boolean | [
"Updates",
"the",
"translation",
"files"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L521-L540 | train |
orchestral/kernel | src/Notifications/ChannelManager.php | ChannelManager.createMailDriver | protected function createMailDriver()
{
$mailer = $this->app->make('orchestra.mail');
return $this->app->make(MailChannel::class, [$mailer->getMailer()]);
} | php | protected function createMailDriver()
{
$mailer = $this->app->make('orchestra.mail');
return $this->app->make(MailChannel::class, [$mailer->getMailer()]);
} | [
"protected",
"function",
"createMailDriver",
"(",
")",
"{",
"$",
"mailer",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'orchestra.mail'",
")",
";",
"return",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"MailChannel",
"::",
"class",
",",
"[",
"$... | Create an instance of the mail driver.
@return \Illuminate\Notifications\Channels\MailChannel | [
"Create",
"an",
"instance",
"of",
"the",
"mail",
"driver",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Notifications/ChannelManager.php#L15-L20 | train |
melisplatform/melis-core | src/Model/Tables/MelisGenericTable.php | MelisGenericTable.getTableColumns | public function getTableColumns()
{
$metadata = new MetaData($this->tableGateway->getAdapter());
$columns = $metadata->getColumnNames($this->tableGateway->getTable());
return $columns;
} | php | public function getTableColumns()
{
$metadata = new MetaData($this->tableGateway->getAdapter());
$columns = $metadata->getColumnNames($this->tableGateway->getTable());
return $columns;
} | [
"public",
"function",
"getTableColumns",
"(",
")",
"{",
"$",
"metadata",
"=",
"new",
"MetaData",
"(",
"$",
"this",
"->",
"tableGateway",
"->",
"getAdapter",
"(",
")",
")",
";",
"$",
"columns",
"=",
"$",
"metadata",
"->",
"getColumnNames",
"(",
"$",
"this... | Returns the columns of the table
@param Array $table | [
"Returns",
"the",
"columns",
"of",
"the",
"table"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisGenericTable.php#L128-L134 | train |
melisplatform/melis-core | src/Model/Tables/MelisGenericTable.php | MelisGenericTable.getTotalData | public function getTotalData($field = null, $idValue = null)
{
$select = $this->tableGateway->getSql()->select();
if (!empty($field) && !empty($idValue))
{
$select->where(array($field => (int) $idValue));
}
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet->count();
} | php | public function getTotalData($field = null, $idValue = null)
{
$select = $this->tableGateway->getSql()->select();
if (!empty($field) && !empty($idValue))
{
$select->where(array($field => (int) $idValue));
}
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet->count();
} | [
"public",
"function",
"getTotalData",
"(",
"$",
"field",
"=",
"null",
",",
"$",
"idValue",
"=",
"null",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"!",
"empty... | Returns the total rows of the selected table
@return int | [
"Returns",
"the",
"total",
"rows",
"of",
"the",
"selected",
"table"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisGenericTable.php#L303-L315 | train |
melisplatform/melis-core | src/Model/Tables/MelisGenericTable.php | MelisGenericTable.getDataForExport | public function getDataForExport($filter, $columns = array())
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array('*'));
$w = new Where();
$filters = array();
$likes = array();
foreach($columns as $columnKeys)
{
$likes[] = new Like($columnKeys, '%'.$filter.'%');
}
$filters = array(new PredicateSet($likes, PredicateSet::COMBINED_BY_OR));
$select->where($filters);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | php | public function getDataForExport($filter, $columns = array())
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array('*'));
$w = new Where();
$filters = array();
$likes = array();
foreach($columns as $columnKeys)
{
$likes[] = new Like($columnKeys, '%'.$filter.'%');
}
$filters = array(new PredicateSet($likes, PredicateSet::COMBINED_BY_OR));
$select->where($filters);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | [
"public",
"function",
"getDataForExport",
"(",
"$",
"filter",
",",
"$",
"columns",
"=",
"array",
"(",
")",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"$",
"select",
"->",
... | Returns all the data from the selected column
@param String $filter
@param array $columns
@return Array | [
"Returns",
"all",
"the",
"data",
"from",
"the",
"selected",
"column"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisGenericTable.php#L332-L354 | train |
orchestral/kernel | src/Http/VersionControl.php | VersionControl.addVersion | public function addVersion(string $code, string $namespace, bool $default = false)
{
$this->supportedVersions[$code] = $namespace;
if (is_null($this->defaultVersion) || $default === true) {
$this->setDefaultVersion($code);
}
return $this;
} | php | public function addVersion(string $code, string $namespace, bool $default = false)
{
$this->supportedVersions[$code] = $namespace;
if (is_null($this->defaultVersion) || $default === true) {
$this->setDefaultVersion($code);
}
return $this;
} | [
"public",
"function",
"addVersion",
"(",
"string",
"$",
"code",
",",
"string",
"$",
"namespace",
",",
"bool",
"$",
"default",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"supportedVersions",
"[",
"$",
"code",
"]",
"=",
"$",
"namespace",
";",
"if",
"(",
... | Add version.
@param string $code
@param string $namespace
@param bool $default
@return $this | [
"Add",
"version",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/VersionControl.php#L32-L41 | train |
orchestral/kernel | src/Http/VersionControl.php | VersionControl.setDefaultVersion | public function setDefaultVersion(string $code)
{
if (! array_key_exists($code, $this->supportedVersions)) {
throw new InvalidArgumentException("Unable to set [{$code}] as default version!");
}
$this->defaultVersion = $code;
return $this;
} | php | public function setDefaultVersion(string $code)
{
if (! array_key_exists($code, $this->supportedVersions)) {
throw new InvalidArgumentException("Unable to set [{$code}] as default version!");
}
$this->defaultVersion = $code;
return $this;
} | [
"public",
"function",
"setDefaultVersion",
"(",
"string",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"supportedVersions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unable to set... | Set default version.
@param string $code
@throws \InvalidArgumentException
@return $this | [
"Set",
"default",
"version",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/VersionControl.php#L52-L61 | train |
orchestral/kernel | src/Http/VersionControl.php | VersionControl.resolve | public function resolve(string $namespace, string $version, string $name): string
{
$class = str_replace('.', '\\', $name);
if (! array_key_exists($version, $this->supportedVersions)) {
$version = $this->defaultVersion;
}
return sprintf('%s\%s\%s\%s', $namespace, $this->supportedVersions[$version], $class);
} | php | public function resolve(string $namespace, string $version, string $name): string
{
$class = str_replace('.', '\\', $name);
if (! array_key_exists($version, $this->supportedVersions)) {
$version = $this->defaultVersion;
}
return sprintf('%s\%s\%s\%s', $namespace, $this->supportedVersions[$version], $class);
} | [
"public",
"function",
"resolve",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"version",
",",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"str_replace",
"(",
"'.'",
",",
"'\\\\'",
",",
"$",
"name",
")",
";",
"if",
"(",
... | Resolve version for requested class.
@param string $namespace
@param string $version
@param string $group
@param string $name
@return string | [
"Resolve",
"version",
"for",
"requested",
"class",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/VersionControl.php#L73-L82 | train |
melisplatform/melis-core | src/Service/MelisCorePlatformSchemeService.php | MelisCorePlatformSchemeService.getCurrentScheme | public function getCurrentScheme($colorsOnly = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = null;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_start', $arrayParameters);
$table = $this->schemeTable();
$schemeData = $table->getActiveScheme($colorsOnly)->current();
if(!$schemeData) {
$schemeData = $table->getDefaultScheme($colorsOnly)->current();
}
// check if scheme has data
if($schemeData) {
$entScheme = new MelisCorePlatformScheme();
$entScheme->setId($schemeData->pscheme_id);
$entScheme->setName($schemeData->pscheme_name);
$entScheme->setColors($schemeData->pscheme_colors);
if(!$colorsOnly) {
$entScheme->setSidebarHeaderLogo($schemeData->pscheme_sidebar_header_logo);
$entScheme->setSidebarHeaderText($schemeData->pscheme_sidebar_header_text);
$entScheme->setLoginLogo($schemeData->pscheme_login_logo);
$entScheme->setLoginBackground($schemeData->pscheme_login_background);
$entScheme->setFavicon($schemeData->pscheme_favicon);
}
$entScheme->setIsActive($schemeData->pscheme_is_active);
$results = $entScheme;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_end', $arrayParameters);
return $arrayParameters['results'];
} | php | public function getCurrentScheme($colorsOnly = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = null;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_start', $arrayParameters);
$table = $this->schemeTable();
$schemeData = $table->getActiveScheme($colorsOnly)->current();
if(!$schemeData) {
$schemeData = $table->getDefaultScheme($colorsOnly)->current();
}
// check if scheme has data
if($schemeData) {
$entScheme = new MelisCorePlatformScheme();
$entScheme->setId($schemeData->pscheme_id);
$entScheme->setName($schemeData->pscheme_name);
$entScheme->setColors($schemeData->pscheme_colors);
if(!$colorsOnly) {
$entScheme->setSidebarHeaderLogo($schemeData->pscheme_sidebar_header_logo);
$entScheme->setSidebarHeaderText($schemeData->pscheme_sidebar_header_text);
$entScheme->setLoginLogo($schemeData->pscheme_login_logo);
$entScheme->setLoginBackground($schemeData->pscheme_login_background);
$entScheme->setFavicon($schemeData->pscheme_favicon);
}
$entScheme->setIsActive($schemeData->pscheme_is_active);
$results = $entScheme;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_end', $arrayParameters);
return $arrayParameters['results'];
} | [
"public",
"function",
"getCurrentScheme",
"(",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"// Event parameters prepare",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"makeArrayFromParameters",
"(",
"__METHOD__",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
... | Returns the currently active scheme, if there's none active
it returns the Melis default scheme
@param bool $colorsOnly : true|false - if true it returns only the colors that will be used in the platform
@return MelisCorePlatformScheme|null | [
"Returns",
"the",
"currently",
"active",
"scheme",
"if",
"there",
"s",
"none",
"active",
"it",
"returns",
"the",
"Melis",
"default",
"scheme"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCorePlatformSchemeService.php#L37-L83 | train |
melisplatform/melis-core | src/Service/MelisCorePlatformSchemeService.php | MelisCorePlatformSchemeService.saveScheme | public function saveScheme($data, $id, $setAsActive = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_start', $arrayParameters);
$data = $arrayParameters['data'];
$id = (int) $arrayParameters['id'];
$setAsActive = (bool) $arrayParameters['setAsActive'];
$success = $this->schemeTable()->save(array_merge($data, array('pscheme_is_active' => $setAsActive)), $id);
if($success) {
$results = true;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_end', $arrayParameters);
return $arrayParameters['results'];
} | php | public function saveScheme($data, $id, $setAsActive = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_start', $arrayParameters);
$data = $arrayParameters['data'];
$id = (int) $arrayParameters['id'];
$setAsActive = (bool) $arrayParameters['setAsActive'];
$success = $this->schemeTable()->save(array_merge($data, array('pscheme_is_active' => $setAsActive)), $id);
if($success) {
$results = true;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_end', $arrayParameters);
return $arrayParameters['results'];
} | [
"public",
"function",
"saveScheme",
"(",
"$",
"data",
",",
"$",
"id",
",",
"$",
"setAsActive",
"=",
"false",
")",
"{",
"// Event parameters prepare",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"makeArrayFromParameters",
"(",
"__METHOD__",
",",
"func_get_arg... | Handles the saving of the platform scheme
@param $data
@param $id
@param bool $setAsActive
@return mixed | [
"Handles",
"the",
"saving",
"of",
"the",
"platform",
"scheme"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCorePlatformSchemeService.php#L92-L117 | train |
melisplatform/melis-core | src/Service/MelisCorePlatformSchemeService.php | MelisCorePlatformSchemeService.resetScheme | public function resetScheme($id)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_start', $arrayParameters);
$defaultSchemeData = $this->schemeTable()->getDefaultScheme()->current();
if($defaultSchemeData) {
$data = array(
'pscheme_colors' => $defaultSchemeData->pscheme_colors,
'pscheme_sidebar_header_logo' => $defaultSchemeData->pscheme_sidebar_header_logo,
'pscheme_sidebar_header_text' => $defaultSchemeData->pscheme_sidebar_header_text,
'pscheme_login_logo' => $defaultSchemeData->pscheme_login_logo,
'pscheme_login_background' => $defaultSchemeData->pscheme_login_background,
'pscheme_favicon' => $defaultSchemeData->pscheme_favicon,
'pscheme_is_active' => 1,
);
$success = $this->schemeTable()->save($data, $id);
if($success) {
$results = true;
}
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_end', $arrayParameters);
return $arrayParameters['results'];
} | php | public function resetScheme($id)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_start', $arrayParameters);
$defaultSchemeData = $this->schemeTable()->getDefaultScheme()->current();
if($defaultSchemeData) {
$data = array(
'pscheme_colors' => $defaultSchemeData->pscheme_colors,
'pscheme_sidebar_header_logo' => $defaultSchemeData->pscheme_sidebar_header_logo,
'pscheme_sidebar_header_text' => $defaultSchemeData->pscheme_sidebar_header_text,
'pscheme_login_logo' => $defaultSchemeData->pscheme_login_logo,
'pscheme_login_background' => $defaultSchemeData->pscheme_login_background,
'pscheme_favicon' => $defaultSchemeData->pscheme_favicon,
'pscheme_is_active' => 1,
);
$success = $this->schemeTable()->save($data, $id);
if($success) {
$results = true;
}
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_end', $arrayParameters);
return $arrayParameters['results'];
} | [
"public",
"function",
"resetScheme",
"(",
"$",
"id",
")",
"{",
"// Event parameters prepare",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"makeArrayFromParameters",
"(",
"__METHOD__",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
"results",
"=",
"false",
... | Handles the event for resetting the whole scheme of the selected template
@param $id
@return mixed | [
"Handles",
"the",
"event",
"for",
"resetting",
"the",
"whole",
"scheme",
"of",
"the",
"selected",
"template"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCorePlatformSchemeService.php#L124-L158 | train |
melisplatform/melis-core | src/Controller/IndexController.php | IndexController.headerAction | public function headerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
if ($melisCoreAuth->hasIdentity())
{
$melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$appsConfigCenter = $melisAppConfig->getItem('/meliscore/interface/meliscore_center/');
$melisCoreRights = $this->getServiceLocator()->get('MelisCoreRights');
$xmlRights = $melisCoreAuth->getAuthRights();
if (!empty($appsConfigCenter['interface']))
{
foreach ($appsConfigCenter['interface'] as $keyInterface => $interface)
{
if (!empty($interface['conf']) && !empty($interface['conf']['type']))
$keyTempInterface = $interface['conf']['type'];
else
$keyTempInterface = $keyInterface;
$isAccessible = $melisCoreRights->isAccessible($xmlRights, MelisCoreRightsService::MELISCORE_PREFIX_INTERFACE, $keyTempInterface);
if (!$isAccessible)
{
unset($appsConfigCenter['interface'][$keyInterface]);
}
}
}
}
else
$appsConfigCenter = array();
$schemeSvc = $this->getServiceLocator()->get('MelisCorePlatformSchemeService');
$schemeData = $schemeSvc->getCurrentScheme();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->appsConfigCenter = $appsConfigCenter;
$view->schemes = $schemeData;
return $view;
} | php | public function headerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
if ($melisCoreAuth->hasIdentity())
{
$melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$appsConfigCenter = $melisAppConfig->getItem('/meliscore/interface/meliscore_center/');
$melisCoreRights = $this->getServiceLocator()->get('MelisCoreRights');
$xmlRights = $melisCoreAuth->getAuthRights();
if (!empty($appsConfigCenter['interface']))
{
foreach ($appsConfigCenter['interface'] as $keyInterface => $interface)
{
if (!empty($interface['conf']) && !empty($interface['conf']['type']))
$keyTempInterface = $interface['conf']['type'];
else
$keyTempInterface = $keyInterface;
$isAccessible = $melisCoreRights->isAccessible($xmlRights, MelisCoreRightsService::MELISCORE_PREFIX_INTERFACE, $keyTempInterface);
if (!$isAccessible)
{
unset($appsConfigCenter['interface'][$keyInterface]);
}
}
}
}
else
$appsConfigCenter = array();
$schemeSvc = $this->getServiceLocator()->get('MelisCorePlatformSchemeService');
$schemeData = $schemeSvc->getCurrentScheme();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->appsConfigCenter = $appsConfigCenter;
$view->schemes = $schemeData;
return $view;
} | [
"public",
"function",
"headerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"melisCoreAuth",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(... | Shows the header section of Melis Platform
@return \Zend\View\Model\ViewModel | [
"Shows",
"the",
"header",
"section",
"of",
"Melis",
"Platform"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L53-L93 | train |
melisplatform/melis-core | src/Controller/IndexController.php | IndexController.leftMenuAction | public function leftMenuAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | php | public function leftMenuAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | [
"public",
"function",
"leftMenuAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"... | Shows the left menu of the Melis Platform interface
@return \Zend\View\Model\ViewModel | [
"Shows",
"the",
"left",
"menu",
"of",
"the",
"Melis",
"Platform",
"interface"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L108-L116 | train |
melisplatform/melis-core | src/Controller/IndexController.php | IndexController.footerAction | public function footerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$coreTool = $this->getServiceLocator()->get('MelisCoreTool');
$modules = $moduleSvc->getAllModules();
$platformVersion = $moduleSvc->getModulesAndVersions('MelisCore');
$request = $this->getRequest();
$uri = $request->getUri();
$domain = $uri->getHost();
$scheme = $uri->getScheme();
$netConnection = $coreTool->isConnected();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->platformVersion = $platformVersion['version'];
$view->modules = serialize($modules);
$view->scheme = $scheme;
$view->domain = $domain;
$view->netConn = $netConnection;
return $view;
} | php | public function footerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$coreTool = $this->getServiceLocator()->get('MelisCoreTool');
$modules = $moduleSvc->getAllModules();
$platformVersion = $moduleSvc->getModulesAndVersions('MelisCore');
$request = $this->getRequest();
$uri = $request->getUri();
$domain = $uri->getHost();
$scheme = $uri->getScheme();
$netConnection = $coreTool->isConnected();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->platformVersion = $platformVersion['version'];
$view->modules = serialize($modules);
$view->scheme = $scheme;
$view->domain = $domain;
$view->netConn = $netConnection;
return $view;
} | [
"public",
"function",
"footerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"moduleSvc",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
... | Shows the footer of the Melis Platform interface
@return \Zend\View\Model\ViewModel | [
"Shows",
"the",
"footer",
"of",
"the",
"Melis",
"Platform",
"interface"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L123-L147 | train |
melisplatform/melis-core | src/Controller/IndexController.php | IndexController.centerAction | public function centerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | php | public function centerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | [
"public",
"function",
"centerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"me... | Shows the center zone of the Melis Platform interface
@return \Zend\View\Model\ViewModel | [
"Shows",
"the",
"center",
"zone",
"of",
"the",
"Melis",
"Platform",
"interface"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L154-L162 | train |
melisplatform/melis-core | src/Controller/IndexController.php | IndexController.headerLanguageAction | public function headerLanguageAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | php | public function headerLanguageAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | [
"public",
"function",
"headerLanguageAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->... | Shows the language select to change the language
@return \Zend\View\Model\ViewModel | [
"Shows",
"the",
"language",
"select",
"to",
"change",
"the",
"language"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L169-L176 | train |
melisplatform/melis-core | src/Controller/IndexController.php | IndexController.closeAllTabsAction | public function closeAllTabsAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | php | public function closeAllTabsAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | [
"public",
"function",
"closeAllTabsAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",... | Shows the close button for closing of tabs | [
"Shows",
"the",
"close",
"button",
"for",
"closing",
"of",
"tabs"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L181-L188 | train |
ublaboo/mailing | src/MailLogger.php | MailLogger.log | public function log($type, Message $mail): void
{
$timestamp = date('Y-m-d H:i:s');
$type .= '.' . time();
$file = $this->getLogFile($type, $timestamp);
if (file_exists($file) && filesize($file)) {
$file = str_replace(
static::LOG_EXTENSION,
'.' . uniqid() . static::LOG_EXTENSION,
$file
);
}
file_put_contents($file, $mail->generateMessage());
} | php | public function log($type, Message $mail): void
{
$timestamp = date('Y-m-d H:i:s');
$type .= '.' . time();
$file = $this->getLogFile($type, $timestamp);
if (file_exists($file) && filesize($file)) {
$file = str_replace(
static::LOG_EXTENSION,
'.' . uniqid() . static::LOG_EXTENSION,
$file
);
}
file_put_contents($file, $mail->generateMessage());
} | [
"public",
"function",
"log",
"(",
"$",
"type",
",",
"Message",
"$",
"mail",
")",
":",
"void",
"{",
"$",
"timestamp",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"type",
".=",
"'.'",
".",
"time",
"(",
")",
";",
"$",
"file",
"=",
"$",
"this",... | Log mail messages to eml file | [
"Log",
"mail",
"messages",
"to",
"eml",
"file"
] | 1dc7751ceae2c5042f8017910c2c406ad8695740 | https://github.com/ublaboo/mailing/blob/1dc7751ceae2c5042f8017910c2c406ad8695740/src/MailLogger.php#L35-L50 | train |
ublaboo/mailing | src/MailLogger.php | MailLogger.getLogFile | public function getLogFile(string $type, string $timestamp): string
{
preg_match('/^((([0-9]{4})-[0-9]{2})-[0-9]{2}).*/', $timestamp, $fragments);
$yearDir = $this->logDirectory . '/' . $fragments[3];
$monthDir = $yearDir . '/' . $fragments[2];
$dayDir = $monthDir . '/' . $fragments[1];
$file = $dayDir . '/' . $type . static::LOG_EXTENSION;
if (!file_exists($dayDir)) {
mkdir($dayDir, 0777, true);
}
if (!file_exists($file)) {
touch($file);
}
return $file;
} | php | public function getLogFile(string $type, string $timestamp): string
{
preg_match('/^((([0-9]{4})-[0-9]{2})-[0-9]{2}).*/', $timestamp, $fragments);
$yearDir = $this->logDirectory . '/' . $fragments[3];
$monthDir = $yearDir . '/' . $fragments[2];
$dayDir = $monthDir . '/' . $fragments[1];
$file = $dayDir . '/' . $type . static::LOG_EXTENSION;
if (!file_exists($dayDir)) {
mkdir($dayDir, 0777, true);
}
if (!file_exists($file)) {
touch($file);
}
return $file;
} | [
"public",
"function",
"getLogFile",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"timestamp",
")",
":",
"string",
"{",
"preg_match",
"(",
"'/^((([0-9]{4})-[0-9]{2})-[0-9]{2}).*/'",
",",
"$",
"timestamp",
",",
"$",
"fragments",
")",
";",
"$",
"yearDir",
"=",... | If not already created, create a directory path that sticks to the standard described above | [
"If",
"not",
"already",
"created",
"create",
"a",
"directory",
"path",
"that",
"sticks",
"to",
"the",
"standard",
"described",
"above"
] | 1dc7751ceae2c5042f8017910c2c406ad8695740 | https://github.com/ublaboo/mailing/blob/1dc7751ceae2c5042f8017910c2c406ad8695740/src/MailLogger.php#L56-L74 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Route/RouteManager.php | RouteManager.setupRoutes | public function setupRoutes()
{
$routes = $this->config();
if (PHP_SAPI == 'cli') {
$scripts = ( isset($routes['scripts']) ? $routes['scripts'] : [] );
foreach ($scripts as $scriptIdent => $scriptConfig) {
$this->setupScript($scriptIdent, $scriptConfig);
}
} else {
$templates = ( isset($routes['templates']) ? $routes['templates'] : [] );
foreach ($templates as $routeIdent => $templateConfig) {
$this->setupTemplate($routeIdent, $templateConfig);
}
$actions = ( isset($routes['actions']) ? $routes['actions'] : [] );
foreach ($actions as $actionIdent => $actionConfig) {
$this->setupAction($actionIdent, $actionConfig);
}
}
} | php | public function setupRoutes()
{
$routes = $this->config();
if (PHP_SAPI == 'cli') {
$scripts = ( isset($routes['scripts']) ? $routes['scripts'] : [] );
foreach ($scripts as $scriptIdent => $scriptConfig) {
$this->setupScript($scriptIdent, $scriptConfig);
}
} else {
$templates = ( isset($routes['templates']) ? $routes['templates'] : [] );
foreach ($templates as $routeIdent => $templateConfig) {
$this->setupTemplate($routeIdent, $templateConfig);
}
$actions = ( isset($routes['actions']) ? $routes['actions'] : [] );
foreach ($actions as $actionIdent => $actionConfig) {
$this->setupAction($actionIdent, $actionConfig);
}
}
} | [
"public",
"function",
"setupRoutes",
"(",
")",
"{",
"$",
"routes",
"=",
"$",
"this",
"->",
"config",
"(",
")",
";",
"if",
"(",
"PHP_SAPI",
"==",
"'cli'",
")",
"{",
"$",
"scripts",
"=",
"(",
"isset",
"(",
"$",
"routes",
"[",
"'scripts'",
"]",
")",
... | Set up the routes.
There are 3 types of routes:
- Templates
- Actions
- Scripts
@return void | [
"Set",
"up",
"the",
"routes",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L48-L68 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Route/RouteManager.php | RouteManager.setupTemplate | private function setupTemplate($routeIdent, $templateConfig)
{
$routePattern = isset($templateConfig['route'])
? $templateConfig['route']
: '/'.ltrim($routeIdent, '/');
$templateConfig['route'] = $routePattern;
$methods = isset($templateConfig['methods'])
? $templateConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$templateConfig
) {
if (!isset($templateConfig['ident'])) {
$templateConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded template route: %s', $templateConfig['ident']),
$templateConfig
);
if (!isset($templateConfig['template_data'])) {
$templateConfig['template_data'] = [];
}
if (count($args)) {
$templateConfig['template_data'] = array_merge(
$templateConfig['template_data'],
$args
);
}
$defaultController = $this['route/controller/template/class'];
$routeController = isset($templateConfig['route_controller'])
? $templateConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $templateConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($templateConfig['ident'])) {
$routeHandler->setName($templateConfig['ident']);
}
return $routeHandler;
} | php | private function setupTemplate($routeIdent, $templateConfig)
{
$routePattern = isset($templateConfig['route'])
? $templateConfig['route']
: '/'.ltrim($routeIdent, '/');
$templateConfig['route'] = $routePattern;
$methods = isset($templateConfig['methods'])
? $templateConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$templateConfig
) {
if (!isset($templateConfig['ident'])) {
$templateConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded template route: %s', $templateConfig['ident']),
$templateConfig
);
if (!isset($templateConfig['template_data'])) {
$templateConfig['template_data'] = [];
}
if (count($args)) {
$templateConfig['template_data'] = array_merge(
$templateConfig['template_data'],
$args
);
}
$defaultController = $this['route/controller/template/class'];
$routeController = isset($templateConfig['route_controller'])
? $templateConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $templateConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($templateConfig['ident'])) {
$routeHandler->setName($templateConfig['ident']);
}
return $routeHandler;
} | [
"private",
"function",
"setupTemplate",
"(",
"$",
"routeIdent",
",",
"$",
"templateConfig",
")",
"{",
"$",
"routePattern",
"=",
"isset",
"(",
"$",
"templateConfig",
"[",
"'route'",
"]",
")",
"?",
"$",
"templateConfig",
"[",
"'route'",
"]",
":",
"'/'",
".",... | Add template route.
Typically for a GET request, the route will render a template.
@param string $routeIdent The template's route identifier.
@param array|\ArrayAccess $templateConfig The template's config for the route.
@return \Slim\Interfaces\RouteInterface | [
"Add",
"template",
"route",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L79-L144 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Route/RouteManager.php | RouteManager.setupAction | private function setupAction($routeIdent, $actionConfig)
{
$routePattern = isset($actionConfig['route'])
? $actionConfig['route']
: '/'.ltrim($routeIdent, '/');
$actionConfig['route'] = $routePattern;
$methods = isset($actionConfig['methods'])
? $actionConfig['methods']
: [ 'POST' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$actionConfig
) {
if (!isset($actionConfig['ident'])) {
$actionConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded action route: %s', $actionConfig['ident']),
$actionConfig
);
if (!isset($actionConfig['action_data'])) {
$actionConfig['action_data'] = [];
}
if (count($args)) {
$actionConfig['action_data'] = array_merge(
$actionConfig['action_data'],
$args
);
}
$defaultController = $this['route/controller/action/class'];
$routeController = isset($actionConfig['route_controller'])
? $actionConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $actionConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($actionConfig['ident'])) {
$routeHandler->setName($actionConfig['ident']);
}
return $routeHandler;
} | php | private function setupAction($routeIdent, $actionConfig)
{
$routePattern = isset($actionConfig['route'])
? $actionConfig['route']
: '/'.ltrim($routeIdent, '/');
$actionConfig['route'] = $routePattern;
$methods = isset($actionConfig['methods'])
? $actionConfig['methods']
: [ 'POST' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$actionConfig
) {
if (!isset($actionConfig['ident'])) {
$actionConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded action route: %s', $actionConfig['ident']),
$actionConfig
);
if (!isset($actionConfig['action_data'])) {
$actionConfig['action_data'] = [];
}
if (count($args)) {
$actionConfig['action_data'] = array_merge(
$actionConfig['action_data'],
$args
);
}
$defaultController = $this['route/controller/action/class'];
$routeController = isset($actionConfig['route_controller'])
? $actionConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $actionConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($actionConfig['ident'])) {
$routeHandler->setName($actionConfig['ident']);
}
return $routeHandler;
} | [
"private",
"function",
"setupAction",
"(",
"$",
"routeIdent",
",",
"$",
"actionConfig",
")",
"{",
"$",
"routePattern",
"=",
"isset",
"(",
"$",
"actionConfig",
"[",
"'route'",
"]",
")",
"?",
"$",
"actionConfig",
"[",
"'route'",
"]",
":",
"'/'",
".",
"ltri... | Add action route.
Typically for a POST request, the route will execute an action (returns JSON).
@param string $routeIdent The action's route identifier.
@param array|\ArrayAccess $actionConfig The action's config for the route.
@return \Slim\Interfaces\RouteInterface | [
"Add",
"action",
"route",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L155-L220 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Route/RouteManager.php | RouteManager.setupScript | private function setupScript($routeIdent, $scriptConfig)
{
$routePattern = isset($scriptConfig['route'])
? $scriptConfig['route']
: '/'.ltrim($routeIdent, '/');
$scriptConfig['route'] = $routePattern;
$methods = isset($scriptConfig['methods'])
? $scriptConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$scriptConfig
) {
if (!isset($scriptConfig['ident'])) {
$scriptConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded script route: %s', $scriptConfig['ident']),
$scriptConfig
);
if (!isset($scriptConfig['script_data'])) {
$scriptConfig['script_data'] = [];
}
if (count($args)) {
$scriptConfig['script_data'] = array_merge(
$scriptConfig['script_data'],
$args
);
}
$defaultController = $this['route/controller/script/class'];
$routeController = isset($scriptConfig['route_controller'])
? $scriptConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $scriptConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($scriptConfig['ident'])) {
$routeHandler->setName($scriptConfig['ident']);
}
return $routeHandler;
} | php | private function setupScript($routeIdent, $scriptConfig)
{
$routePattern = isset($scriptConfig['route'])
? $scriptConfig['route']
: '/'.ltrim($routeIdent, '/');
$scriptConfig['route'] = $routePattern;
$methods = isset($scriptConfig['methods'])
? $scriptConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$scriptConfig
) {
if (!isset($scriptConfig['ident'])) {
$scriptConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded script route: %s', $scriptConfig['ident']),
$scriptConfig
);
if (!isset($scriptConfig['script_data'])) {
$scriptConfig['script_data'] = [];
}
if (count($args)) {
$scriptConfig['script_data'] = array_merge(
$scriptConfig['script_data'],
$args
);
}
$defaultController = $this['route/controller/script/class'];
$routeController = isset($scriptConfig['route_controller'])
? $scriptConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $scriptConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($scriptConfig['ident'])) {
$routeHandler->setName($scriptConfig['ident']);
}
return $routeHandler;
} | [
"private",
"function",
"setupScript",
"(",
"$",
"routeIdent",
",",
"$",
"scriptConfig",
")",
"{",
"$",
"routePattern",
"=",
"isset",
"(",
"$",
"scriptConfig",
"[",
"'route'",
"]",
")",
"?",
"$",
"scriptConfig",
"[",
"'route'",
"]",
":",
"'/'",
".",
"ltri... | Add script route.
Typically used for a CLI interface, the route will execute a script.
@param string $routeIdent The script's route identifier.
@param array|\ArrayAccess $scriptConfig The script's config for the route.
@return \Slim\Interfaces\RouteInterface | [
"Add",
"script",
"route",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L231-L296 | train |
melisplatform/melis-core | src/Service/MelisCoreConfigService.php | MelisCoreConfigService.setFormFieldRequired | public function setFormFieldRequired($array, $fieldName, $isRequired = false)
{
if (!empty($array['input_filter'])) {
foreach ($array['input_filter'] as $keyElement => $element) {
if ($keyElement == $fieldName) {
$array['input_filter'][$keyElement]['required'] = $isRequired;
}
}
}
return $array;
} | php | public function setFormFieldRequired($array, $fieldName, $isRequired = false)
{
if (!empty($array['input_filter'])) {
foreach ($array['input_filter'] as $keyElement => $element) {
if ($keyElement == $fieldName) {
$array['input_filter'][$keyElement]['required'] = $isRequired;
}
}
}
return $array;
} | [
"public",
"function",
"setFormFieldRequired",
"(",
"$",
"array",
",",
"$",
"fieldName",
",",
"$",
"isRequired",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
"[",
"'input_filter'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"array",... | Set a required field in input filters from the the config form array
@param array $array
@param string $fieldName
@param boolean $isRequired
@return array | [
"Set",
"a",
"required",
"field",
"in",
"input",
"filters",
"from",
"the",
"the",
"config",
"form",
"array"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreConfigService.php#L69-L80 | train |
orchestral/kernel | src/Http/Concerns/Transformable.php | Transformable.options | public function options(array $options = [])
{
$this->options = $options;
foreach ($this->meta as $name) {
$this->filterMetaType($name);
}
return $this;
} | php | public function options(array $options = [])
{
$this->options = $options;
foreach ($this->meta as $name) {
$this->filterMetaType($name);
}
return $this;
} | [
"public",
"function",
"options",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"options",
";",
"foreach",
"(",
"$",
"this",
"->",
"meta",
"as",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"filterMetaTy... | Add options.
@param array $options
@return $this | [
"Add",
"options",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L38-L47 | train |
orchestral/kernel | src/Http/Concerns/Transformable.php | Transformable.getRequest | public function getRequest()
{
if (is_null($this->request)) {
$this->setRequest(app()->refresh('request', $this, 'setRequest'));
}
return $this->request;
} | php | public function getRequest()
{
if (is_null($this->request)) {
$this->setRequest(app()->refresh('request', $this, 'setRequest'));
}
return $this->request;
} | [
"public",
"function",
"getRequest",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"request",
")",
")",
"{",
"$",
"this",
"->",
"setRequest",
"(",
"app",
"(",
")",
"->",
"refresh",
"(",
"'request'",
",",
"$",
"this",
",",
"'setRequest'"... | Get request instance.
@return \Illuminate\Http\Request | [
"Get",
"request",
"instance",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L54-L61 | train |
orchestral/kernel | src/Http/Concerns/Transformable.php | Transformable.merge | protected function merge($meta, array $options = []): array
{
if (is_array($meta) && empty($options)) {
$options = $meta;
$meta = null;
}
$options = array_merge(['includes' => [], 'excludes' => []], $options);
foreach ($options as $key => $value) {
$filtered = Arr::expand(array_flip($value));
$parent = Arr::get($this->options, is_null($meta) ? $key : "{$key}.{$meta}", []);
$options[$key] = array_keys(Arr::dot(array_merge_recursive($filtered, $parent)));
}
return $options;
} | php | protected function merge($meta, array $options = []): array
{
if (is_array($meta) && empty($options)) {
$options = $meta;
$meta = null;
}
$options = array_merge(['includes' => [], 'excludes' => []], $options);
foreach ($options as $key => $value) {
$filtered = Arr::expand(array_flip($value));
$parent = Arr::get($this->options, is_null($meta) ? $key : "{$key}.{$meta}", []);
$options[$key] = array_keys(Arr::dot(array_merge_recursive($filtered, $parent)));
}
return $options;
} | [
"protected",
"function",
"merge",
"(",
"$",
"meta",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"is_array",
"(",
"$",
"meta",
")",
"&&",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"$",
... | Merge meta options.
@param string|array $meta
@param array $options
@return array | [
"Merge",
"meta",
"options",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L85-L102 | train |
orchestral/kernel | src/Http/Concerns/Transformable.php | Transformable.transformByMeta | protected function transformByMeta(string $meta, array $data, ...$parameters): array
{
$name = Str::singular($meta);
$types = $this->options[$meta];
if (empty($types)) {
return $data;
}
foreach ($types as $type => $index) {
if (is_array($type)) {
continue;
}
$method = $name.Str::studly($type);
if (method_exists($this, $method)) {
$data = $this->{$method}($data, ...$parameters);
}
}
return $data;
} | php | protected function transformByMeta(string $meta, array $data, ...$parameters): array
{
$name = Str::singular($meta);
$types = $this->options[$meta];
if (empty($types)) {
return $data;
}
foreach ($types as $type => $index) {
if (is_array($type)) {
continue;
}
$method = $name.Str::studly($type);
if (method_exists($this, $method)) {
$data = $this->{$method}($data, ...$parameters);
}
}
return $data;
} | [
"protected",
"function",
"transformByMeta",
"(",
"string",
"$",
"meta",
",",
"array",
"$",
"data",
",",
"...",
"$",
"parameters",
")",
":",
"array",
"{",
"$",
"name",
"=",
"Str",
"::",
"singular",
"(",
"$",
"meta",
")",
";",
"$",
"types",
"=",
"$",
... | Resolve includes for transformer.
@param string $group
@param array $data
@param mixed $parameters
@return array | [
"Resolve",
"includes",
"for",
"transformer",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L113-L135 | train |
orchestral/kernel | src/Http/Concerns/Transformable.php | Transformable.filterMetaType | protected function filterMetaType(string $name): void
{
$types = $this->options[$name] ?? $this->getRequest()->input($name);
if (is_string($types)) {
$types = explode(',', $types);
}
$this->options[$name] = is_array($types) ? Arr::expand(array_flip($types)) : [];
} | php | protected function filterMetaType(string $name): void
{
$types = $this->options[$name] ?? $this->getRequest()->input($name);
if (is_string($types)) {
$types = explode(',', $types);
}
$this->options[$name] = is_array($types) ? Arr::expand(array_flip($types)) : [];
} | [
"protected",
"function",
"filterMetaType",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"??",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"input",
"(",
"$",
"name",
... | Get option by group.
@param string $name
@return void | [
"Get",
"option",
"by",
"group",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L144-L153 | train |
melisplatform/melis-core | public/js/filemanager/include/php_image_magician.php | imageLib.gd_filter_monopin | public function gd_filter_monopin()
{
if ($this->imageResized)
{
imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 100);
}
} | php | public function gd_filter_monopin()
{
if ($this->imageResized)
{
imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 100);
}
} | [
"public",
"function",
"gd_filter_monopin",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"imageResized",
")",
"{",
"imagefilter",
"(",
"$",
"this",
"->",
"imageResized",
",",
"IMG_FILTER_GRAYSCALE",
")",
";",
"imagefilter",
"(",
"$",
"this",
"->",
"imageResiz... | Apply 'Monopin' preset | [
"Apply",
"Monopin",
"preset"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/include/php_image_magician.php#L1201-L1211 | train |
melisplatform/melis-core | public/js/filemanager/include/php_image_magician.php | imageLib.gd_apply_overlay | private function gd_apply_overlay($im, $type, $amount)
#
# Original Author: Marc Hibbins
# License: Attribution-ShareAlike 3.0
# Purpose:
# Params in:
# Params out:
# Notes:
#
{
$width = imagesx($im);
$height = imagesy($im);
$filter = imagecreatetruecolor($width, $height);
imagealphablending($filter, false);
imagesavealpha($filter, true);
$transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127);
imagefilledrectangle($filter, 0, 0, $width, $height, $transparent);
// *** Resize overlay
$overlay = $this->filterOverlayPath . '/' . $type . '.png';
$png = imagecreatefrompng($overlay);
imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png));
$comp = imagecreatetruecolor($width, $height);
imagecopy($comp, $im, 0, 0, 0, 0, $width, $height);
imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height);
imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($comp);
return $im;
} | php | private function gd_apply_overlay($im, $type, $amount)
#
# Original Author: Marc Hibbins
# License: Attribution-ShareAlike 3.0
# Purpose:
# Params in:
# Params out:
# Notes:
#
{
$width = imagesx($im);
$height = imagesy($im);
$filter = imagecreatetruecolor($width, $height);
imagealphablending($filter, false);
imagesavealpha($filter, true);
$transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127);
imagefilledrectangle($filter, 0, 0, $width, $height, $transparent);
// *** Resize overlay
$overlay = $this->filterOverlayPath . '/' . $type . '.png';
$png = imagecreatefrompng($overlay);
imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png));
$comp = imagecreatetruecolor($width, $height);
imagecopy($comp, $im, 0, 0, 0, 0, $width, $height);
imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height);
imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($comp);
return $im;
} | [
"private",
"function",
"gd_apply_overlay",
"(",
"$",
"im",
",",
"$",
"type",
",",
"$",
"amount",
")",
"#",
"# Original Author: Marc Hibbins",
"# License: Attribution-ShareAlike 3.0",
"# Purpose:",
"# Params in:",
"# Params out:",
"# Notes:",
"#",
"{",
"$",
"width",
... | Apply a PNG overlay | [
"Apply",
"a",
"PNG",
"overlay"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/include/php_image_magician.php#L1231-L1264 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/AppConfig.php | AppConfig.setBasePath | public function setBasePath($path)
{
if ($path === null) {
throw new InvalidArgumentException(
'The base path is required.'
);
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The base path must be a string'
);
}
$this->basePath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
} | php | public function setBasePath($path)
{
if ($path === null) {
throw new InvalidArgumentException(
'The base path is required.'
);
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The base path must be a string'
);
}
$this->basePath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
} | [
"public",
"function",
"setBasePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The base path is required.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",... | Set the application's absolute root path.
Resolves symlinks with realpath() and ensure trailing slash.
@param string $path The absolute path to the application's root directory.
@throws InvalidArgumentException If the argument is not a string.
@return self | [
"Set",
"the",
"application",
"s",
"absolute",
"root",
"path",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L188-L204 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/AppConfig.php | AppConfig.setPublicPath | public function setPublicPath($path)
{
if ($path === null) {
$this->publicPath = null;
return $this;
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The public path must be a string'
);
}
$this->publicPath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
} | php | public function setPublicPath($path)
{
if ($path === null) {
$this->publicPath = null;
return $this;
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The public path must be a string'
);
}
$this->publicPath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
} | [
"public",
"function",
"setPublicPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"publicPath",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
... | Set the application's absolute path to the public web directory.
@param string $path The path to the application's public directory.
@throws InvalidArgumentException If the argument is not a string.
@return self | [
"Set",
"the",
"application",
"s",
"absolute",
"path",
"to",
"the",
"public",
"web",
"directory",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L223-L238 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/AppConfig.php | AppConfig.publicPath | public function publicPath()
{
if (!isset($this->publicPath)) {
$this->publicPath = $this->basePath().'www'.DIRECTORY_SEPARATOR;
}
return $this->publicPath;
} | php | public function publicPath()
{
if (!isset($this->publicPath)) {
$this->publicPath = $this->basePath().'www'.DIRECTORY_SEPARATOR;
}
return $this->publicPath;
} | [
"public",
"function",
"publicPath",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"publicPath",
")",
")",
"{",
"$",
"this",
"->",
"publicPath",
"=",
"$",
"this",
"->",
"basePath",
"(",
")",
".",
"'www'",
".",
"DIRECTORY_SEPARATOR",
... | Retrieve the application's absolute path to the public web directory.
@return string The absolute path to the application's public directory. | [
"Retrieve",
"the",
"application",
"s",
"absolute",
"path",
"to",
"the",
"public",
"web",
"directory",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L245-L252 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/AppConfig.php | AppConfig.setBaseUrl | public function setBaseUrl($uri)
{
if (is_string($uri)) {
$this->baseUrl = Uri::createFromString($uri);
} else {
$this->baseUrl = $uri;
}
return $this;
} | php | public function setBaseUrl($uri)
{
if (is_string($uri)) {
$this->baseUrl = Uri::createFromString($uri);
} else {
$this->baseUrl = $uri;
}
return $this;
} | [
"public",
"function",
"setBaseUrl",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"uri",
")",
")",
"{",
"$",
"this",
"->",
"baseUrl",
"=",
"Uri",
"::",
"createFromString",
"(",
"$",
"uri",
")",
";",
"}",
"else",
"{",
"$",
"this",
"... | Set the application's fully qualified base URL to the public web directory.
@param UriInterface|string $uri The base URI to the application's web directory.
@return self | [
"Set",
"the",
"application",
"s",
"fully",
"qualified",
"base",
"URL",
"to",
"the",
"public",
"web",
"directory",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L260-L268 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/AppConfig.php | AppConfig.setProjectName | public function setProjectName($projectName)
{
if ($projectName === null) {
$this->projectName = null;
return $this;
}
if (!is_string($projectName)) {
throw new InvalidArgumentException(
'Project name must be a string'
);
}
$this->projectName = $projectName;
return $this;
} | php | public function setProjectName($projectName)
{
if ($projectName === null) {
$this->projectName = null;
return $this;
}
if (!is_string($projectName)) {
throw new InvalidArgumentException(
'Project name must be a string'
);
}
$this->projectName = $projectName;
return $this;
} | [
"public",
"function",
"setProjectName",
"(",
"$",
"projectName",
")",
"{",
"if",
"(",
"$",
"projectName",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"projectName",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
... | Sets the project name.
@param string|null $projectName The project name.
@throws InvalidArgumentException If the project argument is not a string (or null).
@return self | [
"Sets",
"the",
"project",
"name",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L322-L336 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Route/RouteConfig.php | RouteConfig.setHeaders | public function setHeaders(array $headers)
{
$this->headers = [];
foreach ($headers as $name => $val) {
$this->addHeader($name, $val);
}
return $this;
} | php | public function setHeaders(array $headers)
{
$this->headers = [];
foreach ($headers as $name => $val) {
$this->addHeader($name, $val);
}
return $this;
} | [
"public",
"function",
"setHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"this",
"->",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"addHeader",
"(",
"$",
... | Add custom headers
@param array $headers The custom headers, in key=>val pairs.
@return self | [
"Add",
"custom",
"headers"
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteConfig.php#L186-L193 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Route/RouteConfig.php | RouteConfig.addMethod | public function addMethod($method)
{
if (!is_string($method)) {
throw new InvalidArgumentException(
sprintf(
'Unsupported HTTP method; must be a string, received %s',
(is_object($method) ? get_class($method) : gettype($method))
)
);
}
// According to RFC, methods are defined in uppercase (See RFC 7231)
$method = strtoupper($method);
$validHttpMethods = [
'CONNECT',
'DELETE',
'GET',
'HEAD',
'OPTIONS',
'PATCH',
'POST',
'PUT',
'TRACE',
];
if (!in_array($method, $validHttpMethods)) {
throw new InvalidArgumentException(sprintf(
'Unsupported HTTP method; must be one of "%s", received "%s"',
implode('","', $validHttpMethods),
$method
));
}
$this->methods[] = $method;
return $this;
} | php | public function addMethod($method)
{
if (!is_string($method)) {
throw new InvalidArgumentException(
sprintf(
'Unsupported HTTP method; must be a string, received %s',
(is_object($method) ? get_class($method) : gettype($method))
)
);
}
// According to RFC, methods are defined in uppercase (See RFC 7231)
$method = strtoupper($method);
$validHttpMethods = [
'CONNECT',
'DELETE',
'GET',
'HEAD',
'OPTIONS',
'PATCH',
'POST',
'PUT',
'TRACE',
];
if (!in_array($method, $validHttpMethods)) {
throw new InvalidArgumentException(sprintf(
'Unsupported HTTP method; must be one of "%s", received "%s"',
implode('","', $validHttpMethods),
$method
));
}
$this->methods[] = $method;
return $this;
} | [
"public",
"function",
"addMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unsupported HTTP method; must be a string, received %s'",
",",
"(",
... | Add route HTTP method.
@param string $method The route's supported HTTP method.
@throws InvalidArgumentException If the HTTP method is invalid.
@return self | [
"Add",
"route",
"HTTP",
"method",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteConfig.php#L287-L324 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/ServiceProvider/AppServiceProvider.php | AppServiceProvider.registerViewServices | protected function registerViewServices(Container $container)
{
if (!isset($container['view/mustache/helpers'])) {
$container['view/mustache/helpers'] = function () {
return [];
};
}
/**
* Extend helpers for the Mustache Engine
*
* @return array
*/
$container->extend('view/mustache/helpers', function (array $helpers, Container $container) {
$baseUrl = $container['base-url'];
$urls = [
/**
* Application debug mode.
*
* @return boolean
*/
'debug' => ($container['config']['debug'] || $container['config']['dev_mode']),
/**
* Retrieve the base URI of the project.
*
* @return UriInterface|null
*/
'siteUrl' => $baseUrl,
/**
* Alias of "siteUrl"
*
* @return UriInterface|null
*/
'baseUrl' => $baseUrl,
/**
* Prepend the base URI to the given path.
*
* @param string $uri A URI path to wrap.
* @return UriInterface|null
*/
'withBaseUrl' => function ($uri, LambdaHelper $helper = null) use ($baseUrl) {
if ($helper) {
$uri = $helper->render($uri);
}
$uri = strval($uri);
if ($uri === '') {
$uri = $baseUrl->withPath('');
} else {
$parts = parse_url($uri);
if (!isset($parts['scheme'])) {
if (!in_array($uri[0], [ '/', '#', '?' ])) {
$path = isset($parts['path']) ? $parts['path'] : '';
$query = isset($parts['query']) ? $parts['query'] : '';
$hash = isset($parts['fragment']) ? $parts['fragment'] : '';
$uri = $baseUrl->withPath($path)
->withQuery($query)
->withFragment($hash);
}
}
}
return $uri;
},
'renderContext' => function ($text, LambdaHelper $helper = null) {
return $helper->render('{{>'.$helper->render($text).'}}');
}
];
return array_merge($helpers, $urls);
});
} | php | protected function registerViewServices(Container $container)
{
if (!isset($container['view/mustache/helpers'])) {
$container['view/mustache/helpers'] = function () {
return [];
};
}
/**
* Extend helpers for the Mustache Engine
*
* @return array
*/
$container->extend('view/mustache/helpers', function (array $helpers, Container $container) {
$baseUrl = $container['base-url'];
$urls = [
/**
* Application debug mode.
*
* @return boolean
*/
'debug' => ($container['config']['debug'] || $container['config']['dev_mode']),
/**
* Retrieve the base URI of the project.
*
* @return UriInterface|null
*/
'siteUrl' => $baseUrl,
/**
* Alias of "siteUrl"
*
* @return UriInterface|null
*/
'baseUrl' => $baseUrl,
/**
* Prepend the base URI to the given path.
*
* @param string $uri A URI path to wrap.
* @return UriInterface|null
*/
'withBaseUrl' => function ($uri, LambdaHelper $helper = null) use ($baseUrl) {
if ($helper) {
$uri = $helper->render($uri);
}
$uri = strval($uri);
if ($uri === '') {
$uri = $baseUrl->withPath('');
} else {
$parts = parse_url($uri);
if (!isset($parts['scheme'])) {
if (!in_array($uri[0], [ '/', '#', '?' ])) {
$path = isset($parts['path']) ? $parts['path'] : '';
$query = isset($parts['query']) ? $parts['query'] : '';
$hash = isset($parts['fragment']) ? $parts['fragment'] : '';
$uri = $baseUrl->withPath($path)
->withQuery($query)
->withFragment($hash);
}
}
}
return $uri;
},
'renderContext' => function ($text, LambdaHelper $helper = null) {
return $helper->render('{{>'.$helper->render($text).'}}');
}
];
return array_merge($helpers, $urls);
});
} | [
"protected",
"function",
"registerViewServices",
"(",
"Container",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'view/mustache/helpers'",
"]",
")",
")",
"{",
"$",
"container",
"[",
"'view/mustache/helpers'",
"]",
"=",
"func... | Add helpers to the view services.
@param Container $container A container instance.
@return void | [
"Add",
"helpers",
"to",
"the",
"view",
"services",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/ServiceProvider/AppServiceProvider.php#L456-L528 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/App.php | App.setup | private function setup()
{
$config = $this->config();
date_default_timezone_set($config['timezone']);
// Setup routes
$this->routeManager()->setupRoutes();
// Setup modules
$this->setupModules();
// Setup routable (if not running CLI mode)
if (PHP_SAPI !== 'cli') {
$this->setupRoutables();
}
// Setup middlewares
$this->setupMiddlewares();
} | php | private function setup()
{
$config = $this->config();
date_default_timezone_set($config['timezone']);
// Setup routes
$this->routeManager()->setupRoutes();
// Setup modules
$this->setupModules();
// Setup routable (if not running CLI mode)
if (PHP_SAPI !== 'cli') {
$this->setupRoutables();
}
// Setup middlewares
$this->setupMiddlewares();
} | [
"private",
"function",
"setup",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"(",
")",
";",
"date_default_timezone_set",
"(",
"$",
"config",
"[",
"'timezone'",
"]",
")",
";",
"// Setup routes",
"$",
"this",
"->",
"routeManager",
"(",
"... | Registers the default services and features that Charcoal needs to work.
@return void | [
"Registers",
"the",
"default",
"services",
"and",
"features",
"that",
"Charcoal",
"needs",
"to",
"work",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/App.php#L126-L144 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/App.php | App.setupRoutables | private function setupRoutables()
{
$app = $this;
// For now, need to rely on a catch-all...
$this->get(
'{catchall:.*}',
function (
RequestInterface $request,
ResponseInterface $response,
array $args
) use ($app) {
$config = $app->config();
$routables = $config['routables'];
if ($routables === null || count($routables) === 0) {
return $this['notFoundHandler']($request, $response);
}
$routeFactory = $this['route/factory'];
foreach ($routables as $routableType => $routableOptions) {
$route = $routeFactory->create($routableType, [
'path' => $args['catchall'],
'config' => $routableOptions
]);
if ($route->pathResolvable($this)) {
$this['logger']->debug(
sprintf('Loaded routable "%s" for path %s', $routableType, $args['catchall'])
);
return $route($this, $request, $response);
}
}
// If this point is reached, no routable has provided a callback. 404.
return $this['notFoundHandler']($request, $response);
}
);
} | php | private function setupRoutables()
{
$app = $this;
// For now, need to rely on a catch-all...
$this->get(
'{catchall:.*}',
function (
RequestInterface $request,
ResponseInterface $response,
array $args
) use ($app) {
$config = $app->config();
$routables = $config['routables'];
if ($routables === null || count($routables) === 0) {
return $this['notFoundHandler']($request, $response);
}
$routeFactory = $this['route/factory'];
foreach ($routables as $routableType => $routableOptions) {
$route = $routeFactory->create($routableType, [
'path' => $args['catchall'],
'config' => $routableOptions
]);
if ($route->pathResolvable($this)) {
$this['logger']->debug(
sprintf('Loaded routable "%s" for path %s', $routableType, $args['catchall'])
);
return $route($this, $request, $response);
}
}
// If this point is reached, no routable has provided a callback. 404.
return $this['notFoundHandler']($request, $response);
}
);
} | [
"private",
"function",
"setupRoutables",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
";",
"// For now, need to rely on a catch-all...",
"$",
"this",
"->",
"get",
"(",
"'{catchall:.*}'",
",",
"function",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInter... | Setup the application's "global" routables.
Routables can only be defined globally (app-level) for now.
@return void | [
"Setup",
"the",
"application",
"s",
"global",
"routables",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/App.php#L186-L220 | train |
melisplatform/melis-core | src/Model/Tables/MelisPlatformSchemeTable.php | MelisPlatformSchemeTable.getSchemeById | public function getSchemeById($id, $colorsOnly = false)
{
$id = (int) $id;
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_id', $id);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | php | public function getSchemeById($id, $colorsOnly = false)
{
$id = (int) $id;
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_id', $id);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | [
"public",
"function",
"getSchemeById",
"(",
"$",
"id",
",",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",... | Query scheme table by ID
@param $id
@param bool $colorsOnly
@return null|\Zend\Db\ResultSet\ResultSetInterface | [
"Query",
"scheme",
"table",
"by",
"ID"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisPlatformSchemeTable.php#L28-L45 | train |
melisplatform/melis-core | src/Model/Tables/MelisPlatformSchemeTable.php | MelisPlatformSchemeTable.getSchemeByName | public function getSchemeByName($name, $colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_name', $name);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | php | public function getSchemeByName($name, $colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_name', $name);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | [
"public",
"function",
"getSchemeByName",
"(",
"$",
"name",
",",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"$",
"colorsOnly",
"... | Query scheme table by name
@param $name
@param bool $colorsOnly
@return null|\Zend\Db\ResultSet\ResultSetInterface | [
"Query",
"scheme",
"table",
"by",
"name"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisPlatformSchemeTable.php#L53-L68 | train |
melisplatform/melis-core | src/Model/Tables/MelisPlatformSchemeTable.php | MelisPlatformSchemeTable.getActiveScheme | public function getActiveScheme($colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_is_active', 1);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | php | public function getActiveScheme($colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_is_active', 1);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | [
"public",
"function",
"getActiveScheme",
"(",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"$",
"colorsOnly",
")",
"{",
"$",
"sel... | Returns the currently active scheme
@param bool $colorsOnly
@return null|\Zend\Db\ResultSet\ResultSetInterface | [
"Returns",
"the",
"currently",
"active",
"scheme"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisPlatformSchemeTable.php#L75-L90 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Handler/AbstractHandler.php | AbstractHandler.respondWith | protected function respondWith(ResponseInterface $response, $contentType, $output)
{
$body = new Body(fopen('php://temp', 'r+'));
$body->write($output);
return $response->withHeader('Content-Type', $contentType)
->withBody($body);
} | php | protected function respondWith(ResponseInterface $response, $contentType, $output)
{
$body = new Body(fopen('php://temp', 'r+'));
$body->write($output);
return $response->withHeader('Content-Type', $contentType)
->withBody($body);
} | [
"protected",
"function",
"respondWith",
"(",
"ResponseInterface",
"$",
"response",
",",
"$",
"contentType",
",",
"$",
"output",
")",
"{",
"$",
"body",
"=",
"new",
"Body",
"(",
"fopen",
"(",
"'php://temp'",
",",
"'r+'",
")",
")",
";",
"$",
"body",
"->",
... | Mutate the given response.
@param ResponseInterface $response The most recent Response object.
@param string $contentType The content type of the output.
@param string $output The text output.
@return ResponseInterface | [
"Mutate",
"the",
"given",
"response",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/AbstractHandler.php#L275-L282 | train |
UseMuffin/Tokenize | src/Model/Table/TokensTable.php | TokensTable.findToken | public function findToken(Query $query, array $options)
{
$options += [
'token' => null,
'expired >' => new DateTime(),
'status' => false
];
return $query->where($options);
} | php | public function findToken(Query $query, array $options)
{
$options += [
'token' => null,
'expired >' => new DateTime(),
'status' => false
];
return $query->where($options);
} | [
"public",
"function",
"findToken",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'token'",
"=>",
"null",
",",
"'expired >'",
"=>",
"new",
"DateTime",
"(",
")",
",",
"'status'",
"=>",
"false",
"]",
";",
... | Custom finder "token"
@param \Cake\ORM\Query $query Query
@param array $options Options
@return \Cake\ORM\Query | [
"Custom",
"finder",
"token"
] | a7ecf4114782abe12b0ab36e8a32504428fe91ec | https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Table/TokensTable.php#L42-L51 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Config/LoggerConfig.php | LoggerConfig.addHandler | public function addHandler(array $handler, $key = null)
{
if (!isset($handler['type'])) {
throw new InvalidArgumentException(
'Handler type is required.'
);
}
if (!is_string($key)) {
$this->handlers[] = $handler;
} else {
$this->handlers[$key] = $handler;
}
return $this;
} | php | public function addHandler(array $handler, $key = null)
{
if (!isset($handler['type'])) {
throw new InvalidArgumentException(
'Handler type is required.'
);
}
if (!is_string($key)) {
$this->handlers[] = $handler;
} else {
$this->handlers[$key] = $handler;
}
return $this;
} | [
"public",
"function",
"addHandler",
"(",
"array",
"$",
"handler",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"handler",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Handler type is ... | Add a record handler to use.
@param array $handler The record handler structure.
@param string|null $key The handler's key.
@throws InvalidArgumentException If the handler is invalid.
@return self | [
"Add",
"a",
"record",
"handler",
"to",
"use",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Config/LoggerConfig.php#L143-L158 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Config/LoggerConfig.php | LoggerConfig.addProcessor | public function addProcessor(array $processor, $key = null)
{
if (!isset($processor['type'])) {
throw new InvalidArgumentException(
'Processor type is required.'
);
}
if (!is_string($key)) {
$this->processors[] = $processor;
} else {
$this->processors[$key] = $processor;
}
return $this;
} | php | public function addProcessor(array $processor, $key = null)
{
if (!isset($processor['type'])) {
throw new InvalidArgumentException(
'Processor type is required.'
);
}
if (!is_string($key)) {
$this->processors[] = $processor;
} else {
$this->processors[$key] = $processor;
}
return $this;
} | [
"public",
"function",
"addProcessor",
"(",
"array",
"$",
"processor",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"processor",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Processor ... | Add a record processor to use.
@param array $processor The record processor structure.
@param string|null $key The processor's key.
@throws InvalidArgumentException If the processor is invalid.
@return self | [
"Add",
"a",
"record",
"processor",
"to",
"use",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Config/LoggerConfig.php#L205-L220 | train |
orchestral/kernel | src/Http/FormRequest.php | FormRequest.setupValidationScenario | protected function setupValidationScenario()
{
$current = $this->method();
$available = [
'POST' => 'store',
'PUT' => 'update',
'DELETE' => 'destroy',
];
if (in_array($current, $available)) {
$this->onValidationScenario($available[$current]);
}
} | php | protected function setupValidationScenario()
{
$current = $this->method();
$available = [
'POST' => 'store',
'PUT' => 'update',
'DELETE' => 'destroy',
];
if (in_array($current, $available)) {
$this->onValidationScenario($available[$current]);
}
} | [
"protected",
"function",
"setupValidationScenario",
"(",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"method",
"(",
")",
";",
"$",
"available",
"=",
"[",
"'POST'",
"=>",
"'store'",
",",
"'PUT'",
"=>",
"'update'",
",",
"'DELETE'",
"=>",
"'destroy'",
... | Setup validation scenario based on request method.
@return void | [
"Setup",
"validation",
"scenario",
"based",
"on",
"request",
"method",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/FormRequest.php#L45-L57 | train |
melisplatform/melis-core | src/Controller/MelisFlashMessengerController.php | MelisFlashMessengerController.headerFlashMessengerAction | public function headerFlashMessengerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$flashMessenger = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->flashMessages = $this->getflashMessageAction();
return $view;
} | php | public function headerFlashMessengerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$flashMessenger = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->flashMessages = $this->getflashMessageAction();
return $view;
} | [
"public",
"function",
"headerFlashMessengerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"flashMessenger",
"=",
"$",
"this",
"->",
"getServiceLocator",
"... | Renders the Flash Messenger view in Melis CMS
@return \Zend\View\Model\ViewModel | [
"Renders",
"the",
"Flash",
"Messenger",
"view",
"in",
"Melis",
"CMS"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisFlashMessengerController.php#L28-L38 | train |
melisplatform/melis-core | src/Controller/MelisFlashMessengerController.php | MelisFlashMessengerController.getflashMessageAction | public function getflashMessageAction()
{
// translator service
$translator = $this->serviceLocator->get('translator');
// tool service
$tool = $this->getServiceLocator()->get('MelisCoretool');
// flash messenger service
$flashMessenger = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$flashMessages = Json::decode($flashMessenger->getFlashMessengerMessages());
// flashMessages array, re-stored so we can apply translation to its content
$fmArray = array();
$fmCtr = 0;
if($flashMessages)
{
foreach($flashMessages as $fmKey => $fmValues) {
$title = $translator->translate($fmValues->title);
$message = $translator->translate($fmValues->message);
$fmArray[] = array(
'title' => ($title),
'message' => ($message),
'image' => $fmValues->image,
'time' => $fmValues->time,
'date' => $fmValues->date,
'date_trans' => $fmValues->date_trans,
);
}
}
return new JsonModel(array(
'flashMessage' => $fmArray,
));
} | php | public function getflashMessageAction()
{
// translator service
$translator = $this->serviceLocator->get('translator');
// tool service
$tool = $this->getServiceLocator()->get('MelisCoretool');
// flash messenger service
$flashMessenger = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$flashMessages = Json::decode($flashMessenger->getFlashMessengerMessages());
// flashMessages array, re-stored so we can apply translation to its content
$fmArray = array();
$fmCtr = 0;
if($flashMessages)
{
foreach($flashMessages as $fmKey => $fmValues) {
$title = $translator->translate($fmValues->title);
$message = $translator->translate($fmValues->message);
$fmArray[] = array(
'title' => ($title),
'message' => ($message),
'image' => $fmValues->image,
'time' => $fmValues->time,
'date' => $fmValues->date,
'date_trans' => $fmValues->date_trans,
);
}
}
return new JsonModel(array(
'flashMessage' => $fmArray,
));
} | [
"public",
"function",
"getflashMessageAction",
"(",
")",
"{",
"// translator service",
"$",
"translator",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'translator'",
")",
";",
"// tool service",
"$",
"tool",
"=",
"$",
"this",
"->",
"getServiceLoc... | Returns the flash messages content
@return \Zend\View\Model\JsonModel | [
"Returns",
"the",
"flash",
"messages",
"content"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisFlashMessengerController.php#L83-L119 | train |
melisplatform/melis-core | src/Controller/MelisFlashMessengerController.php | MelisFlashMessengerController.logAction | public function logAction()
{
$flashMessenger = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$success = $this->params()->fromRoute('success', $this->params()->fromQuery('success', ''));
$title = $this->params()->fromRoute('textTitle', $this->params()->fromQuery('textTitle', ''));
$message = $this->params()->fromRoute('textMessage', $this->params()->fromQuery('textMessage', ''));
$typeCode = $this->params()->fromRoute('typeCode', $this->params()->fromQuery('typeCode', ''));
$itemId = $this->params()->fromRoute('itemId', $this->params()->fromQuery('itemId', ''));
$img = $success == 1 ? $flashMessenger::INFO : $flashMessenger::WARNING;
$flashMessenger->addToFlashMessenger($title, $message, $img);
$logSrv = $this->getServiceLocator()->get('MelisCoreLogService');
$logSrv->saveLog($title, $message, $success, $typeCode, $itemId);
} | php | public function logAction()
{
$flashMessenger = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$success = $this->params()->fromRoute('success', $this->params()->fromQuery('success', ''));
$title = $this->params()->fromRoute('textTitle', $this->params()->fromQuery('textTitle', ''));
$message = $this->params()->fromRoute('textMessage', $this->params()->fromQuery('textMessage', ''));
$typeCode = $this->params()->fromRoute('typeCode', $this->params()->fromQuery('typeCode', ''));
$itemId = $this->params()->fromRoute('itemId', $this->params()->fromQuery('itemId', ''));
$img = $success == 1 ? $flashMessenger::INFO : $flashMessenger::WARNING;
$flashMessenger->addToFlashMessenger($title, $message, $img);
$logSrv = $this->getServiceLocator()->get('MelisCoreLogService');
$logSrv->saveLog($title, $message, $success, $typeCode, $itemId);
} | [
"public",
"function",
"logAction",
"(",
")",
"{",
"$",
"flashMessenger",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreFlashMessenger'",
")",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fr... | Logs into the flash messenger service | [
"Logs",
"into",
"the",
"flash",
"messenger",
"service"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisFlashMessengerController.php#L124-L140 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Script/PathScriptTrait.php | PathScriptTrait.processMultiplePaths | public function processMultiplePaths($paths)
{
$paths = $this->parseAsArray($paths);
$paths = array_map([ $this, 'filterPath' ], $paths);
$paths = array_filter($paths, [ $this, 'pathExists' ]);
if ($paths === false) {
throw new InvalidArgumentException('Received invalid paths.');
}
if (empty($paths)) {
throw new InvalidArgumentException('Received empty paths.');
}
return $paths;
} | php | public function processMultiplePaths($paths)
{
$paths = $this->parseAsArray($paths);
$paths = array_map([ $this, 'filterPath' ], $paths);
$paths = array_filter($paths, [ $this, 'pathExists' ]);
if ($paths === false) {
throw new InvalidArgumentException('Received invalid paths.');
}
if (empty($paths)) {
throw new InvalidArgumentException('Received empty paths.');
}
return $paths;
} | [
"public",
"function",
"processMultiplePaths",
"(",
"$",
"paths",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"parseAsArray",
"(",
"$",
"paths",
")",
";",
"$",
"paths",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'filterPath'",
"]",
",",
"$",
"... | Process multiple paths.
@param string|string[] $paths One or many paths to scan.
@throws InvalidArgumentException If the paths are invalid.
@return string[] | [
"Process",
"multiple",
"paths",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/PathScriptTrait.php#L38-L53 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Script/PathScriptTrait.php | PathScriptTrait.pathExists | public function pathExists($path)
{
if (!is_string($path)) {
throw new InvalidArgumentException('The path must be a string.');
}
return $this->globRecursive($this->basePath().'/'.$path, GLOB_BRACE);
} | php | public function pathExists($path)
{
if (!is_string($path)) {
throw new InvalidArgumentException('The path must be a string.');
}
return $this->globRecursive($this->basePath().'/'.$path, GLOB_BRACE);
} | [
"public",
"function",
"pathExists",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The path must be a string.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"glob... | Determine if the path exists.
@param string $path Path to the file or directory.
@throws InvalidArgumentException If the path is invalid.
@return boolean Returns TRUE if the path exists. | [
"Determine",
"if",
"the",
"path",
"exists",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/PathScriptTrait.php#L62-L69 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Script/PathScriptTrait.php | PathScriptTrait.filterPath | public function filterPath($path, $trim = null)
{
if (!is_string($path)) {
throw new InvalidArgumentException('The path must be a string.');
}
if ($trim === null && defined(get_called_class().'::DIRECTORY_SEPARATORS')) {
$trim = static::DIRECTORY_SEPARATORS;
}
if ($trim) {
if (!is_string($trim)) {
throw new InvalidArgumentException(
'The characters to strip must be a string or use static::DIRECTORY_SEPARATORS.'
);
}
$path = trim($path, $trim);
}
return trim($path);
} | php | public function filterPath($path, $trim = null)
{
if (!is_string($path)) {
throw new InvalidArgumentException('The path must be a string.');
}
if ($trim === null && defined(get_called_class().'::DIRECTORY_SEPARATORS')) {
$trim = static::DIRECTORY_SEPARATORS;
}
if ($trim) {
if (!is_string($trim)) {
throw new InvalidArgumentException(
'The characters to strip must be a string or use static::DIRECTORY_SEPARATORS.'
);
}
$path = trim($path, $trim);
}
return trim($path);
} | [
"public",
"function",
"filterPath",
"(",
"$",
"path",
",",
"$",
"trim",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The path must be a string.'",
")",
";",
"}",
"... | Filter the given path.
Trims leading and trailing directory paths
@param string $path Path to the file or directory.
@param string|null $trim The characters to strip from the $path.
@throws InvalidArgumentException If the path is invalid.
@return string Returns the filtered path. | [
"Filter",
"the",
"given",
"path",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/PathScriptTrait.php#L81-L102 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Script/PathScriptTrait.php | PathScriptTrait.filterWritablePath | public function filterWritablePath($path, $name = null)
{
if ($name === null && defined(get_called_class().'::DEFAULT_BASENAME')) {
$name = static::DEFAULT_BASENAME;
}
if (!is_string($name)) {
throw new InvalidArgumentException(
'The target file name must be a string or use static::DEFAULT_BASENAME.'
);
}
$path = $this->filterPath($path);
$test = $this->basePath().'/'.$path;
if (is_dir($test)) {
if (is_writable($test)) {
$path .= '/'.$name;
} else {
throw new InvalidArgumentException('The target path is not writeable.');
}
} elseif (is_file($test)) {
if (!is_writable($test)) {
throw new InvalidArgumentException('The target file is not writeable.');
}
} else {
$info = pathinfo($path);
$path = $this->filterWritablePath($info['dirname'], $info['basename']);
}
return $path;
} | php | public function filterWritablePath($path, $name = null)
{
if ($name === null && defined(get_called_class().'::DEFAULT_BASENAME')) {
$name = static::DEFAULT_BASENAME;
}
if (!is_string($name)) {
throw new InvalidArgumentException(
'The target file name must be a string or use static::DEFAULT_BASENAME.'
);
}
$path = $this->filterPath($path);
$test = $this->basePath().'/'.$path;
if (is_dir($test)) {
if (is_writable($test)) {
$path .= '/'.$name;
} else {
throw new InvalidArgumentException('The target path is not writeable.');
}
} elseif (is_file($test)) {
if (!is_writable($test)) {
throw new InvalidArgumentException('The target file is not writeable.');
}
} else {
$info = pathinfo($path);
$path = $this->filterWritablePath($info['dirname'], $info['basename']);
}
return $path;
} | [
"public",
"function",
"filterWritablePath",
"(",
"$",
"path",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
"&&",
"defined",
"(",
"get_called_class",
"(",
")",
".",
"'::DEFAULT_BASENAME'",
")",
")",
"{",
"$",
"name",
"... | Filter the given path to be writable.
@param string $path A writable path to a file or directory.
@param string|null $name The target file name.
@throws InvalidArgumentException If the path is invalid.
@return string Returns the filtered path. | [
"Filter",
"the",
"given",
"path",
"to",
"be",
"writable",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/PathScriptTrait.php#L112-L143 | train |
locomotivemtl/charcoal-app | src/Charcoal/App/Script/PathScriptTrait.php | PathScriptTrait.globRecursive | public function globRecursive($pattern, $flags = 0)
{
$maxDepth = $this->maxDepth();
$depthKey = strval($maxDepth);
if (isset(static::$globCache[$pattern][$depthKey])) {
return static::$globCache[$pattern][$depthKey];
}
$depth = 1;
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) {
$files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
$depth++;
if ($maxDepth > 0 && $depth >= $maxDepth) {
break;
}
}
static::$globCache[$pattern][$depthKey] = array_filter($files, 'is_file');
return $files;
} | php | public function globRecursive($pattern, $flags = 0)
{
$maxDepth = $this->maxDepth();
$depthKey = strval($maxDepth);
if (isset(static::$globCache[$pattern][$depthKey])) {
return static::$globCache[$pattern][$depthKey];
}
$depth = 1;
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) {
$files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
$depth++;
if ($maxDepth > 0 && $depth >= $maxDepth) {
break;
}
}
static::$globCache[$pattern][$depthKey] = array_filter($files, 'is_file');
return $files;
} | [
"public",
"function",
"globRecursive",
"(",
"$",
"pattern",
",",
"$",
"flags",
"=",
"0",
")",
"{",
"$",
"maxDepth",
"=",
"$",
"this",
"->",
"maxDepth",
"(",
")",
";",
"$",
"depthKey",
"=",
"strval",
"(",
"$",
"maxDepth",
")",
";",
"if",
"(",
"isset... | Recursively find pathnames matching a pattern.
@see http://in.php.net/manual/en/function.glob.php#106595
@param string $pattern The search pattern.
@param integer $flags Bitmask of {@see glob()} options.
@return array | [
"Recursively",
"find",
"pathnames",
"matching",
"a",
"pattern",
"."
] | d25bdab08d40dda83c71b770c59e3b469e0ebfbc | https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Script/PathScriptTrait.php#L153-L175 | train |
melisplatform/melis-core | src/View/Helper/MelisModal.php | MelisModal.setTabContent | public function setTabContent(array $tab)
{
if($tab && is_array($tab)) {
foreach($tab as $attrib => $values)
{
$this->_tabs .= '<li><a href="#'.$values['id'].'" class="'.$values['class'].'" data-toggle="tab"><i></i><span class="strong">'.$values['tab-header'].'</span>'.$values['tab-text'].'</a></li>';
}
$this->setContent($tab);
}
} | php | public function setTabContent(array $tab)
{
if($tab && is_array($tab)) {
foreach($tab as $attrib => $values)
{
$this->_tabs .= '<li><a href="#'.$values['id'].'" class="'.$values['class'].'" data-toggle="tab"><i></i><span class="strong">'.$values['tab-header'].'</span>'.$values['tab-text'].'</a></li>';
}
$this->setContent($tab);
}
} | [
"public",
"function",
"setTabContent",
"(",
"array",
"$",
"tab",
")",
"{",
"if",
"(",
"$",
"tab",
"&&",
"is_array",
"(",
"$",
"tab",
")",
")",
"{",
"foreach",
"(",
"$",
"tab",
"as",
"$",
"attrib",
"=>",
"$",
"values",
")",
"{",
"$",
"this",
"->",... | Sets a single tab in a modal without an active tab
@param array $tab | [
"Sets",
"a",
"single",
"tab",
"in",
"a",
"modal",
"without",
"an",
"active",
"tab"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/View/Helper/MelisModal.php#L105-L115 | train |
melisplatform/melis-core | src/View/Helper/MelisModal.php | MelisModal.getTabPosition | protected function getTabPosition(array $tabs, $tabValue)
{
$position = 0;
$ctr = 0;
foreach($tabs as $keys => $values)
{
if($keys == $tabValue)
{
$position = $ctr;
}
$ctr++;
}
return $position;
} | php | protected function getTabPosition(array $tabs, $tabValue)
{
$position = 0;
$ctr = 0;
foreach($tabs as $keys => $values)
{
if($keys == $tabValue)
{
$position = $ctr;
}
$ctr++;
}
return $position;
} | [
"protected",
"function",
"getTabPosition",
"(",
"array",
"$",
"tabs",
",",
"$",
"tabValue",
")",
"{",
"$",
"position",
"=",
"0",
";",
"$",
"ctr",
"=",
"0",
";",
"foreach",
"(",
"$",
"tabs",
"as",
"$",
"keys",
"=>",
"$",
"values",
")",
"{",
"if",
... | Returns the position of the Tab you want to
be selected.
@param array $tabs
@param String $tabValue
@return int | [
"Returns",
"the",
"position",
"of",
"the",
"Tab",
"you",
"want",
"to",
"be",
"selected",
"."
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/View/Helper/MelisModal.php#L160-L173 | train |
melisplatform/melis-core | src/View/Helper/MelisModal.php | MelisModal.setContents | protected function setContents(array $contents)
{
$loopCtr = 0;
if($contents && is_array($contents))
{
foreach($contents as $attrib => $values)
{
if($this->_defaultTab == $loopCtr)
{
$this->_contents .= '<div class="tab-pane active" id="'.$values['id'].'"><div class="row"><div class="col-md-12">'.$values['content'].'</div></div></div>';
}
else
{
$this->_contents .= '<div class="tab-pane" id="'.$values['id'].'"><div class="row"><div class="col-md-12">'.$values['content'].'</div></div></div>';
}
$loopCtr++;
}
}
} | php | protected function setContents(array $contents)
{
$loopCtr = 0;
if($contents && is_array($contents))
{
foreach($contents as $attrib => $values)
{
if($this->_defaultTab == $loopCtr)
{
$this->_contents .= '<div class="tab-pane active" id="'.$values['id'].'"><div class="row"><div class="col-md-12">'.$values['content'].'</div></div></div>';
}
else
{
$this->_contents .= '<div class="tab-pane" id="'.$values['id'].'"><div class="row"><div class="col-md-12">'.$values['content'].'</div></div></div>';
}
$loopCtr++;
}
}
} | [
"protected",
"function",
"setContents",
"(",
"array",
"$",
"contents",
")",
"{",
"$",
"loopCtr",
"=",
"0",
";",
"if",
"(",
"$",
"contents",
"&&",
"is_array",
"(",
"$",
"contents",
")",
")",
"{",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"attrib",
"... | Sets the contents of each Modal Tab
@param array $contents | [
"Sets",
"the",
"contents",
"of",
"each",
"Modal",
"Tab"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/View/Helper/MelisModal.php#L179-L199 | train |
melisplatform/melis-core | src/View/Helper/MelisModal.php | MelisModal.setContent | protected function setContent(array $contents)
{
if($contents && is_array($contents))
{
foreach($contents as $attrib => $values)
{
$this->_contents .= '<div class="tab-pane" id="'.$values['id'].'"><div class="row"><div class="col-md-12">'.$values['content'].'</div></div></div>';
}
}
} | php | protected function setContent(array $contents)
{
if($contents && is_array($contents))
{
foreach($contents as $attrib => $values)
{
$this->_contents .= '<div class="tab-pane" id="'.$values['id'].'"><div class="row"><div class="col-md-12">'.$values['content'].'</div></div></div>';
}
}
} | [
"protected",
"function",
"setContent",
"(",
"array",
"$",
"contents",
")",
"{",
"if",
"(",
"$",
"contents",
"&&",
"is_array",
"(",
"$",
"contents",
")",
")",
"{",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"attrib",
"=>",
"$",
"values",
")",
"{",
"$... | Sets the content of a specific tab
@param array $contents | [
"Sets",
"the",
"content",
"of",
"a",
"specific",
"tab"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/View/Helper/MelisModal.php#L205-L215 | train |
melisplatform/melis-core | src/View/Helper/MelisModal.php | MelisModal.renderModal | public function renderModal()
{
$this->_modal = '
<div class="tooltabmodal modal fade" id="'.$this->getModalId().'" aria-hidden="true" style="display: none; " '. $this->getAttributes() . '>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body padding-none">
<div class="wizard">
<div class="widget widget-tabs widget-tabs-double widget-tabs-responsive margin-none border-none">
'. $this->getTabs() .'
'. $this->getContents() .'
</div>
</div>
</div>
'.$this->getCloseButton().'
</div>
</div>
</div>';
return $this->_modal;
} | php | public function renderModal()
{
$this->_modal = '
<div class="tooltabmodal modal fade" id="'.$this->getModalId().'" aria-hidden="true" style="display: none; " '. $this->getAttributes() . '>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body padding-none">
<div class="wizard">
<div class="widget widget-tabs widget-tabs-double widget-tabs-responsive margin-none border-none">
'. $this->getTabs() .'
'. $this->getContents() .'
</div>
</div>
</div>
'.$this->getCloseButton().'
</div>
</div>
</div>';
return $this->_modal;
} | [
"public",
"function",
"renderModal",
"(",
")",
"{",
"$",
"this",
"->",
"_modal",
"=",
"'\n <div class=\"tooltabmodal modal fade\" id=\"'",
".",
"$",
"this",
"->",
"getModalId",
"(",
")",
".",
"'\" aria-hidden=\"true\" style=\"display: none; \" '",
".",
"$",
"this... | Renders all config that has been set to create a modal
@return string | [
"Renders",
"all",
"config",
"that",
"has",
"been",
"set",
"to",
"create",
"a",
"modal"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/View/Helper/MelisModal.php#L256-L276 | train |
orchestral/kernel | src/Http/RouteResolver.php | RouteResolver.integrateWithExtension | protected function integrateWithExtension(Application $app): void
{
if ($app->bound('orchestra.extension')) {
$this->extension = $app->make('orchestra.extension');
}
if ($app->bound('orchestra.extension.status')) {
$this->status = $app->make('orchestra.extension.status');
}
} | php | protected function integrateWithExtension(Application $app): void
{
if ($app->bound('orchestra.extension')) {
$this->extension = $app->make('orchestra.extension');
}
if ($app->bound('orchestra.extension.status')) {
$this->status = $app->make('orchestra.extension.status');
}
} | [
"protected",
"function",
"integrateWithExtension",
"(",
"Application",
"$",
"app",
")",
":",
"void",
"{",
"if",
"(",
"$",
"app",
"->",
"bound",
"(",
"'orchestra.extension'",
")",
")",
"{",
"$",
"this",
"->",
"extension",
"=",
"$",
"app",
"->",
"make",
"(... | Integrate with Orchestra Extension.
@param \Illuminate\Contracts\Foundation\Application $app
@return void | [
"Integrate",
"with",
"Orchestra",
"Extension",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/RouteResolver.php#L72-L81 | train |
orchestral/kernel | src/Http/RouteResolver.php | RouteResolver.generateRouteByName | protected function generateRouteByName(string $name, string $default)
{
if (is_null($this->extension)) {
return $default;
}
return $this->extension->route($name, $default);
} | php | protected function generateRouteByName(string $name, string $default)
{
if (is_null($this->extension)) {
return $default;
}
return $this->extension->route($name, $default);
} | [
"protected",
"function",
"generateRouteByName",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"default",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"extension",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"-... | Generate route by name.
@param string $name
@param string $default
@return \Orchestra\Contracts\Extension\UrlGenerator | [
"Generate",
"route",
"by",
"name",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/RouteResolver.php#L190-L197 | train |
orchestral/kernel | src/Http/RouteResolver.php | RouteResolver.prepareHttpQueryString | protected function prepareHttpQueryString(string $query, array $appends = []): string
{
if (! empty($appends)) {
$query .= (! empty($query) ? '&' : '').http_build_query($appends);
}
return $query;
} | php | protected function prepareHttpQueryString(string $query, array $appends = []): string
{
if (! empty($appends)) {
$query .= (! empty($query) ? '&' : '').http_build_query($appends);
}
return $query;
} | [
"protected",
"function",
"prepareHttpQueryString",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"appends",
"=",
"[",
"]",
")",
":",
"string",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"appends",
")",
")",
"{",
"$",
"query",
".=",
"(",
"!",
"empty",
... | Prepare HTTP query string.
@param string $query
@param array $appends
@return string | [
"Prepare",
"HTTP",
"query",
"string",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/RouteResolver.php#L240-L247 | train |
orchestral/kernel | src/Http/RouteResolver.php | RouteResolver.getCsrfToken | protected function getCsrfToken(): ?string
{
if (is_null($this->csrfToken)) {
$this->csrfToken = $this->app->make('session')->token();
}
return $this->csrfToken;
} | php | protected function getCsrfToken(): ?string
{
if (is_null($this->csrfToken)) {
$this->csrfToken = $this->app->make('session')->token();
}
return $this->csrfToken;
} | [
"protected",
"function",
"getCsrfToken",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"csrfToken",
")",
")",
"{",
"$",
"this",
"->",
"csrfToken",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'session'",
")",
... | Get CSRF Token.
@return string|null | [
"Get",
"CSRF",
"Token",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/RouteResolver.php#L254-L261 | train |
melisplatform/melis-core | src/Service/MelisPhpUnitToolService.php | MelisPhpUnitToolService.init | public function init($moduleName, $moduleTestName, $unitTestPath = 'test')
{
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$modulePath = $moduleSvc->getModulePath($moduleName);
$bootstrapSavePath = $modulePath.'/'.$unitTestPath.'/Bootstrap.php';
$xmlSavePath = $modulePath.'/'.$unitTestPath.'/phpunit.xml';
$moduleTestSavePath = $modulePath.'/'.$unitTestPath.'/'.$moduleTestName.'/Controller';
$testSavePath = $modulePath.'/'.$unitTestPath;
$this->setAppConfig();
if(file_exists($modulePath) && file_exists($testSavePath)) {
$bootstrapTemplate = $_SERVER['DOCUMENT_ROOT'] . '/../test/tpl/BootstrapTemplate';
$puControllerTemplate = $_SERVER['DOCUMENT_ROOT'] . '/../test/tpl/PHPUnitControllTest';
$bootstrapContent = '';
$xmlContent = '';
if(file_exists($bootstrapTemplate)) {
$bootstrapContent = file_get_contents($bootstrapTemplate);
$bootstrapContent = sprintf($bootstrapContent, $moduleTestName);
file_put_contents($bootstrapSavePath, $bootstrapContent);
$xml = $_SERVER['DOCUMENT_ROOT'].'/../test/tpl/phpunitxmlTemplate';
if(file_exists($xml)) {
$xmlContent = file_get_contents($xml);
$xmlContent = str_replace('{{moduleName}}', $moduleTestName, $xmlContent);
file_put_contents($xmlSavePath, $xmlContent);
}
if(!file_exists($moduleTestSavePath)) {
mkdir($moduleTestSavePath, 0777, true);
$tmpcontrollerName = explode("Test", $moduleTestName);
if(is_array($tmpcontrollerName) && !empty($tmpcontrollerName)) {
$controllerName = $tmpcontrollerName[0] . 'ControllerTest';
if(!file_exists($moduleTestSavePath.'/'.$controllerName.'.php')) {
$ctrlTpl = file_get_contents($puControllerTemplate);
$ctrlTpl = str_replace(array(
'{{moduleTestName}}',
'{{moduleTestControllerName}}',
'{{tableFunctions}}',
'{{moduleName}}'
), array($moduleTestName, $controllerName, $this->getDbMethods($moduleName), $moduleName), $ctrlTpl);
file_put_contents($moduleTestSavePath.'/'.$controllerName.'.php', $ctrlTpl);
}
}
}
}
}
else {
mkdir($testSavePath, 0777, true);
$this->init($moduleName, $moduleTestName, $unitTestPath);
}
// Make sure the files are existing
if(file_exists($bootstrapSavePath) && file_exists($xmlSavePath) && file_exists($moduleTestSavePath)) {
return true;
}
return false;
} | php | public function init($moduleName, $moduleTestName, $unitTestPath = 'test')
{
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$modulePath = $moduleSvc->getModulePath($moduleName);
$bootstrapSavePath = $modulePath.'/'.$unitTestPath.'/Bootstrap.php';
$xmlSavePath = $modulePath.'/'.$unitTestPath.'/phpunit.xml';
$moduleTestSavePath = $modulePath.'/'.$unitTestPath.'/'.$moduleTestName.'/Controller';
$testSavePath = $modulePath.'/'.$unitTestPath;
$this->setAppConfig();
if(file_exists($modulePath) && file_exists($testSavePath)) {
$bootstrapTemplate = $_SERVER['DOCUMENT_ROOT'] . '/../test/tpl/BootstrapTemplate';
$puControllerTemplate = $_SERVER['DOCUMENT_ROOT'] . '/../test/tpl/PHPUnitControllTest';
$bootstrapContent = '';
$xmlContent = '';
if(file_exists($bootstrapTemplate)) {
$bootstrapContent = file_get_contents($bootstrapTemplate);
$bootstrapContent = sprintf($bootstrapContent, $moduleTestName);
file_put_contents($bootstrapSavePath, $bootstrapContent);
$xml = $_SERVER['DOCUMENT_ROOT'].'/../test/tpl/phpunitxmlTemplate';
if(file_exists($xml)) {
$xmlContent = file_get_contents($xml);
$xmlContent = str_replace('{{moduleName}}', $moduleTestName, $xmlContent);
file_put_contents($xmlSavePath, $xmlContent);
}
if(!file_exists($moduleTestSavePath)) {
mkdir($moduleTestSavePath, 0777, true);
$tmpcontrollerName = explode("Test", $moduleTestName);
if(is_array($tmpcontrollerName) && !empty($tmpcontrollerName)) {
$controllerName = $tmpcontrollerName[0] . 'ControllerTest';
if(!file_exists($moduleTestSavePath.'/'.$controllerName.'.php')) {
$ctrlTpl = file_get_contents($puControllerTemplate);
$ctrlTpl = str_replace(array(
'{{moduleTestName}}',
'{{moduleTestControllerName}}',
'{{tableFunctions}}',
'{{moduleName}}'
), array($moduleTestName, $controllerName, $this->getDbMethods($moduleName), $moduleName), $ctrlTpl);
file_put_contents($moduleTestSavePath.'/'.$controllerName.'.php', $ctrlTpl);
}
}
}
}
}
else {
mkdir($testSavePath, 0777, true);
$this->init($moduleName, $moduleTestName, $unitTestPath);
}
// Make sure the files are existing
if(file_exists($bootstrapSavePath) && file_exists($xmlSavePath) && file_exists($moduleTestSavePath)) {
return true;
}
return false;
} | [
"public",
"function",
"init",
"(",
"$",
"moduleName",
",",
"$",
"moduleTestName",
",",
"$",
"unitTestPath",
"=",
"'test'",
")",
"{",
"$",
"moduleSvc",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'ModulesService'",
")",
";",
... | Bootstrap.php file will be created inside the test folder
@param String $moduleName
@param String $testModuleName
@param String $unitTestPath | [
"Bootstrap",
".",
"php",
"file",
"will",
"be",
"created",
"inside",
"the",
"test",
"folder"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisPhpUnitToolService.php#L67-L127 | train |
melisplatform/melis-core | src/Service/MelisPhpUnitToolService.php | MelisPhpUnitToolService.simplifyResultsView | private function simplifyResultsView($results)
{
$simplified = array();
if(is_array($results)) {
$simplified['tests'] = array();
$totalTests = 0;
$totalFailed = 0;
$totalSuccess = 0;
if(isset($results['testcase'])) {
$testcase = $results['testcase'];
$totalTests = (int) $results['tests'];
$totalFailed = (int) $results['failures'];
$totalSuccess = $totalTests - $totalFailed;
if($totalTests > 1) {
// loop through test cases
foreach($testcase as $count => $testChild) {
$status = 'success';
$message = '';
$type = '';
if(isset($testChild['failure'])) {
$status = 'failed';
$message = $testChild['failure']['_'];
$type = $testChild['failure']['type'];
}
if(isset($testChild['error'])) {
$status = 'failed';
$message = $testChild['error']['_'];
$type = $testChild['error']['type'];
}
$simplified['tests'][$count] = array(
'test' => pathinfo($testChild['file'])['filename'],
'name' => $testChild['name'],
'time' => $testChild['time'],
'status' => $status,
'message' => $message,
'type' => $type
);
}
}
else {
$status = 'success';
$message = '';
$type = '';
if(isset($testcase['failure'])) {
$status = 'failed';
$message = $testcase['failure']['_'];
$type = $testcase['failure']['type'];
}
if(isset($testcase['error'])) {
$status = 'failed';
$message = $testcase['error']['_'];
$type = $testcase['error']['type'];
}
$simplified['tests'][] = array(
'test' => isset($testcase['file']) ? pathinfo($testcase['file'])['filename'] : $testcase['name'],
'name' => $testcase['name'],
'time' => $testcase['time'],
'status' => $status,
'message' => $message,
'type' => $type
);
}
}
$simplified['summary'] = array(
'totalTests' => $totalTests,
'totalSuccess' => $totalSuccess,
'totalFailed' => $totalFailed
);
return $simplified;
}
else {
return 'No tests found!';
}
} | php | private function simplifyResultsView($results)
{
$simplified = array();
if(is_array($results)) {
$simplified['tests'] = array();
$totalTests = 0;
$totalFailed = 0;
$totalSuccess = 0;
if(isset($results['testcase'])) {
$testcase = $results['testcase'];
$totalTests = (int) $results['tests'];
$totalFailed = (int) $results['failures'];
$totalSuccess = $totalTests - $totalFailed;
if($totalTests > 1) {
// loop through test cases
foreach($testcase as $count => $testChild) {
$status = 'success';
$message = '';
$type = '';
if(isset($testChild['failure'])) {
$status = 'failed';
$message = $testChild['failure']['_'];
$type = $testChild['failure']['type'];
}
if(isset($testChild['error'])) {
$status = 'failed';
$message = $testChild['error']['_'];
$type = $testChild['error']['type'];
}
$simplified['tests'][$count] = array(
'test' => pathinfo($testChild['file'])['filename'],
'name' => $testChild['name'],
'time' => $testChild['time'],
'status' => $status,
'message' => $message,
'type' => $type
);
}
}
else {
$status = 'success';
$message = '';
$type = '';
if(isset($testcase['failure'])) {
$status = 'failed';
$message = $testcase['failure']['_'];
$type = $testcase['failure']['type'];
}
if(isset($testcase['error'])) {
$status = 'failed';
$message = $testcase['error']['_'];
$type = $testcase['error']['type'];
}
$simplified['tests'][] = array(
'test' => isset($testcase['file']) ? pathinfo($testcase['file'])['filename'] : $testcase['name'],
'name' => $testcase['name'],
'time' => $testcase['time'],
'status' => $status,
'message' => $message,
'type' => $type
);
}
}
$simplified['summary'] = array(
'totalTests' => $totalTests,
'totalSuccess' => $totalSuccess,
'totalFailed' => $totalFailed
);
return $simplified;
}
else {
return 'No tests found!';
}
} | [
"private",
"function",
"simplifyResultsView",
"(",
"$",
"results",
")",
"{",
"$",
"simplified",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"results",
")",
")",
"{",
"$",
"simplified",
"[",
"'tests'",
"]",
"=",
"array",
"(",
")",
";... | Simplifies the output of the PHPUnit result
@param $results
@return array|string | [
"Simplifies",
"the",
"output",
"of",
"the",
"PHPUnit",
"result"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisPhpUnitToolService.php#L227-L305 | train |
melisplatform/melis-core | src/Service/MelisPhpUnitToolService.php | MelisPhpUnitToolService.getPayload | public function getPayload($module, $methodName)
{
$payloads = array();
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$payloads = $config->getItem('diagnostic/'.$module.'/methods/'. $this->getMethodName($methodName) .'/payloads');
return $payloads;
} | php | public function getPayload($module, $methodName)
{
$payloads = array();
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$payloads = $config->getItem('diagnostic/'.$module.'/methods/'. $this->getMethodName($methodName) .'/payloads');
return $payloads;
} | [
"public",
"function",
"getPayload",
"(",
"$",
"module",
",",
"$",
"methodName",
")",
"{",
"$",
"payloads",
"=",
"array",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";... | Returns the payload data from the diagnostic.config
@param $module
@param $methodName
@return array | [
"Returns",
"the",
"payload",
"data",
"from",
"the",
"diagnostic",
".",
"config"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisPhpUnitToolService.php#L328-L337 | train |
melisplatform/melis-core | src/Controller/ModulesController.php | ModulesController.renderToolModulesAction | public function renderToolModulesAction()
{
$translator = $this->getServiceLocator()->get('translator');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$coreTool = $this->getServiceLocator()->get('MelisCoreTool');
$modules = $moduleSvc->getAllModules();
$melisKey = $this->params()->fromRoute('melisKey', '');
$noAccessPrompt = '';
if(!$this->hasAccess('meliscore_tool_user_module_management')) {
$noAccessPrompt = $translator->translate('tr_tool_no_access');
}
$request = $this->getRequest();
$domain = isset($get['domain']) ? $get['domain'] : null;
$scheme = isset($get['scheme']) ? $get['scheme'] : null;
$melisKey = $this->params()->fromRoute('melisKey', '');
$netStatus = $coreTool->isConnected();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->modules = serialize($modules);
$view->scheme = $scheme;
$view->domain = $domain;
$view->netStatus = $netStatus;
return $view;
} | php | public function renderToolModulesAction()
{
$translator = $this->getServiceLocator()->get('translator');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$coreTool = $this->getServiceLocator()->get('MelisCoreTool');
$modules = $moduleSvc->getAllModules();
$melisKey = $this->params()->fromRoute('melisKey', '');
$noAccessPrompt = '';
if(!$this->hasAccess('meliscore_tool_user_module_management')) {
$noAccessPrompt = $translator->translate('tr_tool_no_access');
}
$request = $this->getRequest();
$domain = isset($get['domain']) ? $get['domain'] : null;
$scheme = isset($get['scheme']) ? $get['scheme'] : null;
$melisKey = $this->params()->fromRoute('melisKey', '');
$netStatus = $coreTool->isConnected();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->modules = serialize($modules);
$view->scheme = $scheme;
$view->domain = $domain;
$view->netStatus = $netStatus;
return $view;
} | [
"public",
"function",
"renderToolModulesAction",
"(",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"moduleSvc",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"... | Main Tool Container
@return \Zend\View\Model\ViewModel | [
"Main",
"Tool",
"Container"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ModulesController.php#L42-L70 | train |
melisplatform/melis-core | src/Controller/ModulesController.php | ModulesController.renderToolModulesContentAction | public function renderToolModulesContentAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$zoneConfig = $this->params()->fromRoute('zoneconfig', array());
$modulesInfo = $this->getModuleSvc()->getModulesAndVersions();
$modules = $this->getModules();
//exclude MelisDemoCms cause it is SiteModule
// it will complicate some default layout/layout of the melis-core
unset($modules['MelisDemoCms']);
unset($modulesInfo['MelisDemoCms']);
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->modules = $modules;
$view->modulesInfo = $modulesInfo;
return $view;
} | php | public function renderToolModulesContentAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$zoneConfig = $this->params()->fromRoute('zoneconfig', array());
$modulesInfo = $this->getModuleSvc()->getModulesAndVersions();
$modules = $this->getModules();
//exclude MelisDemoCms cause it is SiteModule
// it will complicate some default layout/layout of the melis-core
unset($modules['MelisDemoCms']);
unset($modulesInfo['MelisDemoCms']);
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->modules = $modules;
$view->modulesInfo = $modulesInfo;
return $view;
} | [
"public",
"function",
"renderToolModulesContentAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"zoneConfig",
"=",
"$",
"this",
"->",
"params",
"(",
")",
... | Renders the content section of the tool
@return \Zend\View\Model\ViewModel | [
"Renders",
"the",
"content",
"section",
"of",
"the",
"tool"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ModulesController.php#L93-L112 | train |
melisplatform/melis-core | src/Controller/ModulesController.php | ModulesController.saveModuleChangesAction | public function saveModuleChangesAction()
{
$translator = $this->getServiceLocator()->get('translator');
$request = $this->getRequest();
$success = 0;
$textTitle = 'tr_meliscore_module_management_modules';
$textMessage = 'tr_meliscore_module_management_prompt_failed';
if($request->isPost()) {
$modules = $this->params()->fromPost();
$moduleLists = '';
$enabledModules = array();
$disabledModules = array();
foreach($modules as $moduleName => $moduleValue) {
if((int) $moduleValue == 1) {
$enabledModules[] = $moduleName;
}
}
$modules = $enabledModules;
$success = $this->createModuleLoaderFile($modules) === true ? 1 : 0;
if($success == 1) {
$textMessage = 'tr_meliscore_module_management_prompt_success';
}
}
$response = array(
'success' => $success,
'textTitle' => $translator->translate($textTitle),
'textMessage' => $translator->translate($textMessage),
);
$this->getEventManager()->trigger('meliscore_module_management_save_end', $this, $response);
return new JsonModel($response);
} | php | public function saveModuleChangesAction()
{
$translator = $this->getServiceLocator()->get('translator');
$request = $this->getRequest();
$success = 0;
$textTitle = 'tr_meliscore_module_management_modules';
$textMessage = 'tr_meliscore_module_management_prompt_failed';
if($request->isPost()) {
$modules = $this->params()->fromPost();
$moduleLists = '';
$enabledModules = array();
$disabledModules = array();
foreach($modules as $moduleName => $moduleValue) {
if((int) $moduleValue == 1) {
$enabledModules[] = $moduleName;
}
}
$modules = $enabledModules;
$success = $this->createModuleLoaderFile($modules) === true ? 1 : 0;
if($success == 1) {
$textMessage = 'tr_meliscore_module_management_prompt_success';
}
}
$response = array(
'success' => $success,
'textTitle' => $translator->translate($textTitle),
'textMessage' => $translator->translate($textMessage),
);
$this->getEventManager()->trigger('meliscore_module_management_save_end', $this, $response);
return new JsonModel($response);
} | [
"public",
"function",
"saveModuleChangesAction",
"(",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$"... | Saves the changes of the module modifications
@return JsonModel | [
"Saves",
"the",
"changes",
"of",
"the",
"module",
"modifications"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ModulesController.php#L131-L167 | train |
melisplatform/melis-core | src/Controller/ModulesController.php | ModulesController.getDependentsAction | public function getDependentsAction()
{
$success = 0;
$modules = array();
$request = $this->getRequest();
$message = 'tr_meliscore_module_management_no_dependencies';
$tool = $this->getServiceLocator()->get('MelisCoreTool');
if ($request->isPost()) {
$module = $tool->sanitize($request->getPost('module'));
if ($module) {
$modules = $this->getModuleSvc()->getChildDependencies($module);
if ($modules) {
$message = $tool->getTranslation('tr_meliscore_module_management_inactive_confirm', array($module, $module));
$success = 1;
}
}
}
$response = array(
'success' => $success,
'modules' => $modules,
'message' => $tool->getTranslation($message)
);
return new JsonModel($response);
} | php | public function getDependentsAction()
{
$success = 0;
$modules = array();
$request = $this->getRequest();
$message = 'tr_meliscore_module_management_no_dependencies';
$tool = $this->getServiceLocator()->get('MelisCoreTool');
if ($request->isPost()) {
$module = $tool->sanitize($request->getPost('module'));
if ($module) {
$modules = $this->getModuleSvc()->getChildDependencies($module);
if ($modules) {
$message = $tool->getTranslation('tr_meliscore_module_management_inactive_confirm', array($module, $module));
$success = 1;
}
}
}
$response = array(
'success' => $success,
'modules' => $modules,
'message' => $tool->getTranslation($message)
);
return new JsonModel($response);
} | [
"public",
"function",
"getDependentsAction",
"(",
")",
"{",
"$",
"success",
"=",
"0",
";",
"$",
"modules",
"=",
"array",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"message",
"=",
"'tr_meliscore_module_manage... | Returns the module that is dependent to the provided module
@return JsonModel | [
"Returns",
"the",
"module",
"that",
"is",
"dependent",
"to",
"the",
"provided",
"module"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/ModulesController.php#L238-L266 | train |
chillerlan/php-authenticator | src/AuthenticatorOptionsTrait.php | AuthenticatorOptionsTrait.set_digits | protected function set_digits(int $digits):void{
if(!in_array($digits, [6, 8], true)){
throw new AuthenticatorException('Invalid code length: '.$digits);
}
$this->digits = $digits;
} | php | protected function set_digits(int $digits):void{
if(!in_array($digits, [6, 8], true)){
throw new AuthenticatorException('Invalid code length: '.$digits);
}
$this->digits = $digits;
} | [
"protected",
"function",
"set_digits",
"(",
"int",
"$",
"digits",
")",
":",
"void",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"digits",
",",
"[",
"6",
",",
"8",
"]",
",",
"true",
")",
")",
"{",
"throw",
"new",
"AuthenticatorException",
"(",
"'Invali... | Sets the code length to either 6 or 8
@param int $digits
@return void
@throws \chillerlan\Authenticator\AuthenticatorException | [
"Sets",
"the",
"code",
"length",
"to",
"either",
"6",
"or",
"8"
] | 3d13f35038c4a71e9e101110f821ca7e0679f5ea | https://github.com/chillerlan/php-authenticator/blob/3d13f35038c4a71e9e101110f821ca7e0679f5ea/src/AuthenticatorOptionsTrait.php#L72-L79 | train |
chillerlan/php-authenticator | src/AuthenticatorOptionsTrait.php | AuthenticatorOptionsTrait.set_period | protected function set_period(int $period):void{
if($period < 15 || $period > 60){
throw new AuthenticatorException('Invalid period: '.$period);
}
$this->period = $period;
} | php | protected function set_period(int $period):void{
if($period < 15 || $period > 60){
throw new AuthenticatorException('Invalid period: '.$period);
}
$this->period = $period;
} | [
"protected",
"function",
"set_period",
"(",
"int",
"$",
"period",
")",
":",
"void",
"{",
"if",
"(",
"$",
"period",
"<",
"15",
"||",
"$",
"period",
">",
"60",
")",
"{",
"throw",
"new",
"AuthenticatorException",
"(",
"'Invalid period: '",
".",
"$",
"period... | Sets the period to a value between 10 and 60 seconds
@param int $period
@return void
@throws \chillerlan\Authenticator\AuthenticatorException | [
"Sets",
"the",
"period",
"to",
"a",
"value",
"between",
"10",
"and",
"60",
"seconds"
] | 3d13f35038c4a71e9e101110f821ca7e0679f5ea | https://github.com/chillerlan/php-authenticator/blob/3d13f35038c4a71e9e101110f821ca7e0679f5ea/src/AuthenticatorOptionsTrait.php#L89-L96 | train |
melisplatform/melis-core | src/Controller/UserController.php | UserController.retrievePageAction | public function retrievePageAction()
{
$configPath = 'meliscore/datas';
$melisConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$cfg = $melisConfig->getItemPerPlatform($configPath);
$pathAppConfigForm = '/meliscore/forms/meliscore_forgot';
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$melisLostPass = $this->getServiceLocator()->get('MelisCoreLostPassword');
$appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm);
$factory = new \Zend\Form\Factory();
$forgotForm = $factory->createForm($appConfigForm);
$translator = $this->getServiceLocator()->get('translator');
$this->getServiceLocator()->get('ViewHelperManager')->get('HeadTitle')->set($translator->translate('tr_meliscore_forgot_page_title'));
$view = new ViewModel();
$view->setVariable('meliscore_forgot', $forgotForm);
$view->setVariable('formFactory', $factory);
$view->setVariable('formConfig', $appConfigForm);
$this->layout()->schemes = $this->getSchemes();
return $view;
} | php | public function retrievePageAction()
{
$configPath = 'meliscore/datas';
$melisConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$cfg = $melisConfig->getItemPerPlatform($configPath);
$pathAppConfigForm = '/meliscore/forms/meliscore_forgot';
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$melisLostPass = $this->getServiceLocator()->get('MelisCoreLostPassword');
$appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm);
$factory = new \Zend\Form\Factory();
$forgotForm = $factory->createForm($appConfigForm);
$translator = $this->getServiceLocator()->get('translator');
$this->getServiceLocator()->get('ViewHelperManager')->get('HeadTitle')->set($translator->translate('tr_meliscore_forgot_page_title'));
$view = new ViewModel();
$view->setVariable('meliscore_forgot', $forgotForm);
$view->setVariable('formFactory', $factory);
$view->setVariable('formConfig', $appConfigForm);
$this->layout()->schemes = $this->getSchemes();
return $view;
} | [
"public",
"function",
"retrievePageAction",
"(",
")",
"{",
"$",
"configPath",
"=",
"'meliscore/datas'",
";",
"$",
"melisConfig",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"cfg",
"=",
"$",
"... | Renders to the Lost Password form
@return \Zend\View\Model\ViewModel | [
"Renders",
"to",
"the",
"Lost",
"Password",
"form"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/UserController.php#L55-L80 | train |
melisplatform/melis-core | src/Controller/UserController.php | UserController.lostPasswordRequestAction | public function lostPasswordRequestAction()
{
$pathAppConfigForm = '/meliscore/forms/meliscore_forgot';
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm);
$translator = $this->getServiceLocator()->get('translator');
$success = false;
$errors = array();
$message = '';
if($this->getRequest()->isPost())
{
$login = $this->getRequest()->getPost('usr_login');
$email = $this->getRequest()->getPost('usr_email');
$melisLostPass = $this->getServiceLocator()->get('MelisCoreLostPassword');
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$userData = $userTable->getDataByLoginAndEmail($login, $email);
$userData = $userData->current();
if($userData)
{
if($melisLostPass->userExists($login))
{
$success = $melisLostPass->addLostPassRequest($login, $email);
if($success)
{
$message = $translator->translate('tr_meliscore_email_lost_password_request_success');
}
else
{
$message = $translator->translate('tr_meliscore_email_lost_password_request_failed');
}
}
else
{
$message = $translator->translate('tr_meliscore_email_lost_password_request_failed');
}
}
else
{
$success = false;
$message = $translator->translate('tr_meliscore_email_failed');
}
}
return new JsonModel(array('success' => $success, 'message' => $message));
} | php | public function lostPasswordRequestAction()
{
$pathAppConfigForm = '/meliscore/forms/meliscore_forgot';
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$appConfigForm = $melisMelisCoreConfig->getItem($pathAppConfigForm);
$translator = $this->getServiceLocator()->get('translator');
$success = false;
$errors = array();
$message = '';
if($this->getRequest()->isPost())
{
$login = $this->getRequest()->getPost('usr_login');
$email = $this->getRequest()->getPost('usr_email');
$melisLostPass = $this->getServiceLocator()->get('MelisCoreLostPassword');
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$userData = $userTable->getDataByLoginAndEmail($login, $email);
$userData = $userData->current();
if($userData)
{
if($melisLostPass->userExists($login))
{
$success = $melisLostPass->addLostPassRequest($login, $email);
if($success)
{
$message = $translator->translate('tr_meliscore_email_lost_password_request_success');
}
else
{
$message = $translator->translate('tr_meliscore_email_lost_password_request_failed');
}
}
else
{
$message = $translator->translate('tr_meliscore_email_lost_password_request_failed');
}
}
else
{
$success = false;
$message = $translator->translate('tr_meliscore_email_failed');
}
}
return new JsonModel(array('success' => $success, 'message' => $message));
} | [
"public",
"function",
"lostPasswordRequestAction",
"(",
")",
"{",
"$",
"pathAppConfigForm",
"=",
"'/meliscore/forms/meliscore_forgot'",
";",
"$",
"melisMelisCoreConfig",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
... | Processes the lost password request
@return \Zend\View\Model\JsonModel | [
"Processes",
"the",
"lost",
"password",
"request"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/UserController.php#L86-L135 | train |
melisplatform/melis-core | src/Controller/UserController.php | UserController.setHashAction | protected function setHashAction() {
$hash = $this->params()->fromRoute('rhash', $this->params()->fromQuery('rhash',''));
$this->_hash = $hash;
} | php | protected function setHashAction() {
$hash = $this->params()->fromRoute('rhash', $this->params()->fromQuery('rhash',''));
$this->_hash = $hash;
} | [
"protected",
"function",
"setHashAction",
"(",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'rhash'",
",",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'rhash'",
",",
"''",
")",
")",
... | Retrieves the passed hash | [
"Retrieves",
"the",
"passed",
"hash"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/UserController.php#L349-L352 | train |
melisplatform/melis-core | public/js/filemanager/include/FtpClient.php | FtpClient.setPhpLimit | public function setPhpLimit($memory = null, $time_limit = 0, $ignore_user_abort = true)
{
if (null !== $memory) {
ini_set('memory_limit', $memory);
}
ignore_user_abort(true);
set_time_limit($time_limit);
return $this;
} | php | public function setPhpLimit($memory = null, $time_limit = 0, $ignore_user_abort = true)
{
if (null !== $memory) {
ini_set('memory_limit', $memory);
}
ignore_user_abort(true);
set_time_limit($time_limit);
return $this;
} | [
"public",
"function",
"setPhpLimit",
"(",
"$",
"memory",
"=",
"null",
",",
"$",
"time_limit",
"=",
"0",
",",
"$",
"ignore_user_abort",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"memory",
")",
"{",
"ini_set",
"(",
"'memory_limit'",
",",
"$",... | Overwrites the PHP limit
@param string|null $memory The memory limit, if null is not modified
@param int $time_limit The max execution time, unlimited by default
@param bool $ignore_user_abort Ignore user abort, true by default
@return FtpClient | [
"Overwrites",
"the",
"PHP",
"limit"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/include/FtpClient.php#L117-L127 | train |
melisplatform/melis-core | public/js/filemanager/include/FtpClient.php | FtpClient.nlist | public function nlist($directory = '.', $recursive = false, $filter = 'sort')
{
if (!$this->isDir($directory)) {
throw new FtpException('"'.$directory.'" is not a directory');
}
$files = $this->ftp->nlist($directory);
if ($files === false) {
throw new FtpException('Unable to list directory');
}
$result = array();
$dir_len = strlen($directory);
// if it's the current
if (false !== ($kdot = array_search('.', $files))) {
unset($files[$kdot]);
}
// if it's the parent
if(false !== ($kdot = array_search('..', $files))) {
unset($files[$kdot]);
}
if (!$recursive) {
foreach ($files as $file) {
$result[] = $directory.'/'.$file;
}
// working with the reference (behavior of several PHP sorting functions)
$filter($result);
return $result;
}
// utils for recursion
$flatten = function (array $arr) use (&$flatten) {
$flat = [];
foreach ($arr as $k => $v) {
if (is_array($v)) {
$flat = array_merge($flat, $flatten($v));
} else {
$flat[] = $v;
}
}
return $flat;
};
foreach ($files as $file) {
$file = $directory.'/'.$file;
// if contains the root path (behavior of the recursivity)
if (0 === strpos($file, $directory, $dir_len)) {
$file = substr($file, $dir_len);
}
if ($this->isDir($file)) {
$result[] = $file;
$items = $flatten($this->nlist($file, true, $filter));
foreach ($items as $item) {
$result[] = $item;
}
} else {
$result[] = $file;
}
}
$result = array_unique($result);
$filter($result);
return $result;
} | php | public function nlist($directory = '.', $recursive = false, $filter = 'sort')
{
if (!$this->isDir($directory)) {
throw new FtpException('"'.$directory.'" is not a directory');
}
$files = $this->ftp->nlist($directory);
if ($files === false) {
throw new FtpException('Unable to list directory');
}
$result = array();
$dir_len = strlen($directory);
// if it's the current
if (false !== ($kdot = array_search('.', $files))) {
unset($files[$kdot]);
}
// if it's the parent
if(false !== ($kdot = array_search('..', $files))) {
unset($files[$kdot]);
}
if (!$recursive) {
foreach ($files as $file) {
$result[] = $directory.'/'.$file;
}
// working with the reference (behavior of several PHP sorting functions)
$filter($result);
return $result;
}
// utils for recursion
$flatten = function (array $arr) use (&$flatten) {
$flat = [];
foreach ($arr as $k => $v) {
if (is_array($v)) {
$flat = array_merge($flat, $flatten($v));
} else {
$flat[] = $v;
}
}
return $flat;
};
foreach ($files as $file) {
$file = $directory.'/'.$file;
// if contains the root path (behavior of the recursivity)
if (0 === strpos($file, $directory, $dir_len)) {
$file = substr($file, $dir_len);
}
if ($this->isDir($file)) {
$result[] = $file;
$items = $flatten($this->nlist($file, true, $filter));
foreach ($items as $item) {
$result[] = $item;
}
} else {
$result[] = $file;
}
}
$result = array_unique($result);
$filter($result);
return $result;
} | [
"public",
"function",
"nlist",
"(",
"$",
"directory",
"=",
"'.'",
",",
"$",
"recursive",
"=",
"false",
",",
"$",
"filter",
"=",
"'sort'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isDir",
"(",
"$",
"directory",
")",
")",
"{",
"throw",
"new",
... | Returns a list of files in the given directory.
@param string $directory The directory, by default is "." the current directory
@param bool $recursive
@param callable $filter A callable to filter the result, by default is asort() PHP function.
The result is passed in array argument,
must take the argument by reference !
The callable should proceed with the reference array
because is the behavior of several PHP sorting
functions (by reference ensure directly the compatibility
with all PHP sorting functions).
@return array
@throws FtpException If unable to list the directory | [
"Returns",
"a",
"list",
"of",
"files",
"in",
"the",
"given",
"directory",
"."
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/include/FtpClient.php#L271-L349 | train |
melisplatform/melis-core | public/js/filemanager/include/FtpClient.php | FtpClient.parseRawList | public function parseRawList(array $rawlist)
{
$items = array();
$path = '';
foreach ($rawlist as $key => $child) {
$chunks = preg_split("/\s+/", $child);
if (isset($chunks[8]) && ($chunks[8] == '.' or $chunks[8] == '..')) {
continue;
}
if (count($chunks) === 1) {
$len = strlen($chunks[0]);
if ($len && $chunks[0][$len-1] == ':') {
$path = substr($chunks[0], 0, -1);
}
continue;
}
$item = [
'permissions' => $chunks[0],
'number' => $chunks[1],
'owner' => $chunks[2],
'group' => $chunks[3],
'size' => $chunks[4],
'month' => $chunks[5],
'day' => $chunks[6],
'time' => $chunks[7],
'name' => $chunks[8],
'type' => $this->rawToType($chunks[0]),
];
unset($chunks[0]);
unset($chunks[1]);
unset($chunks[2]);
unset($chunks[3]);
unset($chunks[4]);
unset($chunks[5]);
unset($chunks[6]);
unset($chunks[7]);
$item['name'] = implode(' ', $chunks);
if ($item['type'] == 'link') {
$item['target'] = $chunks[10]; // 9 is "->"
}
// if the key is not the path, behavior of ftp_rawlist() PHP function
if (is_int($key) || false === strpos($key, $item['name'])) {
array_splice($chunks, 0, 8);
$key = $item['type'].'#'
.($path ? $path.'/' : '')
.implode(" ", $chunks);
if ($item['type'] == 'link') {
// get the first part of 'link#the-link.ext -> /path/of/the/source.ext'
$exp = explode(' ->', $key);
$key = rtrim($exp[0]);
}
$items[$key] = $item;
} else {
// the key is the path, behavior of FtpClient::rawlist() method()
$items[$key] = $item;
}
}
return $items;
} | php | public function parseRawList(array $rawlist)
{
$items = array();
$path = '';
foreach ($rawlist as $key => $child) {
$chunks = preg_split("/\s+/", $child);
if (isset($chunks[8]) && ($chunks[8] == '.' or $chunks[8] == '..')) {
continue;
}
if (count($chunks) === 1) {
$len = strlen($chunks[0]);
if ($len && $chunks[0][$len-1] == ':') {
$path = substr($chunks[0], 0, -1);
}
continue;
}
$item = [
'permissions' => $chunks[0],
'number' => $chunks[1],
'owner' => $chunks[2],
'group' => $chunks[3],
'size' => $chunks[4],
'month' => $chunks[5],
'day' => $chunks[6],
'time' => $chunks[7],
'name' => $chunks[8],
'type' => $this->rawToType($chunks[0]),
];
unset($chunks[0]);
unset($chunks[1]);
unset($chunks[2]);
unset($chunks[3]);
unset($chunks[4]);
unset($chunks[5]);
unset($chunks[6]);
unset($chunks[7]);
$item['name'] = implode(' ', $chunks);
if ($item['type'] == 'link') {
$item['target'] = $chunks[10]; // 9 is "->"
}
// if the key is not the path, behavior of ftp_rawlist() PHP function
if (is_int($key) || false === strpos($key, $item['name'])) {
array_splice($chunks, 0, 8);
$key = $item['type'].'#'
.($path ? $path.'/' : '')
.implode(" ", $chunks);
if ($item['type'] == 'link') {
// get the first part of 'link#the-link.ext -> /path/of/the/source.ext'
$exp = explode(' ->', $key);
$key = rtrim($exp[0]);
}
$items[$key] = $item;
} else {
// the key is the path, behavior of FtpClient::rawlist() method()
$items[$key] = $item;
}
}
return $items;
} | [
"public",
"function",
"parseRawList",
"(",
"array",
"$",
"rawlist",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"$",
"path",
"=",
"''",
";",
"foreach",
"(",
"$",
"rawlist",
"as",
"$",
"key",
"=>",
"$",
"child",
")",
"{",
"$",
"chunks",
"... | Parse raw list.
@see FtpClient::rawlist()
@see FtpClient::scanDir()
@see FtpClient::dirSize()
@param array $rawlist
@return array | [
"Parse",
"raw",
"list",
"."
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/include/FtpClient.php#L761-L835 | train |
orchestral/kernel | src/Publisher/AssetManager.php | AssetManager.foundation | public function foundation(): bool
{
$path = \rtrim($this->app->basePath(), '/').'/vendor/orchestra/foundation/public';
if (! $this->app->make('files')->isDirectory($path)) {
return false;
}
try {
return $this->publish('orchestra/foundation', $path);
} catch (Exception $e) {
throw new FilePermissionException("Unable to publish [{$path}].");
}
} | php | public function foundation(): bool
{
$path = \rtrim($this->app->basePath(), '/').'/vendor/orchestra/foundation/public';
if (! $this->app->make('files')->isDirectory($path)) {
return false;
}
try {
return $this->publish('orchestra/foundation', $path);
} catch (Exception $e) {
throw new FilePermissionException("Unable to publish [{$path}].");
}
} | [
"public",
"function",
"foundation",
"(",
")",
":",
"bool",
"{",
"$",
"path",
"=",
"\\",
"rtrim",
"(",
"$",
"this",
"->",
"app",
"->",
"basePath",
"(",
")",
",",
"'/'",
")",
".",
"'/vendor/orchestra/foundation/public'",
";",
"if",
"(",
"!",
"$",
"this",... | Migrate Orchestra Platform.
@throws \Orchestra\Contracts\Publisher\FilePermissionException
@return bool | [
"Migrate",
"Orchestra",
"Platform",
"."
] | d4ebf0604e9aba6fe30813bc3446305157d93eb4 | https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Publisher/AssetManager.php#L81-L94 | train |
melisplatform/melis-core | src/Controller/LanguageController.php | LanguageController.headerLanguageAction | public function headerLanguageAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$tableLang = $this->getServiceLocator()->get('MelisCoreTableLang');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$datasLang = $tableLang->fetchAll();
// Get the locale from session
$container = new Container('meliscore');
$currentLangLocale = $container['melis-lang-locale'];
$currentLangLocale = explode('_', $currentLangLocale);
$currentLangLocale = $currentLangLocale[0];
// Get the langId from session
$container = new Container('meliscore');
$currentLangId = 1;
if (!empty($container['melis-lang-id']))
$currentLangId = $container['melis-lang-id'];
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->languages = $datasLang->toArray();
$view->currentLangId = $currentLangId;
$view->currentLangLocale = $currentLangLocale;
$view->flagImagePath = $moduleSvc->getModulePath('MelisCore').'/public/assets/images/lang/';
return $view;
} | php | public function headerLanguageAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$tableLang = $this->getServiceLocator()->get('MelisCoreTableLang');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$datasLang = $tableLang->fetchAll();
// Get the locale from session
$container = new Container('meliscore');
$currentLangLocale = $container['melis-lang-locale'];
$currentLangLocale = explode('_', $currentLangLocale);
$currentLangLocale = $currentLangLocale[0];
// Get the langId from session
$container = new Container('meliscore');
$currentLangId = 1;
if (!empty($container['melis-lang-id']))
$currentLangId = $container['melis-lang-id'];
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->languages = $datasLang->toArray();
$view->currentLangId = $currentLangId;
$view->currentLangLocale = $currentLangLocale;
$view->flagImagePath = $moduleSvc->getModulePath('MelisCore').'/public/assets/images/lang/';
return $view;
} | [
"public",
"function",
"headerLanguageAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"tableLang",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
... | Shows language button in right corner of header
@return \Zend\View\Model\ViewModel | [
"Shows",
"language",
"button",
"in",
"right",
"corner",
"of",
"header"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/LanguageController.php#L31-L59 | train |
melisplatform/melis-core | src/Controller/LanguageController.php | LanguageController.changeLanguageAction | public function changeLanguageAction()
{
$langId = $this->params()->fromQuery('langId', null);
$locale = '';
$success = true;
$errors = array();
if (empty($langId) || !is_numeric($langId) || $langId <= 0)
$success = false;
$melisLangTable = $this->serviceLocator->get('MelisCore\Model\Tables\MelisLangTable');
$melisUserTable = $this->serviceLocator->get('MelisCore\Model\Tables\MelisUserTable');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
$datasLang = $melisLangTable->getEntryById($langId);
// If the language was found and then exists
if (!empty($datasLang))
{
$datasLang = $datasLang->current();
// Update session locale for melis BO
$container = new Container('meliscore');
if($container) {
$container['melis-lang-id'] = $langId;
if(isset($datasLang->lang_locale)){
$container['melis-lang-locale'] = $datasLang->lang_locale;
$container['melis-login-lang-locale'] = $datasLang->lang_locale;
}
}
// If user is connected
if ($melisCoreAuth->hasIdentity())
{
// Get user id from session auth
$userAuthDatas = $melisCoreAuth->getStorage()->read();
$userId = $userAuthDatas->usr_id;
// Update auth user session
$userAuthDatas->usr_lang_id = $langId;
// Update user table
$datasUser = $melisUserTable->save(array('usr_lang_id' => $langId), $userId);
$flashMsgSrv = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$flashMsgSrv->clearFlashMessage();
$this->getEventManager()->trigger('meliscore_get_recent_user_logs', $this, array());
}
}
else
{
$success = false;
$errors[] = 'Language not found';
}
$jsonModel = new JsonModel();
$jsonModel->setVariables(array(
'success' => $success,
'errors' => $errors,
));
return $jsonModel;
} | php | public function changeLanguageAction()
{
$langId = $this->params()->fromQuery('langId', null);
$locale = '';
$success = true;
$errors = array();
if (empty($langId) || !is_numeric($langId) || $langId <= 0)
$success = false;
$melisLangTable = $this->serviceLocator->get('MelisCore\Model\Tables\MelisLangTable');
$melisUserTable = $this->serviceLocator->get('MelisCore\Model\Tables\MelisUserTable');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
$datasLang = $melisLangTable->getEntryById($langId);
// If the language was found and then exists
if (!empty($datasLang))
{
$datasLang = $datasLang->current();
// Update session locale for melis BO
$container = new Container('meliscore');
if($container) {
$container['melis-lang-id'] = $langId;
if(isset($datasLang->lang_locale)){
$container['melis-lang-locale'] = $datasLang->lang_locale;
$container['melis-login-lang-locale'] = $datasLang->lang_locale;
}
}
// If user is connected
if ($melisCoreAuth->hasIdentity())
{
// Get user id from session auth
$userAuthDatas = $melisCoreAuth->getStorage()->read();
$userId = $userAuthDatas->usr_id;
// Update auth user session
$userAuthDatas->usr_lang_id = $langId;
// Update user table
$datasUser = $melisUserTable->save(array('usr_lang_id' => $langId), $userId);
$flashMsgSrv = $this->getServiceLocator()->get('MelisCoreFlashMessenger');
$flashMsgSrv->clearFlashMessage();
$this->getEventManager()->trigger('meliscore_get_recent_user_logs', $this, array());
}
}
else
{
$success = false;
$errors[] = 'Language not found';
}
$jsonModel = new JsonModel();
$jsonModel->setVariables(array(
'success' => $success,
'errors' => $errors,
));
return $jsonModel;
} | [
"public",
"function",
"changeLanguageAction",
"(",
")",
"{",
"$",
"langId",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'langId'",
",",
"null",
")",
";",
"$",
"locale",
"=",
"''",
";",
"$",
"success",
"=",
"true",
";",
"$",
... | Change the language
@return \Zend\View\Model\JsonModel | [
"Change",
"the",
"language"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/LanguageController.php#L66-L127 | train |
melisplatform/melis-core | src/Controller/LanguageController.php | LanguageController.getTranslationsAction | public function getTranslationsAction()
{
// Get the current language
$container = new Container('meliscore');
$locale = $container['melis-lang-locale'];
$translator = $this->getServiceLocator()->get('translator');
$melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation');
// Set the headers of this route
$response = $this->getResponse();
$response->getHeaders()
->addHeaderLine('Content-Type', 'text/javascript; charset=utf-8');
$translationCompilation = '';
foreach($melisTranslation->getTranslationMessages($locale) as $transKey => $transValue)
{
$translationCompilation .= "translations['".$transKey."'] = '" . $transValue . "';".PHP_EOL;
}
$scriptContent = '';
$scriptContent .= 'var melisLangId = "' . $locale . '";' . PHP_EOL;
$scriptContent .= 'var melisDateFormat = "'. $melisTranslation->getDateFormat($locale) . '";'. PHP_EOL;
$scriptContent .= 'var translations = new Object();'. PHP_EOL;
$scriptContent .= $translationCompilation;
$response->setContent($scriptContent);
$view = new ViewModel();
$view->setTerminal(true);
$view->contentHeaders = $response->getContent();
return $view;
} | php | public function getTranslationsAction()
{
// Get the current language
$container = new Container('meliscore');
$locale = $container['melis-lang-locale'];
$translator = $this->getServiceLocator()->get('translator');
$melisTranslation = $this->getServiceLocator()->get('MelisCoreTranslation');
// Set the headers of this route
$response = $this->getResponse();
$response->getHeaders()
->addHeaderLine('Content-Type', 'text/javascript; charset=utf-8');
$translationCompilation = '';
foreach($melisTranslation->getTranslationMessages($locale) as $transKey => $transValue)
{
$translationCompilation .= "translations['".$transKey."'] = '" . $transValue . "';".PHP_EOL;
}
$scriptContent = '';
$scriptContent .= 'var melisLangId = "' . $locale . '";' . PHP_EOL;
$scriptContent .= 'var melisDateFormat = "'. $melisTranslation->getDateFormat($locale) . '";'. PHP_EOL;
$scriptContent .= 'var translations = new Object();'. PHP_EOL;
$scriptContent .= $translationCompilation;
$response->setContent($scriptContent);
$view = new ViewModel();
$view->setTerminal(true);
$view->contentHeaders = $response->getContent();
return $view;
} | [
"public",
"function",
"getTranslationsAction",
"(",
")",
"{",
"// Get the current language",
"$",
"container",
"=",
"new",
"Container",
"(",
"'meliscore'",
")",
";",
"$",
"locale",
"=",
"$",
"container",
"[",
"'melis-lang-locale'",
"]",
";",
"$",
"translator",
"... | Returns a Javascript format of Melis Translations | [
"Returns",
"a",
"Javascript",
"format",
"of",
"Melis",
"Translations"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/LanguageController.php#L132-L165 | train |
melisplatform/melis-core | src/Controller/LanguageController.php | LanguageController.updateLanguageAction | public function updateLanguageAction()
{
$response = array();
$success = 0;
$excludeModules = array('.', '..', '.gitignore', 'MelisSites', 'MelisInstaller');
$textTitle = 'tr_meliscore_header_language_Language';
$textMessage = 'tr_meliscore_tool_language_update_failed';
$this->getEventManager()->trigger('meliscore_language_update_start', $this, $response);
$translationSvc = $this->getServiceLocator()->get('MelisCoreTranslation');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$vendorModules = $moduleSvc->getVendorModules();
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$directory = $melisCoreConfig->getItem('meliscore/datas/default/langauges/default_trans_dir');
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$fullPathVendorModules = null;
if($this->getRequest()->isPost()){
$id = (int) $this->getRequest()->getPost('id');
$locale = $melisTool->sanitize($this->getRequest()->getPost('locale'));
if(!empty($locale)){
foreach($vendorModules as $vModule) {
$vPath = $moduleSvc->getModulePath($vModule) . '/language/';
if(file_exists($vPath) && is_writable($vPath)) {
$fullPathVendorModules[] = array('module' => $vModule, 'path' => $vPath);
}
}
if($fullPathVendorModules) {
foreach($fullPathVendorModules as $vModuleConf) {
$success = $translationSvc->createOrUpdateTranslationFiles($vModuleConf['path'], $vModuleConf['module'], $locale);
if(!$success){
break;
}
}
}
if($success){
$textMessage = 'tr_meliscore_tool_language_edit_success';
}
}
}
$response = array(
'textTitle' => $textTitle,
'textMessage' => $textMessage,
'success' => $success
);
$this->getEventManager()->trigger('meliscore_language_update_end', $this, $response);
return new JsonModel($response);
} | php | public function updateLanguageAction()
{
$response = array();
$success = 0;
$excludeModules = array('.', '..', '.gitignore', 'MelisSites', 'MelisInstaller');
$textTitle = 'tr_meliscore_header_language_Language';
$textMessage = 'tr_meliscore_tool_language_update_failed';
$this->getEventManager()->trigger('meliscore_language_update_start', $this, $response);
$translationSvc = $this->getServiceLocator()->get('MelisCoreTranslation');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$vendorModules = $moduleSvc->getVendorModules();
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$directory = $melisCoreConfig->getItem('meliscore/datas/default/langauges/default_trans_dir');
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$fullPathVendorModules = null;
if($this->getRequest()->isPost()){
$id = (int) $this->getRequest()->getPost('id');
$locale = $melisTool->sanitize($this->getRequest()->getPost('locale'));
if(!empty($locale)){
foreach($vendorModules as $vModule) {
$vPath = $moduleSvc->getModulePath($vModule) . '/language/';
if(file_exists($vPath) && is_writable($vPath)) {
$fullPathVendorModules[] = array('module' => $vModule, 'path' => $vPath);
}
}
if($fullPathVendorModules) {
foreach($fullPathVendorModules as $vModuleConf) {
$success = $translationSvc->createOrUpdateTranslationFiles($vModuleConf['path'], $vModuleConf['module'], $locale);
if(!$success){
break;
}
}
}
if($success){
$textMessage = 'tr_meliscore_tool_language_edit_success';
}
}
}
$response = array(
'textTitle' => $textTitle,
'textMessage' => $textMessage,
'success' => $success
);
$this->getEventManager()->trigger('meliscore_language_update_end', $this, $response);
return new JsonModel($response);
} | [
"public",
"function",
"updateLanguageAction",
"(",
")",
"{",
"$",
"response",
"=",
"array",
"(",
")",
";",
"$",
"success",
"=",
"0",
";",
"$",
"excludeModules",
"=",
"array",
"(",
"'.'",
",",
"'..'",
",",
"'.gitignore'",
",",
"'MelisSites'",
",",
"'Melis... | This allows the selected language to get new translations from melisplatform
@return \Zend\View\Model\JsonModel | [
"This",
"allows",
"the",
"selected",
"language",
"to",
"get",
"new",
"translations",
"from",
"melisplatform"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/LanguageController.php#L605-L660 | train |
melisplatform/melis-core | src/Controller/LanguageController.php | LanguageController.getWarningLogs | private function getWarningLogs()
{
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$allModules = $moduleSvc->getAllModules();
$excludeModules = ['MelisFront', 'MelisEngine', 'MelisInstaller', 'MelisAssetManager', 'MelisModuleConfig', 'MelisSites'];
$modules = [];
// foreach($allModules as $module) {
// if(!in_array($module, $excludeModules)) {
// $modules[] = $moduleSvc->getModulePath($module).'/language';
// }
// }
$folderPath = [
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/',
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/languages',
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/config',
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/config/translation.list.php',
];
$logs = [];
foreach(array_merge($modules, $folderPath) as $path) {
if(file_exists($path)) {
if(!is_readable($path)) {
// this folder is not readable
$logs[] = $melisTool->getTranslation('tr_meliscore_tool_language_lang_folder_not_readable', [$path]);
}
else {
if(!is_writable($path)) {
// this folder is not writable
$logs[] = $melisTool->getTranslation('tr_meliscore_tool_language_lang_folder_not_writable', [$path]);
}
}
}
// else {
// $logs[] = $melisTool->getTranslation('tr_meliscore_tool_language_lang_folder_not_exist', [$path]);
// }
}
return $logs;
} | php | private function getWarningLogs()
{
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$allModules = $moduleSvc->getAllModules();
$excludeModules = ['MelisFront', 'MelisEngine', 'MelisInstaller', 'MelisAssetManager', 'MelisModuleConfig', 'MelisSites'];
$modules = [];
// foreach($allModules as $module) {
// if(!in_array($module, $excludeModules)) {
// $modules[] = $moduleSvc->getModulePath($module).'/language';
// }
// }
$folderPath = [
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/',
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/languages',
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/config',
$_SERVER['DOCUMENT_ROOT'] . '../module/MelisModuleConfig/config/translation.list.php',
];
$logs = [];
foreach(array_merge($modules, $folderPath) as $path) {
if(file_exists($path)) {
if(!is_readable($path)) {
// this folder is not readable
$logs[] = $melisTool->getTranslation('tr_meliscore_tool_language_lang_folder_not_readable', [$path]);
}
else {
if(!is_writable($path)) {
// this folder is not writable
$logs[] = $melisTool->getTranslation('tr_meliscore_tool_language_lang_folder_not_writable', [$path]);
}
}
}
// else {
// $logs[] = $melisTool->getTranslation('tr_meliscore_tool_language_lang_folder_not_exist', [$path]);
// }
}
return $logs;
} | [
"private",
"function",
"getWarningLogs",
"(",
")",
"{",
"$",
"melisTool",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTool'",
")",
";",
"$",
"moduleSvc",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
... | Returns the possible folder or file issues
@return array | [
"Returns",
"the",
"possible",
"folder",
"or",
"file",
"issues"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/LanguageController.php#L666-L706 | train |
melisplatform/melis-core | src/Service/MelisCoreModulesService.php | MelisCoreModulesService.getModulesAndVersions | public function getModulesAndVersions($moduleName = null)
{
$tmpModules = [];
$repos = $this->getComposer()->getRepositoryManager()->getLocalRepository();
$composerFile = $_SERVER['DOCUMENT_ROOT'] . '/../vendor/composer/installed.json';
$composer = (array) \Zend\Json\Json::decode(file_get_contents($composerFile));
foreach ($composer as $package) {
$packageModuleName = isset($package->extra) ? (array) $package->extra : null;
$module = null;
if (isset($packageModuleName['module-name'])) {
$module = $packageModuleName['module-name'];
}
if ($module) {
$tmpModules[$module] = [
'package' => $package->name,
'module' => $module,
'version' => $package->version,
];
if ($module == $moduleName) {
break;
}
}
}
$userModules = $this->getUserModules();
$exclusions = ['MelisModuleConfig', 'MelisSites'];
foreach ($userModules as $module) {
if (!in_array($module, $exclusions)) {
$class = $_SERVER['DOCUMENT_ROOT'] . '/../module/' . $module . '/Module.php';
$class = file_get_contents($class);
$package = $module;
$version = '1.0';
if (preg_match_all('/@(\w+)\s+(.*)\r?\n/m', $class, $matches)) {
$result = array_combine($matches[1], $matches[2]);
$version = isset($result['version']) ? $result['version'] : '1.0';
$package = isset($result['module']) ? $result['module'] : $module;
}
$tmpModules[$package] = [
'package' => $package,
'module' => $package,
'version' => $version,
];
}
}
$modules = $tmpModules;
if (!is_null($moduleName)) {
return isset($modules[$moduleName]) ? $modules[$moduleName] : null;
}
return $modules;
} | php | public function getModulesAndVersions($moduleName = null)
{
$tmpModules = [];
$repos = $this->getComposer()->getRepositoryManager()->getLocalRepository();
$composerFile = $_SERVER['DOCUMENT_ROOT'] . '/../vendor/composer/installed.json';
$composer = (array) \Zend\Json\Json::decode(file_get_contents($composerFile));
foreach ($composer as $package) {
$packageModuleName = isset($package->extra) ? (array) $package->extra : null;
$module = null;
if (isset($packageModuleName['module-name'])) {
$module = $packageModuleName['module-name'];
}
if ($module) {
$tmpModules[$module] = [
'package' => $package->name,
'module' => $module,
'version' => $package->version,
];
if ($module == $moduleName) {
break;
}
}
}
$userModules = $this->getUserModules();
$exclusions = ['MelisModuleConfig', 'MelisSites'];
foreach ($userModules as $module) {
if (!in_array($module, $exclusions)) {
$class = $_SERVER['DOCUMENT_ROOT'] . '/../module/' . $module . '/Module.php';
$class = file_get_contents($class);
$package = $module;
$version = '1.0';
if (preg_match_all('/@(\w+)\s+(.*)\r?\n/m', $class, $matches)) {
$result = array_combine($matches[1], $matches[2]);
$version = isset($result['version']) ? $result['version'] : '1.0';
$package = isset($result['module']) ? $result['module'] : $module;
}
$tmpModules[$package] = [
'package' => $package,
'module' => $package,
'version' => $version,
];
}
}
$modules = $tmpModules;
if (!is_null($moduleName)) {
return isset($modules[$moduleName]) ? $modules[$moduleName] : null;
}
return $modules;
} | [
"public",
"function",
"getModulesAndVersions",
"(",
"$",
"moduleName",
"=",
"null",
")",
"{",
"$",
"tmpModules",
"=",
"[",
"]",
";",
"$",
"repos",
"=",
"$",
"this",
"->",
"getComposer",
"(",
")",
"->",
"getRepositoryManager",
"(",
")",
"->",
"getLocalRepos... | Returns the module name, module package, and its' version
@param null $moduleName - provide the module name if you want to get the package specific information
@return array | [
"Returns",
"the",
"module",
"name",
"module",
"package",
"and",
"its",
"version"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreModulesService.php#L39-L105 | train |
melisplatform/melis-core | src/Service/MelisCoreModulesService.php | MelisCoreModulesService.getDir | protected function getDir($dir, $excludeSubFolders = [])
{
$directories = [];
if (file_exists($dir)) {
$excludeDir = array_merge(['.', '..', '.gitignore'], $excludeSubFolders);
$directory = array_diff(scandir($dir), $excludeDir);
foreach ($directory as $d) {
if (is_dir($dir . '/' . $d)) {
$directories[] = $d;
}
}
}
return $directories;
} | php | protected function getDir($dir, $excludeSubFolders = [])
{
$directories = [];
if (file_exists($dir)) {
$excludeDir = array_merge(['.', '..', '.gitignore'], $excludeSubFolders);
$directory = array_diff(scandir($dir), $excludeDir);
foreach ($directory as $d) {
if (is_dir($dir . '/' . $d)) {
$directories[] = $d;
}
}
}
return $directories;
} | [
"protected",
"function",
"getDir",
"(",
"$",
"dir",
",",
"$",
"excludeSubFolders",
"=",
"[",
"]",
")",
"{",
"$",
"directories",
"=",
"[",
"]",
";",
"if",
"(",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"excludeDir",
"=",
"array_merge",
"(",
... | Returns all the sub-folders in the provided path
@param String $dir
@param array $excludeSubFolders
@return array | [
"Returns",
"all",
"the",
"sub",
"-",
"folders",
"in",
"the",
"provided",
"path"
] | f8b0648930e21d1f2b2e5b9300781c335bd34ea4 | https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreModulesService.php#L193-L209 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.