isConnectionActive example

$this->tasks[] = [
      'arguments' => [],
      'function' => 'ensureInnoDbAvailable',
    ];
  }

  /** * {@inheritdoc} */
  public function name() {
    try {
      if (!$this->isConnectionActive() || !$this->getConnection() instanceof Connection) {
        throw new ConnectionNotDefinedException('The database connection is not active or not a MySql connection');
      }
      if ($this->getConnection()->isMariaDb()) {
        return $this->t('MariaDB');
      }
      return $this->t('MySQL, Percona Server, or equivalent');
    }
    catch (ConnectionNotDefinedException $e) {
      return $this->t('MySQL, MariaDB, Percona Server, or equivalent');
    }
  }

  
Home | Imprint | This part of the site doesn't use cookies.