src/CoreManager.php
public function checkCoreDependencies(InstallerEvent $event)
    {
        $options = new Options($this->composer->getPackage()->getExtra());
        $installedCorePackages = array();
        foreach ($event->getInstalledRepo()->getPackages() as $package) {
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                $installedCorePackages[$package->getName()] = $package;
            }
        }

        $operations = array_filter($event->getOperations(), function (OperationInterface $o) {
            return in_array($o->getJobType(), array('install', 'uninstall'));
        });

        foreach ($operations as $operation) {
            $p = $operation->getPackage();
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                switch ($operation->getJobType()) {
                    case "uninstall":
                        unset($installedCorePackages[$p->getName()]);
                        break;
                    case "install":
                        $installedCorePackages[$p->getName()] = $p;
                        break;
                }
            }
        }

        if (count($installedCorePackages) > 1) {
            throw new \RuntimeException("Cannot use more than 1 core package");
        }
    }
public function checkCoreDependencies(InstallerEvent $event)
    {
        $options = new Options($this->composer->getPackage()->getExtra());
        $installedCorePackages = array();
        foreach ($event->getInstalledRepo()->getPackages() as $package) {
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                $installedCorePackages[$package->getName()] = $package;
            }
        }

        $operations = array_filter($event->getOperations(), function (OperationInterface $o) {
            return in_array($o->getJobType(), array('install', 'uninstall'));
        });

        foreach ($operations as $operation) {
            $p = $operation->getPackage();
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                switch ($operation->getJobType()) {
                    case "uninstall":
                        unset($installedCorePackages[$p->getName()]);
                        break;
                    case "install":
                        $installedCorePackages[$p->getName()] = $p;
                        break;
                }
            }
        }

        if (count($installedCorePackages) > 1) {
            throw new \RuntimeException("Cannot use more than 1 core package");
        }
    }
public function checkCoreDependencies ( InstallerEvent $ event ) { $ options = new Options ( $ this -> composer -> getPackage ( ) -> getExtra ( ) ) ; $ installedCorePackages = array ( ) ; foreach ( $ event -> getInstalledRepo ( ) -> getPackages ( ) as $ package ) { if ( $ package -> getType ( ) === $ options -> getMagentoCorePackageType ( ) ) { $ installedCorePackages [ $ package -> getName ( ) ] = $ package ; } } $ operations = array_filter ( $ event -> getOperations ( ) , function ( OperationInterface $ o ) { return in_array ( $ o -> getJobType ( ) , array ( 'install' , 'uninstall' ) ) ; } ) ; foreach ( $ operations as $ operation ) { $ p = $ operation -> getPackage ( ) ; if ( $ package -> getType ( ) === $ options -> getMagentoCorePackageType ( ) ) { switch ( $ operation -> getJobType ( ) ) { case "uninstall" : unset ( $ installedCorePackages [ $ p -> getName ( ) ] ) ; break ; case "install" : $ installedCorePackages [ $ p -> getName ( ) ] = $ p ; break ; } } } if ( count ( $ installedCorePackages ) > 1 ) { throw new \ RuntimeException ( "Cannot use more than 1 core package" ) ; } }
Check that there is only 1 core package required
Check that there is only 1 core package required