c
This commit is contained in:
106
inc/Hura8/System/Constant.php
Normal file
106
inc/Hura8/System/Constant.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\System;
|
||||
|
||||
|
||||
use Hura8\Traits\ClassCacheTrait;
|
||||
use ReflectionClass;
|
||||
|
||||
class Constant
|
||||
{
|
||||
|
||||
use ClassCacheTrait;
|
||||
|
||||
|
||||
private static $constant_dir = CONFIG_DIR . '/system';
|
||||
|
||||
const LANGUAGE_ID = "_l"; // to identify the language setting on URL or in FORM
|
||||
|
||||
|
||||
public static function getAllEntityTypes() {
|
||||
|
||||
return static::getCache('getAllEntityTypes', function () {
|
||||
|
||||
$extend_type_config = CONFIG_DIR . DIRECTORY_SEPARATOR . "/client/config_extend_entity_type.php";
|
||||
$extended_types = [];
|
||||
if(file_exists($extend_type_config)) {
|
||||
$extend_types = include_once $extend_type_config;
|
||||
foreach ($extend_types as $key => $title) {
|
||||
$extended_types[] = preg_replace("/[^a-z0-9_\-]/i", "", $key);
|
||||
}
|
||||
}
|
||||
|
||||
$list = [];
|
||||
try {
|
||||
$reflectionClass = new \ReflectionClass(new \Hura8\Interfaces\EntityType());
|
||||
foreach ($reflectionClass->getConstants() as $handle => $value) {
|
||||
$list[] = $value;
|
||||
}
|
||||
|
||||
// add extend
|
||||
foreach ($extended_types as $type) {
|
||||
if(!in_array($type, $list)) {
|
||||
$list[] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\ReflectionException $e) {
|
||||
//
|
||||
}
|
||||
|
||||
return $list;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// list of languages can be enabled
|
||||
public static function languagePermitList() {
|
||||
return [
|
||||
"vi" => "Tiếng Việt", // default
|
||||
"en" => "English",
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public static function mobileProviderPrefixList() {
|
||||
return static::getCache('mobileProviderPrefixList', function () {
|
||||
return include static::$constant_dir. '/mobile_provider.php';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static function customerStageList() {
|
||||
return static::getCache('customerStageList', function () {
|
||||
return include static::$constant_dir. '/customer_stage_list.php';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static function saluteList() {
|
||||
return static::getCache('genderList', function () {
|
||||
return include static::$constant_dir. '/salute_list.php';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static function genderList() {
|
||||
return static::getCache('genderList', function () {
|
||||
return include static::$constant_dir. '/gender_list.php';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static function industryList() {
|
||||
return static::getCache('industryList', function () {
|
||||
return include static::$constant_dir. '/industry_list.php';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static function maritalStatusList() {
|
||||
return static::getCache('maritalStatusList', function () {
|
||||
return include static::$constant_dir. '/marital_status_list.php';
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user