本文整理汇总了PHP中PharData::getMetaData方法的典型用法代码示例。如果您正苦于以下问题:PHP PharData::getMetaData方法的具体用法?PHP PharData::getMetaData怎么用?PHP PharData::getMetaData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PharData
的用法示例。
在下文中一共展示了PharData::getMetaData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: realpath
/**
* @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);
}
示例2: __construct
/**
* Overloaded constructor
*
* @param string $path Path to the module package
*
* @return void
*/
public function __construct($path)
{
if (!\Includes\Utils\FileManager::isFileReadable($path)) {
\Includes\ErrorHandler::fireError('Unable to read module package: "' . $path . '"');
}
$this->setRepositoryPath($path);
$module = new \PharData($this->getRepositoryPath());
$this->metadata = $module->getMetaData();
if (empty($this->metadata)) {
\Includes\ErrorHandler::fireError('Unable to read module metadata: "' . $path . '"');
}
parent::__construct();
}