simplytest-8.x-4.x-dev/modules/simplytest_tugboat/simplytest_tugboat.module

modules/simplytest_tugboat/simplytest_tugboat.module
<?php

/**
 * @file
 * Primary module hooks for Simplytest tugboat module.
 */

/**
 * Implements hook_page_attachments().
 */
function simplytest_tugboat_page_attachments(array &$page) {
  $page['#attached']['library'][] = 'simplytest_tugboat/simplytest_tugboat_status';
}

/**
 * Implements hook_theme().
 */
function simplytest_tugboat_theme() {
  $items = [];
  $items['simplytest_tugboat_config_9_yml'] = [
    'variables' => [
      'parameters' => [],
    ],
  ];
  $items['simplytest_tugboat_config_8_yml'] = [
    'variables' => [
      'parameters' => [],
    ],
  ];
  $items['simplytest_tugboat_config_7_yml'] = [
    'variables' => [
      'parameters' => [],
    ],
  ];
  return $items;
}

/**
 * Prepares variables for D7 Tugboat configuration templates.
 *
 * This will be a YAML file, but I think the Drupal theme system requires us to
 * use the .html.twig extension.
 *
 * Default template: tugboat-config-7-yml.html.twig.
 *
 * @param array $variables
 *   An associative array with the key 'parameters' and the value is an
 *   associative array with the following keys:
 *   - additionals: array of additional projects to install
 *   - drupal_core_version: the version (branch or tag) of Drupal core to use
 *   - instance_id
 *   - patches: array of URLs to patch files to apply
 *   - perform_install (bool): whether to 'drush si'
 *   - project: the primary project to install
 *   - project_type: the type (Module, Theme, or Distribution) of the primary project
 *   - project_version: the version string for the primary project
 *   - status_endpoint: The $base_url + route uri + instance id for reporting
 *     status back to the simplytest server.
 *
 * @see \Drupal\simplytest_tugboat\InstanceManager::launchInstance()
 */
function template_preprocess_simplytest_tugboat_config_7_yml(&$variables) {
  $variables += $variables['parameters'];
}

/**
 * Prepares variables for D8 Tugboat configuration templates.
 *
 * This will be a YAML file, but I think the Drupal theme system requires us to
 * use the .html.twig extension.
 *
 * Default template: tugboat-config-8-yml.html.twig.
 *
 * @param array $variables
 *   An associative array with the key 'parameters' and the value is an
 *   associative array with the following keys:
 *   - additionals: array of additional projects to install
 *   - drupal_core_version: the version (branch or tag) of Drupal core to use
 *   - patches: array of URLs to patch files to apply
 *   - perform_install (bool): whether to 'drush si'
 *   - project: the primary project to install
 *   - project_type: the type (Module, Theme, or Distribution) of the primary project
 *   - project_version: the version string for the primary project
 *   - status_endpoint: The $base_url + route uri + instance id for reporting
 *     status back to the simplytest server.
 *
 * @see \Drupal\simplytest_tugboat\InstanceManager::launchInstance()
 */
function template_preprocess_simplytest_tugboat_config_8_yml(&$variables) {
  $variables += $variables['parameters'];
}

/**
 * Prepares variables for D9 Tugboat configuration templates.
 *
 * This will be a YAML file, but I think the Drupal theme system requires us to
 * use the .html.twig extension.
 *
 * Default template: tugboat-config-9-yml.html.twig.
 *
 * @param array $variables
 *   An associative array with the key 'parameters' and the value is an
 *   associative array with the following keys:
 *   - additionals: array of additional projects to install
 *   - drupal_core_version: the version (branch or tag) of Drupal core to use
 *   - patches: array of URLs to patch files to apply
 *   - perform_install (bool): whether to 'drush si'
 *   - project: the primary project to install
 *   - project_type: the type (Module, Theme, or Distribution) of the primary project
 *   - project_version: the version string for the primary project
 *   - status_endpoint: The $base_url + route uri + instance id for reporting
 *     status back to the simplytest server.
 *
 * @see \Drupal\simplytest_tugboat\InstanceManager::launchInstance()
 */
function template_preprocess_simplytest_tugboat_config_9_yml(&$variables) {
  $variables += $variables['parameters'];
}

/**
 * Get instance log.
 *
 * @param string $instance_id
 *   The primary identifier for the instance.
 */
function _simplytest_tugboat_get_log($instance_id) {
  return \Drupal::service('simplytest_tugboat.instance_manager')
    ->getLog($instance_id);
}

/**
 * Loads the preview ID from a base preview branch.
 *
 * @param $context
 *
 * @return string
 */
function simplytest_tugboat_load_preview_id($context, $base = TRUE) {
  return \Drupal::service('simplytest_tugboat.instance_manager')
    ->loadPreviewId($instance_id);
}

/**
 * Loads the URL for an instance.
 *
 * @param $instance_id
 *   The primary identifier for the instance.
 *
 * @return string
 *   The Tugboat URL.
 */
function simplytest_tugboat_url_load($instance_id) {
  return \Drupal::service('simplytest_tugboat.instance_manager')
    ->loadUrl($instance_id);
}

/**
 * Updates the URL for an instance.
 *
 * @param $instance_id
 *   The primary identifier for the instance.
 * @param $tugboat_url
 *   The Tugboat URL.
 */
function simplytest_tugboat_url_update($instance_id, $tugboat_url) {
  \Drupal::service('simplytest_tugboat.instance_manager')
    ->updateUrl($instance_id, $tugboat_url);
}

/**
 * Loads the context for an instance.
 *
 * @param $instance_id
 *   The primary identifier for the instance.
 *
 * @return string
 *   The context string.
 */
function simplytest_tugboat_context_load($instance_id) {
  return \Drupal::service('simplytest_tugboat.instance_manager')
    ->loadContext($instance_id);
}

/**
 * Creates an entity for the given instance, setting the context.
 *
 * @param $instance_id
 *   The primary identifier for the instance.
 * @param $context
 *   The context.
 */
function simplytest_tugboat_context_update($instance_id, $context) {
  \Drupal::service('simplytest_tugboat.instance_manager')
    ->createWithContext($instance_id, $tugboat_url);
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc