You are here

function apigee_edge_teams_requirements in Apigee Edge 8

Implements hook_requirements().

File

modules/apigee_edge_teams/apigee_edge_teams.install, line 33
Copyright 2019 Google Inc.

Code

function apigee_edge_teams_requirements($phase) {
  $requirements = [];
  if ($phase == 'install' || $phase == 'runtime') {
    try {

      /** @var \Drupal\apigee_edge\SDKConnectorInterface $sdk_connector */
      $sdk_connector = \Drupal::service('apigee_edge.sdk_connector');
      $org_controller = \Drupal::service('apigee_edge.controller.organization');

      /* @var \Apigee\Edge\Api\Management\Entity\Organization $organization */
      $organization = $org_controller
        ->load($sdk_connector
        ->getOrganization());
      if ($organization && !OrganizationFeatures::isCompaniesFeatureAvailable($organization)) {
        $url = [
          ':url' => 'https://cloud.google.com/apigee/docs/api-platform/get-started/compare-apigee-products#unsupported-apis',
        ];
        $message = $phase == 'runtime' ? t("The Apigee Edge Teams module functionality is not available for your org and should be uninstalled, because <a href=':url' target='_blank'>Edge company APIs are not supported in Apigee hybrid orgs</a>.", $url) : t("The Apigee Edge Teams module functionality is not available for your org because <a href=':url' target='_blank'>Edge company APIs are not supported in Apigee hybrid orgs</a>.", $url);
        $requirements['apigee_edge_teams_not_supported'] = [
          'title' => t('Apigee Edge Teams'),
          'description' => $message,
          'severity' => REQUIREMENT_ERROR,
        ];
      }
    } catch (\Exception $exception) {

      // Do nothing if connection to Edge is not available.
    }
  }
  return $requirements;
}