예제 #1
0
 /**
  * @param \Venne\Packages\IPackage $package
  */
 public function install(IPackage $package)
 {
     try {
         $name = $package->getName();
         $configuration = $package->getConfiguration();
         // create resources dir
         if ($package->getRelativePublicPath()) {
             $resourcesDir = $this->resourcesDir;
             $packageDir = $resourcesDir . '/' . $name;
             $targetDir = realpath($package->getPath() . $package->getRelativePublicPath());
             if (!is_dir($packageDir) && is_dir($targetDir)) {
                 umask(00);
                 @mkdir(dirname($packageDir), 0777, true);
                 if (!@symlink(Helpers::getRelativePath(dirname($packageDir), $targetDir), $packageDir) && !is_dir($packageDir)) {
                     FileSystem::copy($targetDir, $packageDir);
                 }
                 $this->actions[] = function () use($resourcesDir) {
                     if (is_link($resourcesDir)) {
                         unlink($resourcesDir);
                     } else {
                         FileSystem::delete($resourcesDir);
                     }
                 };
             }
         }
         // update main config.neon
         if (count($configuration) > 0) {
             $orig = $data = $this->loadConfig();
             $data = array_merge_recursive($data, $configuration);
             $this->saveConfig($data);
             $this->actions[] = function ($self) use($orig) {
                 $self->saveConfig($orig);
             };
         }
     } catch (\Exception $e) {
         $actions = array_reverse($this->actions);
         try {
             foreach ($actions as $action) {
                 $action($this);
             }
         } catch (\Exception $ex) {
             echo $ex->getMessage();
         }
         throw $e;
     }
 }
예제 #2
0
파일: Solver.php 프로젝트: venne/packages
 /**
  * @param \Venne\Packages\IPackage $package
  * @param \Venne\Packages\DependencyResolver\Problem $problem
  */
 public function testInstall(IPackage $package, Problem $problem = null)
 {
     $installedPackages =& $this->installedPackages;
     $packages =& $this->packages;
     foreach ($package->getRequire() as $name) {
         if (!isset($installedPackages[$name])) {
             if ($problem && isset($packages[$name])) {
                 $solver = $this->createSolver();
                 $solver->testInstall($packages[$name], $problem);
                 $job = new Job(Job::ACTION_INSTALL, $packages[$name]);
                 if (!$problem->hasSolution($job)) {
                     $problem->addSolution($job);
                 }
                 $installedPackages[$name] = $packages[$name];
                 $tr = array($this->libsDir => '%libsDir%');
                 $this->packagesConfig[$name] = array(PackageManager::PACKAGE_STATUS => PackageManager::STATUS_INSTALLED, PackageManager::PACKAGE_PATH => str_replace(array_keys($tr), array_merge($tr), $package->getPath()));
             } else {
                 throw new InvalidArgumentException(sprintf('Package \'%s\' depend on \'%s\', which was not found.', $package->getName(), $name));
             }
         }
     }
 }
예제 #3
0
 /**
  * Registration of package.
  *
  * @param \Venne\Packages\IPackage $package
  */
 private function register(IPackage $package)
 {
     $packageConfig =& $this->getPackageConfig();
     if (!array_search($package->getName(), $packageConfig)) {
         $packageConfig[$package->getName()] = array(self::PACKAGE_STATUS => self::STATUS_UNINSTALLED, self::PACKAGE_PATH => $this->getFormattedPath($package->getPath()), self::PACKAGE_VERSION => $this->getVersion($package), self::PACKAGE_METADATA => array('authors' => $package->getAuthors(), 'description' => $package->getDescription(), 'keywords' => $package->getKeywords(), 'license' => $package->getLicense(), 'require' => $package->getRequire(), 'extra' => array('venne' => array('configuration' => $package->getConfiguration(), 'installers' => $package->getInstallers(), 'relativePublicPath' => $package->getRelativePublicPath()))));
     }
     $this->savePackageConfig();
     $this->onRegister($this, $package);
 }