-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
772 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
php-version: | ||
- "7.4" | ||
- "8.0" | ||
- "8.1" | ||
drupal-core: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
61
modules/apigee_edge_teams/src/Commands/ApigeeEdgeCommands.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
|
||
} |
Oops, something went wrong.