Chris@0: 'AimeosInstaller', Chris@0: 'asgard' => 'AsgardInstaller', Chris@0: 'attogram' => 'AttogramInstaller', Chris@0: 'agl' => 'AglInstaller', Chris@0: 'annotatecms' => 'AnnotateCmsInstaller', Chris@0: 'bitrix' => 'BitrixInstaller', Chris@0: 'bonefish' => 'BonefishInstaller', Chris@0: 'cakephp' => 'CakePHPInstaller', Chris@0: 'chef' => 'ChefInstaller', Chris@0: 'ccframework' => 'ClanCatsFrameworkInstaller', Chris@0: 'cockpit' => 'CockpitInstaller', Chris@0: 'codeigniter' => 'CodeIgniterInstaller', Chris@0: 'concrete5' => 'Concrete5Installer', Chris@0: 'craft' => 'CraftInstaller', Chris@0: 'croogo' => 'CroogoInstaller', Chris@0: 'dokuwiki' => 'DokuWikiInstaller', Chris@0: 'dolibarr' => 'DolibarrInstaller', Chris@0: 'decibel' => 'DecibelInstaller', Chris@0: 'drupal' => 'DrupalInstaller', Chris@0: 'elgg' => 'ElggInstaller', Chris@0: 'eliasis' => 'EliasisInstaller', Chris@0: 'ee3' => 'ExpressionEngineInstaller', Chris@0: 'ee2' => 'ExpressionEngineInstaller', Chris@0: 'ezplatform' => 'EzPlatformInstaller', Chris@0: 'fuel' => 'FuelInstaller', Chris@0: 'fuelphp' => 'FuelphpInstaller', Chris@0: 'grav' => 'GravInstaller', Chris@0: 'hurad' => 'HuradInstaller', Chris@0: 'imagecms' => 'ImageCMSInstaller', Chris@0: 'itop' => 'ItopInstaller', Chris@0: 'joomla' => 'JoomlaInstaller', Chris@0: 'kanboard' => 'KanboardInstaller', Chris@0: 'kirby' => 'KirbyInstaller', Chris@0: 'kodicms' => 'KodiCMSInstaller', Chris@0: 'kohana' => 'KohanaInstaller', Chris@0: 'lms' => 'LanManagementSystemInstaller', Chris@0: 'laravel' => 'LaravelInstaller', Chris@0: 'lavalite' => 'LavaLiteInstaller', Chris@0: 'lithium' => 'LithiumInstaller', Chris@0: 'magento' => 'MagentoInstaller', Chris@0: 'mako' => 'MakoInstaller', Chris@0: 'maya' => 'MayaInstaller', Chris@0: 'mautic' => 'MauticInstaller', Chris@0: 'mediawiki' => 'MediaWikiInstaller', Chris@0: 'microweber' => 'MicroweberInstaller', Chris@0: 'modulework' => 'MODULEWorkInstaller', Chris@0: 'modxevo' => 'MODXEvoInstaller', Chris@0: 'moodle' => 'MoodleInstaller', Chris@0: 'october' => 'OctoberInstaller', Chris@0: 'ontowiki' => 'OntoWikiInstaller', Chris@0: 'oxid' => 'OxidInstaller', Chris@0: 'osclass' => 'OsclassInstaller', Chris@0: 'phpbb' => 'PhpBBInstaller', Chris@0: 'pimcore' => 'PimcoreInstaller', Chris@0: 'piwik' => 'PiwikInstaller', Chris@0: 'plentymarkets'=> 'PlentymarketsInstaller', Chris@0: 'ppi' => 'PPIInstaller', Chris@0: 'puppet' => 'PuppetInstaller', Chris@0: 'radphp' => 'RadPHPInstaller', Chris@0: 'phifty' => 'PhiftyInstaller', Chris@0: 'porto' => 'PortoInstaller', Chris@0: 'redaxo' => 'RedaxoInstaller', Chris@0: 'reindex' => 'ReIndexInstaller', Chris@0: 'roundcube' => 'RoundcubeInstaller', Chris@0: 'shopware' => 'ShopwareInstaller', Chris@0: 'silverstripe' => 'SilverStripeInstaller', Chris@0: 'smf' => 'SMFInstaller', Chris@0: 'sydes' => 'SyDESInstaller', Chris@0: 'symfony1' => 'Symfony1Installer', Chris@0: 'thelia' => 'TheliaInstaller', Chris@0: 'tusk' => 'TuskInstaller', Chris@0: 'typo3-cms' => 'TYPO3CmsInstaller', Chris@0: 'typo3-flow' => 'TYPO3FlowInstaller', Chris@0: 'userfrosting' => 'UserFrostingInstaller', Chris@0: 'vanilla' => 'VanillaInstaller', Chris@0: 'whmcs' => 'WHMCSInstaller', Chris@0: 'wolfcms' => 'WolfCMSInstaller', Chris@0: 'wordpress' => 'WordPressInstaller', Chris@0: 'yawik' => 'YawikInstaller', Chris@0: 'zend' => 'ZendInstaller', Chris@0: 'zikula' => 'ZikulaInstaller', Chris@0: 'prestashop' => 'PrestashopInstaller' Chris@0: ); Chris@0: Chris@0: /** Chris@0: * {@inheritDoc} Chris@0: */ Chris@0: public function getInstallPath(PackageInterface $package) Chris@0: { Chris@0: $type = $package->getType(); Chris@0: $frameworkType = $this->findFrameworkType($type); Chris@0: Chris@0: if ($frameworkType === false) { Chris@0: throw new \InvalidArgumentException( Chris@0: 'Sorry the package type of this package is not yet supported.' Chris@0: ); Chris@0: } Chris@0: Chris@0: $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; Chris@0: $installer = new $class($package, $this->composer, $this->getIO()); Chris@0: Chris@0: return $installer->getInstallPath($package, $frameworkType); Chris@0: } Chris@0: Chris@0: public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) Chris@0: { Chris@0: if (!$repo->hasPackage($package)) { Chris@0: throw new \InvalidArgumentException('Package is not installed: '.$package); Chris@0: } Chris@0: Chris@0: $repo->removePackage($package); Chris@0: Chris@0: $installPath = $this->getInstallPath($package); Chris@0: $this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? 'deleted' : 'not deleted')); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritDoc} Chris@0: */ Chris@0: public function supports($packageType) Chris@0: { Chris@0: $frameworkType = $this->findFrameworkType($packageType); Chris@0: Chris@0: if ($frameworkType === false) { Chris@0: return false; Chris@0: } Chris@0: Chris@0: $locationPattern = $this->getLocationPattern($frameworkType); Chris@0: Chris@0: return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Finds a supported framework type if it exists and returns it Chris@0: * Chris@0: * @param string $type Chris@0: * @return string Chris@0: */ Chris@0: protected function findFrameworkType($type) Chris@0: { Chris@0: $frameworkType = false; Chris@0: Chris@0: krsort($this->supportedTypes); Chris@0: Chris@0: foreach ($this->supportedTypes as $key => $val) { Chris@0: if ($key === substr($type, 0, strlen($key))) { Chris@0: $frameworkType = substr($type, 0, strlen($key)); Chris@0: break; Chris@0: } Chris@0: } Chris@0: Chris@0: return $frameworkType; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the second part of the regular expression to check for support of a Chris@0: * package type Chris@0: * Chris@0: * @param string $frameworkType Chris@0: * @return string Chris@0: */ Chris@0: protected function getLocationPattern($frameworkType) Chris@0: { Chris@0: $pattern = false; Chris@0: if (!empty($this->supportedTypes[$frameworkType])) { Chris@0: $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; Chris@0: /** @var BaseInstaller $framework */ Chris@0: $framework = new $frameworkClass(null, $this->composer, $this->getIO()); Chris@0: $locations = array_keys($framework->getLocations()); Chris@0: $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; Chris@0: } Chris@0: Chris@0: return $pattern ? : '(\w+)'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get I/O object Chris@0: * Chris@0: * @return IOInterface Chris@0: */ Chris@0: private function getIO() Chris@0: { Chris@0: return $this->io; Chris@0: } Chris@0: }