diff --git a/Taskfile.yml b/Taskfile.yml index 401ab912e..9452b6c71 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -382,6 +382,11 @@ tasks: cmds: - cmd: task dev:cli -- drush default-content:export-module dpl_example_content + dev:go:graphql-credentials: + desc: Get the GraphQL consumer credentials + cmds: + - cmd: task dev:cli -- drush dpl_consumers:consumer-credentials + ci:reset: desc: Create CI setup in a clean state cmds: diff --git a/web/modules/custom/dpl_consumers/dpl_consumers.module b/web/modules/custom/dpl_consumers/dpl_consumers.module new file mode 100644 index 000000000..0eb0820fb --- /dev/null +++ b/web/modules/custom/dpl_consumers/dpl_consumers.module @@ -0,0 +1,36 @@ +getStorage('consumer') + ->loadByProperties(['client_id' => $client_id]); + + // We assume that there is only one consumer with the given client ID + // as it is used an as unique identifier (machine name). + if (!empty($consumer)) { + $consumer = reset($consumer); + + return $consumer->uuid() ?? throw new \Exception('UUID not found.'); + } + else { + throw new \Exception('Consumer not found.'); + } + } + catch (\Exception $e) { + throw new \Exception($e->getMessage()); + } +} diff --git a/web/modules/custom/dpl_consumers/drush.services.yml b/web/modules/custom/dpl_consumers/drush.services.yml new file mode 100644 index 000000000..350f43c43 --- /dev/null +++ b/web/modules/custom/dpl_consumers/drush.services.yml @@ -0,0 +1,5 @@ +services: + dpl_consumer.commands: + class: \Drupal\dpl_consumers\Commands\DplConsumersCommands + tags: + - { name: drush.command } diff --git a/web/modules/custom/dpl_consumers/src/Commands/DplConsumersCommands.php b/web/modules/custom/dpl_consumers/src/Commands/DplConsumersCommands.php new file mode 100644 index 000000000..ad9496eb1 --- /dev/null +++ b/web/modules/custom/dpl_consumers/src/Commands/DplConsumersCommands.php @@ -0,0 +1,26 @@ +output()->writeln('Consumer UUID: ' . $consumer_uuid); + } + +}