metadata->get(['entityDefs', Settings::ENTITY_TYPE, 'fields']); foreach ($fieldDefs as $field => $fieldParams) { if (empty($fieldParams['readOnly'])) { continue; } foreach ($this->fieldUtil->getAttributeList(Settings::ENTITY_TYPE, $field) as $attribute) { $itemList[] = $attribute; } } $params = $this->metadata->get(['app', 'config', 'params']) ?? []; foreach ($params as $name => $item) { if ($item['readOnly'] ?? false) { $itemList[] = $name; } } return array_values(array_unique($itemList)); } /** * @return string[] */ public function getAdminParamList(): array { $itemList = $this->config->get('adminItems') ?? []; $fieldDefs = $this->metadata->get(['entityDefs', Settings::ENTITY_TYPE, 'fields']); foreach ($fieldDefs as $field => $fieldParams) { if (empty($fieldParams['onlyAdmin'])) { continue; } foreach ($this->fieldUtil->getAttributeList(Settings::ENTITY_TYPE, $field) as $attribute) { $itemList[] = $attribute; } } return array_values( array_merge( $itemList, $this->getParamListByLevel(self::LEVEL_ADMIN) ) ); } /** * @return string[] */ public function getInternalParamList(): array { return $this->getParamListByLevel(self::LEVEL_INTERNAL); } /** * @return string[] */ public function getSystemParamList(): array { $itemList = $this->config->get('systemItems') ?? []; $fieldDefs = $this->metadata->get(['entityDefs', Settings::ENTITY_TYPE, 'fields']); foreach ($fieldDefs as $field => $fieldParams) { if (empty($fieldParams['onlySystem'])) { continue; } foreach ($this->fieldUtil->getAttributeList(Settings::ENTITY_TYPE, $field) as $attribute) { $itemList[] = $attribute; } } return array_values( array_merge( $itemList, $this->getParamListByLevel(self::LEVEL_SYSTEM) ) ); } /** * @return string[] */ public function getGlobalParamList(): array { $itemList = $this->config->get('globalItems', []); $fieldDefs = $this->metadata->get(['entityDefs', Settings::ENTITY_TYPE, 'fields']); foreach ($fieldDefs as $field => $fieldParams) { if (empty($fieldParams['global'])) { continue; } foreach ($this->fieldUtil->getAttributeList(Settings::ENTITY_TYPE, $field) as $attribute) { $itemList[] = $attribute; } } return array_values( array_merge( $itemList, $this->getParamListByLevel(self::LEVEL_GLOBAL) ) ); } /** * @return string[] */ public function getSuperAdminParamList(): array { return array_values( array_merge( $this->config->get('superAdminItems') ?? [], $this->getParamListByLevel(self::LEVEL_SUPER_ADMIN) ) ); } /** * @param self::LEVEL_* $level * @return string[] */ private function getParamListByLevel(string $level): array { $itemList = []; $params = $this->metadata->get(['app', 'config', 'params']) ?? []; foreach ($params as $name => $item) { $levelItem = $item['level'] ?? null; if ($levelItem !== $level) { continue; } $itemList[] = $name; } return $itemList; } }