|
@@ -4,28 +4,15 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace SixShop\Core;
|
|
namespace SixShop\Core;
|
|
|
|
|
|
|
|
-use Composer\Composer;
|
|
|
|
|
-use Composer\EventDispatcher\EventSubscriberInterface;
|
|
|
|
|
use Composer\InstalledVersions;
|
|
use Composer\InstalledVersions;
|
|
|
-use Composer\IO\IOInterface;
|
|
|
|
|
-use Composer\Plugin\PluginInterface;
|
|
|
|
|
-use Composer\Script\Event;
|
|
|
|
|
-use Composer\Script\ScriptEvents;
|
|
|
|
|
use RuntimeException;
|
|
use RuntimeException;
|
|
|
|
|
|
|
|
-class Plugin implements PluginInterface, EventSubscriberInterface
|
|
|
|
|
|
|
+class Plugin
|
|
|
{
|
|
{
|
|
|
public const string EXTENSION_TYPE = 'sixshop-extension';
|
|
public const string EXTENSION_TYPE = 'sixshop-extension';
|
|
|
|
|
|
|
|
public static array $installedSixShopExtensions = [];
|
|
public static array $installedSixShopExtensions = [];
|
|
|
|
|
|
|
|
- public static function getSubscribedEvents(): array
|
|
|
|
|
- {
|
|
|
|
|
- return [
|
|
|
|
|
- ScriptEvents::POST_AUTOLOAD_DUMP => 'onPostAutoloadDump',
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @return array{root: array{reference: string}, versions: array<string, array>}
|
|
* @return array{root: array{reference: string}, versions: array<string, array>}
|
|
|
*/
|
|
*/
|
|
@@ -41,36 +28,4 @@ class Plugin implements PluginInterface, EventSubscriberInterface
|
|
|
}
|
|
}
|
|
|
throw new RuntimeException('Please run "composer dump-autoload" to generate installedSixShop.php');
|
|
throw new RuntimeException('Please run "composer dump-autoload" to generate installedSixShop.php');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public function activate(Composer $composer, IOInterface $io): void
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function deactivate(Composer $composer, IOInterface $io): void
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function uninstall(Composer $composer, IOInterface $io): void
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function onPostAutoloadDump(Event $event): void
|
|
|
|
|
- {
|
|
|
|
|
- $installedSixShopExtensions = [
|
|
|
|
|
- 'root' => [],
|
|
|
|
|
- 'versions' => []
|
|
|
|
|
- ];
|
|
|
|
|
- $referenceMap = [];
|
|
|
|
|
- foreach (InstalledVersions::getAllRawData() as $installed) {
|
|
|
|
|
- foreach ($installed['versions'] as $name => $package) {
|
|
|
|
|
- if (isset($package['type']) && $package['type'] === self::EXTENSION_TYPE) {
|
|
|
|
|
- $installedSixShopExtensions['versions'][$name] = $package;
|
|
|
|
|
- $referenceMap[$name] = $package['reference'];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $installedSixShopExtensions['root']['reference'] = hash('md5', json_encode($referenceMap));
|
|
|
|
|
- $filePath = $event->getComposer()->getConfig()->get('vendor-dir') . '/composer/installedSixShop.php';
|
|
|
|
|
- file_put_contents($filePath, '<?php return ' . var_export($installedSixShopExtensions, true) . ';');
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|