You are here

function yamlform_test_install in YAML Form 8

Implements hook_install().

File

tests/modules/yamlform_test/yamlform_test.install, line 14
Install, update and uninstall functions for the YAML Form Test module.

Code

function yamlform_test_install() {

  // Update 'Test: Handler: Remote post' URLs.

  /** @var \Drupal\yamlform\YamlFormInterface $remote_post_yamlform */
  $remote_post_yamlform = YamlForm::load('test_handler_remote_post');

  /** @var \Drupal\yamlform\Plugin\YamlFormHandler\RemotePostYamlFormHandler $remote_post_handler */
  $remote_post_handler = $remote_post_yamlform
    ->getHandler('remote_post');
  $remote_post_configuration = $remote_post_handler
    ->getConfiguration();

  // ISSUE: $base_url and $base_path are not working correctly so we are just
  // going to use the front page.
  $base_url = Url::fromRoute('<front>', [], [
    'absolute' => TRUE,
  ])
    ->toString();
  $remote_post_configuration['settings']['insert_url'] = $base_url . 'yamlform_test/remote_post/insert';
  $remote_post_configuration['settings']['update_url'] = $base_url . 'yamlform_test/remote_post/update';
  $remote_post_configuration['settings']['delete_url'] = $base_url . 'yamlform_test/remote_post/delete';
  $remote_post_handler
    ->setConfiguration($remote_post_configuration);
  $remote_post_yamlform
    ->save();
}