You are here

public function BitbucketManager::getBuildHookDetailsForPluginConfiguration in Build Hooks 8.2

Same name and namespace in other branches
  1. 3.x modules/build_hooks_bitbucket/src/BitbucketManager.php \Drupal\build_hooks_bitbucket\BitbucketManager::getBuildHookDetailsForPluginConfiguration()

Converts hook configuration into an api call.

Parameters

array $settings: The configuration for this hook.

Return value

\Drupal\build_hooks\BuildHookDetails An object that will trigger a pipeline based on config.

File

modules/build_hooks_bitbucket/src/BitbucketManager.php, line 80

Class

BitbucketManager
Service for managing BitBucket connection details.

Namespace

Drupal\build_hooks_bitbucket

Code

public function getBuildHookDetailsForPluginConfiguration($settings) {
  $buildHookDetails = new BuildHookDetails();
  $buildHookDetails
    ->setUrl($this
    ->getPipelinesApiPath($settings));
  $buildHookDetails
    ->setMethod('POST');
  $body = [
    'target' => [
      "type" => "pipeline_ref_target",
      "ref_name" => $settings['ref']['name'],
      "ref_type" => $settings['ref']['type'],
      "selector" => [
        "type" => $settings['selector']['type'],
        "pattern" => $settings['selector']['name'],
      ],
    ],
  ];
  $buildHookDetails
    ->setOptions([
    'json' => $body,
    'auth' => $this
      ->getAuth(),
  ]);
  return $buildHookDetails;
}