*/ public const DEFAULT_SORT_BY_KEYS = ['name', 'fileUid']; /** * @param list $sortByKeys Keys the forms are sorted by in the form manager and plugin select * @param list $allowedExtensionPaths EXT: paths that contain forms shipped within extensions * @param list $allowedFileMounts File mounts forms may be stored in */ public function __construct( public bool $allowSaveToExtensionPaths = false, public bool $allowDeleteFromExtensionPaths = false, public array $sortByKeys = self::DEFAULT_SORT_BY_KEYS, public bool $sortAscending = true, public array $allowedExtensionPaths = [], public array $allowedFileMounts = [], ) {} /** * Create the DTO from the raw "persistenceManager" configuration array. * * @param array $configuration */ public static function fromArray(array $configuration): self { return new self( allowSaveToExtensionPaths: (bool)($configuration['allowSaveToExtensionPaths'] ?? false), allowDeleteFromExtensionPaths: (bool)($configuration['allowDeleteFromExtensionPaths'] ?? false), sortByKeys: self::normalizeStringList($configuration['sortByKeys'] ?? null, self::DEFAULT_SORT_BY_KEYS), sortAscending: (bool)($configuration['sortAscending'] ?? true), allowedExtensionPaths: self::normalizeStringList($configuration['allowedExtensionPaths'] ?? null, []), allowedFileMounts: self::normalizeStringList($configuration['allowedFileMounts'] ?? null, []), ); } /** * Normalize a configuration value into a numerically indexed list of strings. * * The YAML configuration may use associative keys (e.g. `10:`, `20:`) to * define ordering, so values are cast to strings and re-indexed. * * @param list $default * @return list */ private static function normalizeStringList(mixed $value, array $default): array { if (!is_array($value)) { return $default; } return array_values(array_map(strval(...), $value)); } }