Skip to content
Snippets Groups Projects

Connection configuration using DSN

Merged Nikita Malyshev requested to merge 1.x-improve-connection-configuration into 1.x
3 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
143 if ($this->host !== NULL || $this->port !== NULL) {
144 $errors[] = 'Host and port must be null for Unix connections';
145 }
146
147 $this->throwIfErrors($errors);
148 }
149
150 /**
151 * Throws aggregated validation errors as a single exception.
152 *
153 * @param list<string> $errors
154 * List of validation error messages.
155 *
156 * @throws \InvalidArgumentException
157 */
158 private function throwIfErrors(array $errors): void {
  • Maintainer
    if (\count($errors) > 0) {
      throw new \InvalidArgumentException((implode('. ', $errors)));
    }

    Целый метод чтобы три строчки два раза не повторять?

  • Please register or sign in to reply
  • 4
    5 namespace Drupal\cache_pilot\Connection;
    6
    7 /**
    8 * Immutable configuration container for Fast-CGI connections.
    9 */
    10 final readonly class ConnectionConfig {
    11
    12 /**
    13 * Constructs a new ConnectionConfig instance.
    14 *
    15 * @param string $type
    16 * The connection type. Supported values:
    17 * - 'tcp': TCP/IP connection (requires $host and $port)
    18 * - 'unix': Unix Domain Socket connection (requires $socketPath)
    19 * @param string|null $socketPath
  • 82 $this->validateType();
    83
    84 match ($this->type) {
    85 'tcp' => $this->validateTcpParams(),
    86 'unix' => $this->validateUnixParams(),
    87 default => throw new \InvalidArgumentException('Invalid connection type'),
    88 };
    89 }
    90
    91 /**
    92 * Validates the connection type parameter.
    93 *
    94 * @throws \InvalidArgumentException
    95 * When an unsupported connection type is provided.
    96 */
    97 private function validateType(): void {
  • Ivan left review comments

    left review comments

  • Please register or sign in to reply
    Loading