-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract pear package parsing into separate file for framework utils
- Loading branch information
Showing
3 changed files
with
70 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
class PEAR_Package_Parse | ||
{ | ||
public $pear_pkg; | ||
|
||
public function __construct() | ||
{ | ||
// Create the local PEAR config. | ||
if (!(@include_once 'PEAR/Config.php') || | ||
!(@include_once 'PEAR/PackageFile.php')) { | ||
throw new Exception('PEAR libraries are not in the PHP include_path.'); | ||
} | ||
|
||
/* We are heavily relying on the PEAR libraries which are not clean | ||
* with regard to E_STRICT. */ | ||
if (defined('E_DEPRECATED')) { | ||
error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED); | ||
} else { | ||
error_reporting(E_ALL & ~E_STRICT); | ||
} | ||
|
||
$pear_config = PEAR_Config::singleton(); | ||
$this->pear_pkg = new PEAR_PackageFile($pear_config); | ||
} | ||
|
||
public function getPackages(array $srcDirs) | ||
{ | ||
$pkgs = array(); | ||
|
||
foreach ($srcDirs as $dir) { | ||
$di = new DirectoryIterator($dir); | ||
foreach ($di as $val) { | ||
$pathname = $val->getPathname(); | ||
if ($val->isDir() && | ||
!$di->isDot() && | ||
file_exists($pathname . '/package.xml')) { | ||
$pkgs[basename($val)] = $pathname; | ||
} elseif ($val->isFile() && | ||
($val == 'package.xml')) { | ||
$pkgs[basename($val->getPath())] = $val->getPath(); | ||
} | ||
} | ||
} | ||
|
||
asort($pkgs); | ||
|
||
return $pkgs; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters