本文整理汇总了PHP中PharData::setMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP PharData::setMetadata方法的具体用法?PHP PharData::setMetadata怎么用?PHP PharData::setMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PharData
的用法示例。
在下文中一共展示了PharData::setMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
$language = $input->getArgument('language');
$tmpFolder = $input->getOption('tmp');
$_configuration = $this->getHelper('configuration')->getConfiguration();
$connection = $this->getHelper('configuration')->getConnection();
if ($connection) {
$lang = isset($language) ? $language : null;
$lang = mysql_real_escape_string($lang);
$q = mysql_query("SELECT * FROM language WHERE english_name = '{$lang}' ");
$langInfo = mysql_fetch_array($q, MYSQL_ASSOC);
if (!$langInfo) {
$output->writeln("<comment>Language '{$lang}' is not registered in the Chamilo Database</comment>");
$q = mysql_query("SELECT * FROM language WHERE parent_id IS NULL or parent_id = 0");
$output->writeln("<comment>Available languages are: </comment>");
while ($langRow = mysql_fetch_array($q, MYSQL_ASSOC)) {
$output->write($langRow['english_name'] . ", ");
}
$output->writeln(' ');
$q = mysql_query("SELECT * FROM language WHERE parent_id <> 0");
$output->writeln("<comment>Available sub languages are: </comment>");
while ($langRow = mysql_fetch_array($q, MYSQL_ASSOC)) {
$output->write($langRow['english_name'] . ", ");
}
$output->writeln(' ');
exit;
} else {
$output->writeln("<comment>Language</comment> <info>'{$lang}'</info> <comment>is registered in the Chamilo installation with iso code: </comment><info>{$langInfo['isocode']} </info>");
}
$langFolder = $_configuration['root_sys'] . 'main/lang/' . $lang;
if (!is_dir($langFolder)) {
$output->writeln("<comment>Language '{$lang}' does not exist in the path: {$langFolder}</comment>");
}
if (empty($tmpFolder)) {
$tmpFolder = '/tmp/';
$output->writeln("<comment>No temporary directory defined. Assuming /tmp/. Please make sure you have *enough space* left on that device");
}
if (!is_dir($tmpFolder)) {
$output->writeln("<comment>Temporary directory: {$tmpFolder} is not a valid dir path, using /tmp/ </comment>");
$tmpFolder = '/tmp/';
}
if ($langInfo) {
$output->writeln("<comment>Creating translation package</comment>");
$fileName = $tmpFolder . $langInfo['english_name'] . '.tar';
$phar = new \PharData($fileName);
$phar->buildFromDirectory($langFolder);
$phar->setMetadata($langInfo);
$output->writeln("<comment>File created:</comment> <info>{$fileName}</info>");
}
}
}
示例2: pack
/**
* Create PHAR archive
*
* @param string &$name Pack name
* @param \Iterator $iterator Directory iterator
* @param array $metadata Archive description OPTIONAL
* @param boolean $compress Flag OPTIONAL
*
* @return \Phar
*/
protected static function pack(&$name, \Iterator $iterator, array $metadata = array(), $compress = true)
{
// To prevent existsing files usage
\Includes\Utils\FileManager::deleteFile($name);
$phar = new \PharData($name);
// Files
$phar->buildFromIterator($iterator, LC_DIR_ROOT);
// Metadata
$phar->setMetadata($metadata);
// File hashes
static::addPackHash($phar, $iterator);
// GZ compression
return $compress ? static::compress($phar, $name) : $phar;
}