MagentoHackathon\Composer\Magento\Plugin::deployLibraries PHP Method

deployLibraries() protected method

protected deployLibraries ( )
    protected function deployLibraries()
    {
        $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
        $autoloadDirectories = array();
        $libraryPath = $this->config->getLibraryPath();
        if ($libraryPath === null) {
            if ($this->io->isDebug()) {
                $this->io->write('jump over deployLibraries as no Magento libraryPath is set');
            }
            return;
        }
        $vendorDir = rtrim($this->composer->getConfig()->get('vendor-dir'), '/');
        $filesystem = $this->filesystem;
        $filesystem->removeDirectory($libraryPath);
        $filesystem->ensureDirectoryExists($libraryPath);
        foreach ($packages as $package) {
            /** @var PackageInterface $package */
            $packageConfig = $this->config->getLibraryConfigByPackagename($package->getName());
            if ($packageConfig === null) {
                continue;
            }
            if (!isset($packageConfig['autoload'])) {
                $packageConfig['autoload'] = array('/');
            }
            foreach ($packageConfig['autoload'] as $path) {
                $autoloadDirectories[] = $libraryPath . '/' . $package->getName() . "/" . $path;
            }
            if ($this->io->isDebug()) {
                $this->io->write('Magento deployLibraries executed for ' . $package->getName());
            }
            $libraryTargetPath = $libraryPath . '/' . $package->getName();
            $filesystem->removeDirectory($libraryTargetPath);
            $filesystem->ensureDirectoryExists($libraryTargetPath);
            $this->copyRecursive($vendorDir . '/' . $package->getPrettyName(), $libraryTargetPath);
        }
        $autoloadGenerator = new AutoloadGenerator(new EventDispatcher($this->composer, $this->io));
        $classmap = ClassMapGenerator::createMap($libraryPath);
        $executable = $this->composer->getConfig()->get('bin-dir') . '/phpab';
        if (!file_exists($executable)) {
            $executable = $this->composer->getConfig()->get('vendor-dir') . '/theseer/autoload/composer/bin/phpab';
        }
        if (file_exists($executable)) {
            if ($this->io->isDebug()) {
                $this->io->write('Magento deployLibraries executes autoload generator');
            }
            $process = new Process($executable . " -o {$libraryPath}/autoload.php  " . implode(' ', $autoloadDirectories));
            $process->run();
        } else {
            if ($this->io->isDebug()) {
                $this->io->write('Magento deployLibraries autoload generator not availabel, you should require "theseer/autoload"');
                var_dump($executable, getcwd());
            }
        }
    }