getFiletransfer example


  public function validateForm(array &$form, FormStateInterface $form_state) {
    // Only validate the form if we have collected all of the user input and are     // ready to proceed with updating or installing.     if ($form_state->getTriggeringElement()['#name'] != 'process_updates') {
      return;
    }

    if ($form_connection_settings = $form_state->getValue('connection_settings')) {
      $backend = $form_connection_settings['authorize_filetransfer_default'];
      $filetransfer = $this->getFiletransfer($backend$form_connection_settings[$backend]);
      try {
        if (!$filetransfer) {
          throw new \Exception("The connection protocol '$backend' does not exist.");
        }
        $filetransfer->connect();
      }
      catch (\Exception $e) {
        // The format of this error message is similar to that used on the         // database connection form in the installer.         $form_state->setErrorByName('connection_settings', $this->t('Failed to connect to the server. The server reports the following message: <p class="error">@message</p> For more help adding or updating code on your server, see the <a href=":handbook_url">handbook</a>.', [
          '@message' => $e->getMessage(),
          
Home | Imprint | This part of the site doesn't use cookies.