From ac72ddbea5f1f4fc2b418ebe2a186dba9bb8d25e Mon Sep 17 00:00:00 2001
From: Grzegorz Rola <grola@seostudio.pl>
Date: Thu, 5 Aug 2021 14:06:45 +0200
Subject: [PATCH] feature(init): initial version

---
 .../Composer/CommandProvider.php              | 18 ++++++++++
 src/ActivationReminder/Composer/Plugin.php    | 11 +++++-
 .../PrepareActivationReminderCommand.php      | 36 +++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 src/ActivationReminder/Composer/CommandProvider.php
 create mode 100644 src/ActivationReminder/Composer/PrepareActivationReminderCommand.php

diff --git a/src/ActivationReminder/Composer/CommandProvider.php b/src/ActivationReminder/Composer/CommandProvider.php
new file mode 100644
index 0000000..d25a197
--- /dev/null
+++ b/src/ActivationReminder/Composer/CommandProvider.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace WPDesk\ActivationReminder\Composer;
+
+/**
+ * Links plugin commands handlers to composer
+ *
+ * @package WPDesk\ActivationReminder\Composer
+ */
+class CommandProvider implements \Composer\Plugin\Capability\CommandProvider
+{
+    public function getCommands()
+    {
+        return [
+            new PrepareActivationReminderCommand(),
+        ];
+    }
+}
\ No newline at end of file
diff --git a/src/ActivationReminder/Composer/Plugin.php b/src/ActivationReminder/Composer/Plugin.php
index 838f4bb..e7bb64d 100644
--- a/src/ActivationReminder/Composer/Plugin.php
+++ b/src/ActivationReminder/Composer/Plugin.php
@@ -67,12 +67,21 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
 		$this->io = $io;
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	public function getCapabilities(): array
+	{
+		return [
+			\Composer\Plugin\Capability\CommandProvider::class => CommandProvider::class
+		];
+	}
 
 	/**
 	 * @param Event $event
 	 */
 	public function generateReminder(Event $event) {
-		error_log('generate reminder');
+		passthru("composer prepare-activation-reminder");
 	}
 
 }
diff --git a/src/ActivationReminder/Composer/PrepareActivationReminderCommand.php b/src/ActivationReminder/Composer/PrepareActivationReminderCommand.php
new file mode 100644
index 0000000..b195316
--- /dev/null
+++ b/src/ActivationReminder/Composer/PrepareActivationReminderCommand.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace WPDesk\ActivationReminder\Composer;
+
+use Composer\Command\BaseCommand;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+
+/**
+ * Can prepare activation reminder for plugin.
+ *
+ * @package WPDesk\Composer\GitPlugin\Command
+ */
+class PrepareActivationReminderCommand extends BaseCommand
+{
+
+    protected function configure()
+    {
+        $this
+            ->setName('prepare-activation-reminder')
+            ->setDescription('Prepares activation reminder for WP Desk plugin.');
+    }
+
+    /**
+     * Execute command.
+     *
+     * @param InputInterface $input
+     * @param OutputInterface $output
+     * @return int|void|null
+     */
+    protected function execute(InputInterface $input, OutputInterface $output)
+    {
+	    $output->writeln("Activation reminder created.");
+    }
+}
-- 
GitLab