public function run(ScriptEvent $event): bool
    {
        $composer = $event->getComposer();
        $composerConfig = $composer->getConfig();
        $basePath = realpath(substr($composerConfig->get('vendor-dir'), 0, -strlen($composerConfig->get('vendor-dir', $composerConfig::RELATIVE_PATHS))));
        $commandConfiguration = [];
        foreach ($this->extractPackageMapFromComposer($composer) as $item) {
            /** @var \Composer\Package\PackageInterface $package */
            list($package, $installPath) = $item;
            $installPath = ($installPath ?: $basePath);
            $packageName = $package->getName();
            $packageType = $package->getType();
            if (in_array($packageType, ['metapackage', 'typo3-cms-extension', 'typo3-cms-framework'], true)) {
                // Commands in TYPO3 extensions are scanned for anyway at a later point.
                // With that we ensure not showing commands for extensions that aren't active.
                // Since meta packages have no code, thus cannot include any commands, we ignore them as well.
                continue;
            }
            $packageConfig = $this->getConfigFromPackage($installPath, $packageName);
            if ($packageConfig !== []) {
                $commandConfiguration[] = $packageConfig;
            }
        }

        $success = file_put_contents(
            __DIR__ . '/../../../../Configuration/ComposerPackagesCommands.php',
            '<?php' . chr(10)
            . 'return '
            . var_export($commandConfiguration, true)
            . ';'
        );

        return $success !== false;
    }
public function run(ScriptEvent $event): bool
    {
        $composer = $event->getComposer();
        $composerConfig = $composer->getConfig();
        $basePath = realpath(substr($composerConfig->get('vendor-dir'), 0, -strlen($composerConfig->get('vendor-dir', $composerConfig::RELATIVE_PATHS))));
        $commandConfiguration = [];
        foreach ($this->extractPackageMapFromComposer($composer) as $item) {
            /** @var \Composer\Package\PackageInterface $package */
            list($package, $installPath) = $item;
            $installPath = ($installPath ?: $basePath);
            $packageName = $package->getName();
            $packageType = $package->getType();
            if (in_array($packageType, ['metapackage', 'typo3-cms-extension', 'typo3-cms-framework'], true)) {
                // Commands in TYPO3 extensions are scanned for anyway at a later point.
                // With that we ensure not showing commands for extensions that aren't active.
                // Since meta packages have no code, thus cannot include any commands, we ignore them as well.
                continue;
            }
            $packageConfig = $this->getConfigFromPackage($installPath, $packageName);
            if ($packageConfig !== []) {
                $commandConfiguration[] = $packageConfig;
            }
        }

        $success = file_put_contents(
            __DIR__ . '/../../../../Configuration/ComposerPackagesCommands.php',
            '<?php' . chr(10)
            . 'return '
            . var_export($commandConfiguration, true)
            . ';'
        );

        return $success !== false;
    }
public function run ( ScriptEvent $ event ) : bool { $ composer = $ event -> getComposer ( ) ; $ composerConfig = $ composer -> getConfig ( ) ; $ basePath = realpath ( substr ( $ composerConfig -> get ( 'vendor-dir' ) , 0 , - strlen ( $ composerConfig -> get ( 'vendor-dir' , $ composerConfig :: RELATIVE_PATHS ) ) ) ) ; $ commandConfiguration = [ ] ; foreach ( $ this -> extractPackageMapFromComposer ( $ composer ) as $ item ) { /** @var \Composer\Package\PackageInterface $package */ list ( $ package , $ installPath ) = $ item ; $ installPath = ( $ installPath ? : $ basePath ) ; $ packageName = $ package -> getName ( ) ; $ packageType = $ package -> getType ( ) ; if ( in_array ( $ packageType , [ 'metapackage' , 'typo3-cms-extension' , 'typo3-cms-framework' ] , true ) ) { // Commands in TYPO3 extensions are scanned for anyway at a later point. // With that we ensure not showing commands for extensions that aren't active. // Since meta packages have no code, thus cannot include any commands, we ignore them as well. continue ; } $ packageConfig = $ this -> getConfigFromPackage ( $ installPath , $ packageName ) ; if ( $ packageConfig !== [ ] ) { $ commandConfiguration [ ] = $ packageConfig ; } } $ success = file_put_contents ( __DIR__ . '/../../../../Configuration/ComposerPackagesCommands.php' , '<?php' . chr ( 10 ) . 'return ' . var_export ( $ commandConfiguration , true ) . ';' ) ; return $ success !== false ; }
Called from Composer

@param ScriptEvent $event
@return bool
@internal
Called from Composer