This commit is contained in:
Yuri Kuznetsov
2022-11-14 13:15:11 +02:00
parent 550bdaba4f
commit 8efe9842cf
10 changed files with 47 additions and 28 deletions
@@ -228,7 +228,7 @@ class DefaultTable implements Table
$fieldTableList[] = $role->getFieldTableData();
foreach ($this->valuePermissionList as $permissionKey) {
$permission = $this->normilizePermissionName($permissionKey);
$permission = $this->normalizePermissionName($permissionKey);
$valuePermissionLists->{$permissionKey}[] = $role->getPermissionLevel($permission);
}
@@ -263,7 +263,7 @@ class DefaultTable implements Table
if (!$this->user->isAdmin()) {
foreach ($this->valuePermissionList as $permissionKey) {
$permission = $this->normilizePermissionName($permissionKey);
$permission = $this->normalizePermissionName($permissionKey);
$defaultLevel = $this->metadata
->get(['app', $this->type, 'permissionsStrictDefaults', $permissionKey]) ??
@@ -284,7 +284,7 @@ class DefaultTable implements Table
if ($this->user->isAdmin()) {
foreach ($this->valuePermissionList as $permissionKey) {
$permission = $this->normilizePermissionName($permissionKey);
$permission = $this->normalizePermissionName($permissionKey);
$highestLevel = $this->metadata
->get(['app', $this->type, 'valuePermissionHighestLevels', $permissionKey]);
@@ -300,7 +300,7 @@ class DefaultTable implements Table
}
}
private function normilizePermissionName(string $permissionKey): string
private function normalizePermissionName(string $permissionKey): string
{
$permission = $permissionKey;
+1 -1
View File
@@ -223,7 +223,7 @@ class HookManager
foreach ($fileList as $scopeName => $hookFiles) {
$hookScopeDirPath = Util::concatPath($hookDir, $scopeName);
$normalizedScopeName = Util::normilizeScopeName($scopeName);
$normalizedScopeName = Util::normalizeScopeName($scopeName);
foreach ($hookFiles as $hookFile) {
$hookFilePath = Util::concatPath($hookScopeDirPath, $hookFile);
@@ -191,7 +191,7 @@ class ClassMap
continue;
}
$name = Util::normilizeScopeName(ucfirst($fileName));
$name = Util::normalizeScopeName(ucfirst($fileName));
$name = $category . $name;
+25 -2
View File
@@ -356,11 +356,12 @@ class Util
* @param string $name
* @return string
*/
public static function normilizeClassName($name)
public static function normalizeClassName($name)
{
if (in_array($name, self::$reservedWordList)) {
$name .= 'Obj';
}
return $name;
}
@@ -370,7 +371,7 @@ class Util
* @param string $name
* @return string
*/
public static function normilizeScopeName($name)
public static function normalizeScopeName($name)
{
foreach (self::$reservedWordList as $reservedWord) {
if ($reservedWord.'Obj' == $name) {
@@ -1005,4 +1006,26 @@ class Util
return implode('', $shuffle($array));
}
/**
* @deprecated Use `normalizeScopeName`.
*
* @param string $name
* @return string
*/
public static function normilizeScopeName($name)
{
return self::normalizeScopeName($name);
}
/**
* @deprecated Use `normalizeClassName`.
*
* @param string $name
* @return string
*/
public static function normilizeClassName($name)
{
return self::normalizeClassName($name);
}
}
@@ -49,7 +49,7 @@ trait SelectingBuilderTrait
* * `where(array $clause)`
* * `where(string $key, string $value)`
*
* @param WhereItem|array<mixed,mixed>|string $clause A key or where clause.
* @param WhereItem|array<mixed, mixed>|string $clause A key or where clause.
* @param mixed[]|scalar|null $value A value. Omitted if the first argument is not string.
*/
public function where($clause, $value = null): self
@@ -60,7 +60,7 @@ trait SelectingBuilderTrait
}
/**
* @param WhereItem|array<mixed,mixed>|string $clause A key or where clause.
* @param WhereItem|array<mixed, mixed>|string $clause A key or where clause.
* @param mixed[]|scalar|null $value A value. Omitted if the first argument is not string.
*/
private function applyWhereClause(string $type, $clause, $value): void
@@ -99,8 +99,6 @@ trait SelectingBuilderTrait
}
$this->params[$type] = $new + $original;
return;
}
/**
@@ -186,7 +184,7 @@ trait SelectingBuilderTrait
* @param Join|string $target
* A relation name or table. A relation name should be in camelCase, a table in CamelCase.
* @param string|null $alias An alias.
* @param WhereItem|array<mixed,mixed>|null $conditions Join conditions.
* @param WhereItem|array<mixed, mixed>|null $conditions Join conditions.
*/
private function joinInternal(string $type, $target, ?string $alias = null, $conditions = null): self
{
@@ -308,8 +306,6 @@ trait SelectingBuilderTrait
/** @var array{0:string,1?:string} $newItem */
$resultList[] = $newItem;
continue;
}
return $resultList;
+1 -1
View File
@@ -93,7 +93,7 @@ class Record extends RecordService implements
$name = $matches[1];
}
$this->entityType = Util::normilizeScopeName($name);
$this->entityType = Util::normalizeScopeName($name);
}
// to be removed
@@ -150,7 +150,7 @@ class EntityManager
throw new Conflict("Entity name '{$name}' is not allowed.");
}
$normalizedName = Util::normilizeClassName($name);
$normalizedName = Util::normalizeClassName($name);
$templateNamespace = "\Espo\Core\Templates";
@@ -160,7 +160,7 @@ class EntityManager
if (!empty($templateDefs['module'])) {
$templateModuleName = $templateDefs['module'];
$normalizedTemplateModuleName = Util::normilizeClassName($templateModuleName);
$normalizedTemplateModuleName = Util::normalizeClassName($templateModuleName);
$templateNamespace = "\Espo\Modules\\{$normalizedTemplateModuleName}\Core\Templates";
@@ -600,7 +600,7 @@ class EntityManager
throw new Forbidden;
}
$normalizedName = Util::normilizeClassName($name);
$normalizedName = Util::normalizeClassName($name);
$type = $this->metadata->get(['scopes', $name, 'type']);
@@ -1582,7 +1582,7 @@ class EntityManager
if (!empty($templateDefs['module'])) {
$templateModuleName = $templateDefs['module'];
$normalizedTemplateModuleName = Util::normilizeClassName($templateModuleName);
$normalizedTemplateModuleName = Util::normalizeClassName($templateModuleName);
$className =
'Espo\\Modules\\' . $normalizedTemplateModuleName .
@@ -140,7 +140,7 @@ class NameUtil
return true;
}
if ($name !== Util::normilizeScopeName($name)) {
if ($name !== Util::normalizeScopeName($name)) {
return true;
}
@@ -178,7 +178,7 @@ class NameUtil
private function controllerExists(string $name): bool
{
$controllerClassName = 'Espo\\Custom\\Controllers\\' . Util::normilizeClassName($name);
$controllerClassName = 'Espo\\Custom\\Controllers\\' . Util::normalizeClassName($name);
if (class_exists($controllerClassName)) {
return true;
@@ -186,14 +186,14 @@ class NameUtil
foreach ($this->metadata->getModuleList() as $moduleName) {
$controllerClassName =
'Espo\\Modules\\' . $moduleName . '\\Controllers\\' . Util::normilizeClassName($name);
'Espo\\Modules\\' . $moduleName . '\\Controllers\\' . Util::normalizeClassName($name);
if (class_exists($controllerClassName)) {
return true;
}
}
$controllerClassName = 'Espo\\Controllers\\' . Util::normilizeClassName($name);
$controllerClassName = 'Espo\\Controllers\\' . Util::normalizeClassName($name);
if (class_exists($controllerClassName)) {
return true;
+3 -3
View File
@@ -94,7 +94,7 @@ function (Dep, styleCss) {
this.panels.splice(index, 1);
}
this.normilizeDisabledItemList();
this.normalizeDisabledItemList();
this.setIsChanged();
},
@@ -116,7 +116,7 @@ function (Dep, styleCss) {
$(e.target).closest('ul.rows > li').remove();
this.normilizeDisabledItemList();
this.normalizeDisabledItemList();
this.setIsChanged();
},
@@ -237,7 +237,7 @@ function (Dep, styleCss) {
}
}, Dep.prototype.events),
normilizeDisabledItemList: function () {
normalizeDisabledItemList: function () {
$('#layout ul.cells.disabled > li').each((i, el) => {
});
},
@@ -151,7 +151,7 @@ class EntityManagerReturnType implements DynamicMethodReturnTypeExtension
private function findEntityClassName(string $entityType): ?string
{
foreach ($this->entityNamespaceList as $namespace) {
$className = $namespace . '\\' . Util::normilizeClassName($entityType);
$className = $namespace . '\\' . Util::normalizeClassName($entityType);
if (class_exists($className)) {
return $className;