Jarves\Controller\Admin\BundleManager\ManagerController::uninstallComposerAction PHP Method

uninstallComposerAction() public method

public uninstallComposerAction ( FOS\RestBundle\Request\ParamFetcher $paramFetcher ) : string
$paramFetcher FOS\RestBundle\Request\ParamFetcher
return string
    public function uninstallComposerAction(ParamFetcher $paramFetcher)
    {
        $name = $paramFetcher->get('name');
        $fs = $this->localFilesystem;
        if ($fs->has('composer.json') && is_string($name)) {
            $composer = $fs->read('composer.json');
            if ($composer) {
                $composer = json_decode($composer, true);
                if (is_array($composer)) {
                    $pathToDelete = false;
                    foreach ($composer['require'] as $key => $value) {
                        if (strtolower($key) == strtolower($name)) {
                            unset($composer['require'][$key]);
                            $pathToDelete = $key;
                        }
                    }
                    $fs->write('composer.json', json_encode($composer, JSON_PRETTY_PRINT));
                    if ($pathToDelete) {
                        $this->searchAndUninstallBundles($this->getComposerVendorDir() . $pathToDelete);
                        $fs->delete($this->getComposerVendorDir() . $pathToDelete);
                        if (file_exists($pathToDelete)) {
                            $this->getLogger()->warning(sprintf('[UninstallComposer] Can not delete folder `%s`.', $pathToDelete));
                        }
                    } else {
                        throw new PackageNotFoundException(sprintf('Package `%s` not found.', $name));
                    }
                    $this->updateAutoloader();
                    return true;
                }
            }
        }
        return false;
    }