Ejemplo n.º 1
0
 function __construct($package, \Pyrus\Package $parent, \Pyrus\PackageFile $info = null)
 {
     $this->archive = $package;
     if ($info === null) {
         $info = new \Pyrus\PackageFile($package);
     }
     parent::__construct($info, $parent);
 }
Ejemplo n.º 2
0
 /**
  * @param string $package path to package file
  */
 function __construct($package, \Pyrus\Package $parent)
 {
     $package = realpath($package);
     if (!$package) {
         throw new Phar\Exception('Phar package ' . $package . ' does not exist');
     }
     $pxml = false;
     $this->archive = $package;
     try {
         if (\Phar::isValidPharFilename($package, 1)) {
             $phar = new \Phar($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
             $pxml = 'phar://' . $package . '/' . $phar->getMetaData();
         } else {
             $phar = new \PharData($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
             if ($phar->getMetaData()) {
                 $pxml = 'phar://' . $package . '/' . $phar->getMetaData();
             }
         }
     } catch (\Exception $e) {
         throw new Phar\Exception('Could not open Phar archive ' . $package, $e);
     }
     $package = str_replace('\\', '/', $package);
     try {
         if ($pxml === false) {
             $info = pathinfo($package);
             $internal = $info['filename'];
             if (isset($phar[$internal . '/.xmlregistry'])) {
                 if ($phar instanceof \PharData) {
                     $iterate = new \PharData('phar://' . $package . '/' . $internal . '/.xmlregistry');
                 } else {
                     $iterate = new \Phar('phar://' . $package . '/' . $internal . '/.xmlregistry');
                 }
                 foreach (new \RecursiveIteratorIterator($iterate, \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
                     $filename = $file->getFileName();
                     // default to new package.xml
                     if (preg_match('@^(.+)\\-package.xml$@', $filename)) {
                         $pxml = $file->getPathName();
                         break;
                     }
                 }
             } else {
                 foreach (array('package2.xml', $internal . '/' . 'package2.xml', 'package.xml', $internal . '/' . 'package.xml') as $checkfile) {
                     if (isset($phar[$checkfile])) {
                         $this->_BCpackage = true;
                         $pxml = $phar[$checkfile]->getPathName();
                         break;
                     }
                 }
             }
         }
         if ($pxml === false) {
             throw new Phar\Exception('No package.xml in archive');
         }
     } catch (\Exception $e) {
         throw new Phar\Exception('Could not extract Phar archive ' . $package, $e);
     }
     parent::__construct(new \Pyrus\PackageFile($pxml, 'Pyrus\\PackageFile\\v2'), $parent);
 }
Ejemplo n.º 3
0
 function __construct(\Pyrus\PackageFile $packagefile, $parent = null, \Pyrus\Registry $registry)
 {
     $this->registry = $registry;
     parent::__construct($packagefile, $parent);
 }