Beispiel #1
0
 public function getGuid()
 {
     if (null !== $this->_targetPackage) {
         return $this->_targetPackage->getGuid();
     } else {
         return $this->_currentPackage->getGuid();
     }
 }
Beispiel #2
0
 /**
  * @param array $options
  * @return Engine_Package_Manager_PackageCollection
  */
 public function listInstalledPackages($options = array())
 {
     if (null !== $this->_installedPackages) {
         return $this->_installedPackages;
     }
     // Generate
     $installedPackages = new Engine_Package_Manager_PackageCollection($this, array(), $options);
     $it = new DirectoryIterator($this->getAbsPath(self::PATH_INSTALLED));
     // List installed packages
     foreach ($it as $file) {
         if ($file->isDot() || $file->isDir() || $file->getFilename() === 'index.html') {
             continue;
         }
         try {
             $packageFile = new Engine_Package_Manifest($file->getPathname());
             // Reset base path
             $packageFile->setBasePath($this->_basePath);
             // Check for package files for two versions of the package
             $guid = $packageFile->getGuid();
             if ($installedPackages->hasGuid($guid)) {
                 /*
                           $otherPackageKey = $installedPackages->getKeyByGuid($guid);
                           $otherPackageVersion = trim(str_replace($guid, '', $otherPackageKey), '.:-');
                           if( version_compare($packageFile->getVersion(), $otherPackageVersion, '>') ) {
                  $installedPackages->append($packageFile);
                           }
                 *
                 */
                 $otherPackage = $installedPackages->offsetGet($packageFile->getGuid());
                 if (version_compare($packageFile->getVersion(), $otherPackage->getVersion(), '>')) {
                     $installedPackages->append($packageFile);
                 }
             } else {
                 $installedPackages->append($packageFile);
             }
             unset($packageFile);
         } catch (Exception $e) {
             // Silence?
             if (APPLICATION_ENV == 'development') {
                 throw $e;
             }
         }
     }
     // Order? -- @todo probably should switch to priority later
     $installedPackages->ksort();
     return $this->_installedPackages = $installedPackages;
 }