schemaFactory->has($schemaName)) { return new FieldCollection(); } $backendUser = $this->getBackendUser(); $schema = $this->schemaFactory->get($schemaName); $fields = $schema->getFields(); $record = $this->recordFactory->createRawRecord($schemaName, $row); if ($schema->hasSubSchema($record->getRecordType() ?? '')) { $fields = $schema->getSubSchema($record->getRecordType())->getFields(); } // FieldCollection is immutable - to remove fields we transform it to an array $fields = iterator_to_array($fields); foreach ($exlcudeFieldNames as $fieldName) { unset($fields[$fieldName]); } $isOverlay = false; if ($schema->hasCapability(TcaSchemaCapability::Language)) { $isOverlay = (int)($record->toArray()[$schema->getCapability(TcaSchemaCapability::Language)->getTranslationOriginPointerField()->getName()] ?? 0) > 0; } foreach ($fields as $field) { if (($field->supportsAccessControl() && !$backendUser->check('non_exclude_fields', $schemaName . ':' . $field->getName())) || ($isOverlay && empty($field->getConfiguration()['l10n_display']) && ($field->getConfiguration()['l10n_mode'] ?? '') === 'exclude') ) { unset($fields[$field->getName()]); } } return new FieldCollection($fields); } /** * @return string[] */ public function getFieldNames(string $schemaName, array $row, array $excludeFieldNames = []): array { return array_map(static fn(FieldTypeInterface $field): string => $field->getName(), iterator_to_array($this->getFields($schemaName, $row, $excludeFieldNames))); } protected function getBackendUser(): BackendUserAuthentication { return $GLOBALS['BE_USER']; } }