Skip to content

Commit

Permalink
Merge branch '2.x' into issue_730
Browse files Browse the repository at this point in the history
  • Loading branch information
shishir-intelli authored Dec 29, 2022
2 parents 177250d + d2dc18b commit 1e650ae
Show file tree
Hide file tree
Showing 21 changed files with 772 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ assignees: ''
## Description
A clear and concise description of what the bug is.

## Apigee Info
Please specify if you are using Apigee X, Apigee Edge, or OPDK.

## Steps to Reproduce
Steps to reproduce the behavior:
1. Go to '...'
Expand All @@ -31,4 +34,3 @@ Add any other context about the problem here.
This can be the version you can see on admin/modules in Drupal or
the output of this command: `composer show`. Add Drupal core and
other version information if needed.

1 change: 0 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
drupal-core:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "drupal-module",
"description": "Apigee Edge for Drupal.",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"ext-json": "*",
"apigee/apigee-client-php": "^2.0.16",
"drupal/core": "^9.3",
Expand Down
5 changes: 5 additions & 0 deletions modules/apigee_edge_teams/apigee_edge_teams.links.task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ apigee_edge_teams.team_app.analytics:
title: 'Analytics'
base_route: entity.team_app.canonical
weight: -1

apigee_edge_teams.settings.team_member.sync:
route_name: apigee_edge_teams.settings.team_member.sync
title: 'Sync'
base_route: apigee_edge_teams.settings.team
24 changes: 24 additions & 0 deletions modules/apigee_edge_teams/apigee_edge_teams.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,27 @@ apigee_edge_teams.settings.team_app.cache:
_title: 'Caching'
requirements:
_permission: 'administer team'

apigee_edge_teams.settings.team_member.sync:
path: '/admin/config/apigee-edge/app-settings/team-settings/sync'
defaults:
_form: '\Drupal\apigee_edge_teams\Form\TeamMemberSyncForm'
_title: 'Team Member Synchronization'
requirements:
_permission: 'administer team'

apigee_edge_teams.team_member.run:
path: '/admin/config/apigee-edge/app-settings/team-settings/sync/run'
defaults:
_controller: '\Drupal\apigee_edge_teams\Controller\TeamMemberSyncController::run'
requirements:
_permission: 'administer team'
_csrf_token: 'TRUE'

apigee_edge_teams.team_member.schedule:
path: '/admin/config/apigee-edge/app-settings/team-settings/sync/schedule'
defaults:
_controller: '\Drupal\apigee_edge_teams\Controller\TeamMemberSyncController::schedule'
requirements:
_permission: 'administer team'
_csrf_token: 'TRUE'
4 changes: 4 additions & 0 deletions modules/apigee_edge_teams/apigee_edge_teams.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ services:
arguments: ['@entity_type.manager', '@logger.channel.apigee_edge_teams']
tags:
- { name: paramconverter }

apigee_edge_teams.cli:
class: Drupal\apigee_edge_teams\CliService
arguments: ['@apigee_edge.apigee_edge_mgmt_cli_service']
9 changes: 8 additions & 1 deletion modules/apigee_edge_teams/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"extra": {
"drush": {
"services": {
"drush.services.yml": "^9"
}
}
}
}
6 changes: 6 additions & 0 deletions modules/apigee_edge_teams/drush.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
apigee_edge_teams.commands:
class: \Drupal\apigee_edge_teams\Commands\ApigeeEdgeCommands
arguments: ['@apigee_edge_teams.cli', '@apigee_edge.apigee_edge_mgmt_cli_service']
tags:
- { name: drush.command }
73 changes: 73 additions & 0 deletions modules/apigee_edge_teams/src/CliService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/**
* Copyright 2022 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.
*/

namespace Drupal\apigee_edge_teams;

use Drupal\apigee_edge_teams\Controller\TeamMemberSyncController;
use Drupal\apigee_edge\Command\Util\ApigeeEdgeManagementCliServiceInterface;
use Symfony\Component\Console\Style\StyleInterface;

/**
* A CLI service which defines all the commands logic and delegates the methods.
*/
class CliService implements CliServiceInterface {

/**
* The service that makes calls to the Apigee API.
*
* @var \Drupal\apigee_edge\Command\Util\ApigeeEdgeManagementCliServiceInterface
*/
private $apigeeEdgeManagementCliService;

/**
* CliService constructor.
*
* @param \Drupal\apigee_edge\Command\Util\ApigeeEdgeManagementCliServiceInterface $apigeeEdgeManagementCliService
* The ApigeeEdgeManagementCliService to make calls to Apigee Edge.
*/
public function __construct(ApigeeEdgeManagementCliServiceInterface $apigeeEdgeManagementCliService) {
$this->apigeeEdgeManagementCliService = $apigeeEdgeManagementCliService;
}

/**
* {@inheritdoc}
*/
public function sync(StyleInterface $io, callable $t) {
$io->title($t('Team Member synchronization'));
$batch = TeamMemberSyncController::getBatch();
$last_message = '';

foreach ($batch['operations'] as $operation) {
$context = [
'finished' => 0,
];

while ($context['finished'] < 1) {
call_user_func_array($operation[0], array_merge($operation[1], [&$context]));
if (isset($context['message']) && $context['message'] !== $last_message) {
$io->text($t($context['message']));
}
$last_message = $context['message'];

gc_collect_cycles();
}
}
}

}
39 changes: 39 additions & 0 deletions modules/apigee_edge_teams/src/CliServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* Copyright 2022 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.
*/

namespace Drupal\apigee_edge_teams;

use Symfony\Component\Console\Style\StyleInterface;

/**
* Defines an interface for CLI service classes.
*/
interface CliServiceInterface {

/**
* Handle the sync interaction.
*
* @param \Symfony\Component\Console\Style\StyleInterface $io
* The IO interface of the CLI tool calling the method.
* @param callable $t
* The translation function akin to t().
*/
public function sync(StyleInterface $io, callable $t);

}
61 changes: 61 additions & 0 deletions modules/apigee_edge_teams/src/Commands/ApigeeEdgeCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

/**
* Copyright 2022 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.
*/

namespace Drupal\apigee_edge_teams\Commands;

use Consolidation\AnnotatedCommand\CommandData;
use Drupal\apigee_edge_teams\CliServiceInterface;
use Drush\Commands\DrushCommands;

/**
* Drush 9 command file.
*/
class ApigeeEdgeCommands extends DrushCommands {

/**
* The interoperability cli service.
*
* @var \Drupal\apigee_edge_teams\CliServiceInterface
*/
protected $cliService;

/**
* ApigeeEdgeCommands constructor.
*
* @param \Drupal\apigee_edge_teams\CliServiceInterface $cli_service
* The CLI service which allows interoperability.
*/
public function __construct(CliServiceInterface $cli_service = NULL) {
parent::__construct();
$this->cliService = $cli_service;
}

/**
* Team Member synchronization.
*
* @command apigee-edge-teams:sync
*
* @usage drush apigee-edge-teams:sync
* Starts the team member synchronization.
*/
public function sync() {
$this->cliService->sync($this->io(), 'dt');
}

}
Loading

0 comments on commit 1e650ae

Please sign in to comment.