apigee_m10n-8.x-1.7/modules/apigee_m10n_teams/apigee_m10n_teams.install

modules/apigee_m10n_teams/apigee_m10n_teams.install
<?php

/**
 * @file
 * Copyright 2018 Google Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License version 2 as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

use Drupal\apigee_m10n_teams\MonetizationTeamsInterface;
use Drupal\user\RoleInterface;

/**
 * Implements hook_install().
 */
function apigee_m10n_teams_install() {
  // Populate the default permissions for the authenticated user.
  if (Drupal::moduleHandler()->moduleExists('user')) {
    user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, MonetizationTeamsInterface::DEFAULT_AUTHENTICATED_PERMISSIONS);
  }
}

/**
 * Implements hook_requirements().
 */
function apigee_m10n_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 && $org_controller->isOrganizationApigeeX()) {
        // AppGroup APIs are not supported in Apigee X / Hybrid orgs with monetization enabled.
        if ($organization->getAddonsConfig() && $organization->getAddonsConfig()->getMonetizationConfig() && TRUE === $organization->getAddonsConfig()->getMonetizationConfig()->getEnabled()) {
          $url = [
            ':url' => 'https://cloud.google.com/apigee/docs/api-platform/publish/organizing-client-app-ownership?hl=en#appgroups-limitations-and-known-issues',
          ];
          $message = ($phase == 'runtime') ?
            t("The Apigee Monetization Teams module functionality is not available for monetization enabled org on Apigee X / Hybrid and should be uninstalled, because <a href=':url' target='_blank'>AppGroup APIs are not supported in Apigee X / Hybrid orgs with monetization enabled</a>.", $url) :
            t("The Apigee Monetization Teams module functionality is not available for monetization enabled org on Apigee X / Hybrid because <a href=':url' target='_blank'>AppGroup APIs are not supported in Apigee X / Hybrid orgs with monetization enabled</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;
}

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

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