本文整理汇总了PHP中Package::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::getName方法的具体用法?PHP Package::getName怎么用?PHP Package::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run(array $arguments)
{
$json = $this->deps->nearestJson();
$package = new Package(dirname($json));
$porcelain = count($arguments) && $arguments[0] == 'porcelain';
if (!$porcelain) {
Terminal::info("From {$json}\n\n");
Terminal::bold("* project name: " . $package->getName() . "\n");
}
$dependencies = $package->getDependencies();
if ($porcelain) {
echo implode(':', $dependencies) . "\n";
} else {
if ($dependencies) {
Terminal::bold("* dependencies:\n");
foreach ($dependencies as $dep) {
echo " - {$dep} ";
if ($this->deps->hasPackage($dep)) {
Terminal::success("(installed)");
} else {
Terminal::warning("(not installed)");
}
echo "\n";
}
} else {
Terminal::bold("* no dependencies\n");
}
}
}
示例2: run
public function run(array $arguments)
{
$json = $this->deps->nearestJson();
$linkDir = dirname($json);
$package = new Package(dirname($json));
$name = $package->getName();
if (!$name) {
echo "Error: no name for package\n";
} else {
echo "* Linking package {$name} to {$linkDir}...\n";
$dir = $this->deps->getPackageDirectory($package->getName());
if (is_dir($dir)) {
OS::run("rm -rf {$dir}");
}
OS::run("ln -s {$linkDir} {$dir}");
}
}
示例3: run
public function run(array $arguments)
{
$json = $this->deps->nearestJson();
$linkDir = dirname($json);
$package = new Package(dirname($json));
$name = $package->getName();
if (!$name) {
echo "Error: no name for package\n";
} else {
echo "Do you want to create symlink from {$name} to {$linkDir}? (yes/no)\n";
$l = readline();
if (trim($l) == 'yes') {
echo "* Linking package {$name} to {$linkDir}...\n";
$dir = $this->deps->getPackageDirectory($package->getName());
if (is_dir($dir)) {
OS::run("rm -rf {$dir}");
}
OS::run("ln -s {$linkDir} {$dir}");
} else {
echo "Aborting.\n";
}
}
}
示例4: run
public function run(array $arguments)
{
if ($arguments) {
foreach ($arguments as $dep) {
$this->deps->build($dep);
}
} else {
$json = $this->deps->nearestJson();
$package = new Package(dirname($json));
$dependencies = $package->getDependencies();
foreach ($dependencies as $dep) {
$this->deps->build($dep);
}
$this->deps->build($package->getName());
}
return true;
}
示例5: run
public function run(array $arguments)
{
$json = $this->deps->nearestJson();
$package = new Package(dirname($json));
echo "From {$json}\n\n";
echo "* project name: " . $package->getName() . "\n";
$dependencies = $package->getDependencies();
if ($dependencies) {
echo "* dependencies:\n";
foreach ($dependencies as $dep) {
echo " - {$dep} ";
if ($this->deps->hasPackage($dep)) {
echo "(installed)";
} else {
echo "(not installed)";
}
echo "\n";
}
} else {
echo "* no dependencies\n";
}
}
示例6: printStatus
public function printStatus(Package $package)
{
$dir = $package->getDirectory();
$name = $package->getName();
$result = `cd {$dir}; LANG=en_US.UTF-8 git status`;
$errors = array();
$warnings = array();
$messages = array();
if (strstr($result, 'Changes not staged for commit:') !== false) {
$errors[] = 'Unstaged changes';
}
if (strstr($result, 'Changes to be committed:') !== false) {
$errors[] = 'Changes to commit';
}
if (strstr($result, 'Your branch is ahead of') !== false) {
$errors[] = 'Not pushed changes';
}
if (strstr($result, 'Your branch is behind') !== false) {
$warnings[] = 'Branch is behind origin';
}
if (strstr($result, 'Untracked files:') !== false) {
$warnings[] = 'Untracked files';
}
$messages = implode(', ', array_merge($errors, $warnings, $messages));
if ($messages) {
$messages = '(' . $messages . ')';
}
$branch = $package->getBranch();
if (count($errors)) {
Terminal::error("* [{$branch}] {$name}: ERROR {$messages}\n");
} else {
if (count($warnings)) {
Terminal::warning("* [{$branch}] {$name}: WARNING {$messages}\n");
} else {
Terminal::success("* [{$branch}] {$name}: OK {$messages}\n");
}
}
}
示例7: install
public function install($dep, $rebuildDeps = true)
{
if (isset($this->installed[$dep])) {
return;
}
$this->installed[$dep] = true;
if (!$this->hasPackage($dep)) {
Terminal::info("* Installing {$dep}...\n");
$target = $this->getPackageDirectory($dep);
if (is_dir($target)) {
OS::run("rm -rf {$target}");
}
$btarget = OS::bashize($target);
$remotes = $this->remotes->getRemotes();
$addr = $remotes[$this->remotes->getCurrent()];
$addr = sprintf($addr, $dep);
$return = OS::run("git clone --depth=1 {$addr} {$btarget}");
if ($return != 0) {
OS::run("rm -rf {$target}");
throw new \Exception("Unable to install package {$dep}");
}
$package = new Package($target);
if (!$package->hasConfig()) {
OS::run("rm -rf {$btarget}");
throw new \Exception("{$dep} doesn't look like a deps package (no deps.json)");
}
$package->updateRemotes($this->remotes, true);
$this->packages[$package->getName()] = $package;
} else {
$this->update($dep);
$package = $this->getPackage($dep);
}
$package->readConfig();
foreach ($package->getDependencies() as $sdep) {
if ($rebuildDeps) {
$this->install($sdep);
} else {
if (!$this->hasPackage($sdep)) {
$this->install($sdep);
}
}
}
$this->build($dep);
}
示例8: addQueueEntries
/**
* Adds an uninstall entry to the package installation queue.
*
* @param Package $package
* @param array $packages
*/
public static function addQueueEntries(Package $package, $packages = array())
{
// get new process no
$processNo = PackageInstallationQueue::getNewProcessNo();
// add dependent packages to queue
$inserts = '';
$userID = WCF::getUser()->userID;
foreach ($packages as $dependentPackage) {
if (!empty($inserts)) {
$inserts .= ',';
}
$inserts .= "(" . $processNo . ", " . $userID . ", '" . escapeString($dependentPackage['packageName']) . "', " . $dependentPackage['packageID'] . ", 'uninstall')";
}
// add uninstalling package to queue
if (!empty($inserts)) {
$inserts .= ',';
}
$inserts .= "(" . $processNo . ", " . $userID . ", '" . escapeString($package->getName()) . "', " . $package->getPackageID() . ", 'uninstall')";
// insert queue entry (entries)
$sql = "INSERT INTO\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\t\t(processNo, userID, package, packageID, action)\n\t\t\tVALUES\t\t" . $inserts;
WCF::getDB()->sendQuery($sql);
// open queue
HeaderUtil::redirect('index.php?page=Package&action=openQueue&processNo=' . $processNo . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
exit;
}
示例9: updatePackage
/**
* Updates an existing package.
*
* @param integer $packageID
* @param string $version new package version
*/
protected function updatePackage($packageID, $version)
{
// get package info
$package = new Package($packageID);
// get current package version
$packageVersion = $package->getVersion();
if (isset($this->virtualPackageVersions[$packageID])) {
$packageVersion = $this->virtualPackageVersions[$packageID];
// check virtual package version
if (Package::compareVersion($packageVersion, $version, '>=')) {
// virtual package version is greater than requested version
// skip package update
return;
}
}
// get highest version of the required major release
if (preg_match('/(\\d+\\.\\d+\\.)/', $version, $match)) {
$packageVersions = array();
$sql = "SELECT\tDISTINCT packageVersion\n\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\tWHERE\tpackageUpdateID IN (\n\t\t\t\t\t\tSELECT\tpackageUpdateID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\t\t\tWHERE\tpackage = '" . escapeString($package->getPackage()) . "'\n\t\t\t\t\t)\n\t\t\t\t\tAND packageVersion LIKE '" . escapeString($match[1]) . "%'";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$packageVersions[] = $row['packageVersion'];
}
if (count($packageVersions) > 1) {
// sort by version number
usort($packageVersions, array('Package', 'compareVersion'));
// get highest version
$version = array_pop($packageVersions);
}
}
// get all fromversion
$fromversions = array();
$sql = "SELECT\t\tpuv.packageVersion, puf.fromversion\n\t\t\tFROM\t\twcf" . WCF_N . "_package_update_fromversion puf\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_update_version puv\n\t\t\tON\t\t(puv.packageUpdateVersionID = puf.packageUpdateVersionID)\n\t\t\tWHERE\t\tpuf.packageUpdateVersionID IN (\n\t\t\t\t\t\tSELECT\tpackageUpdateVersionID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update_version\n\t\t\t\t\t\tWHERE \tpackageUpdateID IN (\n\t\t\t\t\t\t\tSELECT\tpackageUpdateID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_update\n\t\t\t\t\t\t\tWHERE\tpackage = '" . escapeString($package->getPackage()) . "'\n\t\t\t\t\t\t)\n\t\t\t\t\t)";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
if (!isset($fromversions[$row['packageVersion']])) {
$fromversions[$row['packageVersion']] = array();
}
$fromversions[$row['packageVersion']][$row['fromversion']] = $row['fromversion'];
}
// sort by version number
uksort($fromversions, array('Package', 'compareVersion'));
// find shortest update thread
$updateThread = self::findShortestUpdateThread($package->getPackage(), $fromversions, $packageVersion, $version);
// process update thread
foreach ($updateThread as $fromversion => $toVersion) {
$packageUpdateVersions = self::getPackageUpdateVersions($package->getPackage(), $toVersion);
// resolve requirements
$this->resolveRequirements($packageUpdateVersions[0]['packageUpdateVersionID']);
// download package
$download = '';
if ($this->download) {
$download = $this->downloadPackage($package->getPackage(), $packageUpdateVersions);
}
// add to stack
$this->packageInstallationStack[] = array('packageName' => $package->getName(), 'instanceNo' => $package->getInstanceNo(), 'fromversion' => $fromversion, 'toVersion' => $toVersion, 'package' => $package->getPackage(), 'packageID' => $packageID, 'archive' => $download, 'action' => 'update');
// update virtual versions
$this->virtualPackageVersions[$packageID] = $toVersion;
}
}
示例10: mapPackage
/**
* Map a remote package name to a local package
*
* @param string remote
* @param lang.reflect.Package mapped
*/
public function mapPackage($remote, Package $mapped)
{
$this->packages[0][$remote] = $mapped->getName();
$this->packages[1][$mapped->getName()] = $remote;
}
示例11: testGetAndSetName
public function testGetAndSetName()
{
$this->assertEquals(null, $this->sut->getName());
$this->sut->setName('bar');
$this->assertEquals('bar', $this->sut->getName());
}
示例12: addPackage
/**
* Add package
*
* @param Package $package
* @return void
*/
public function addPackage($package)
{
$channel = $this->chanName($package->getChannel());
$name = $package->getName();
$record = array(self::K_VER => $package->getVersion(), self::K_STATE => $package->getStability(), self::K_XML => $package->getPackageXml(), self::K_NAME => $name, self::K_DEPS => array(), self::K_PACK_DEPS => array());
$this->setPackageRecord($channel, $name, $record);
$this->setPackageDependencies($channel, $name, $package->getDependencyPackages());
$this->save();
}
示例13: offsetset
/**
* Appens only packages
*
* @param string $key
* @param Package $package
*
* @return void
*/
public function offsetset($key, $package)
{
$key = $package->getVendor() . '/' . $package->getName();
parent::offsetSet($key, $package);
}
示例14: removePackage
public function removePackage(Package $package)
{
//Si le paquet n'est pas dans la liste, on ne fait rien
if (!$this->isPackage($package->getName())) {
return;
}
$xml = new \DOMDocument();
if ($this->webos->managers()->get('File')->exists($this->source . '/packages.xml')) {
$xml->loadXML($this->webos->managers()->get('File')->get($this->source . '/packages.xml')->contents());
$root = $xml->getElementsByTagName('packages')->item(0);
} else {
return;
}
$packages = $root->getElementsByTagName('package');
foreach ($packages as $xml_package) {
if ($xml_package->getAttribute('name') == $package->getName()) {
$root->removeChild($xml_package);
}
}
$this->webos->managers()->get('File')->get($this->source . '/packages.xml')->setContents($xml->saveXML());
$this->webos->managers()->get('File')->get($this->source . '/packages/' . $package->getName() . '.xml')->delete();
unset($this->packages[$package->getName()]);
}
示例15: writeConfigFile
/**
* Writes the config.inc.php for a standalone application.
*
* @param integer $packageID
*/
public static function writeConfigFile($packageID)
{
$package = new Package($packageID);
$packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $package->getDir()));
$file = new File($packageDir . PackageInstallation::CONFIG_FILE);
$file->write("<?php\n");
$currentPrefix = strtoupper($package->getAbbreviation());
// get dependencies (only standalones)
$sql = "SELECT\t\tpackage.*, IF(package.packageID = " . $packageID . ", 1, 0) AS sortOrder\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = package_dependency.dependency)\n\t\t\tWHERE\t\tpackage_dependency.packageID = " . $packageID . "\n\t\t\t\t\tAND package.standalone = 1\n\t\t\t\t\tAND package.packageDir <> ''\n\t\t\tORDER BY\tsortOrder DESC,\n\t\t\t\t\tpackage_dependency.priority DESC";
$result = WCF::getDB()->sendQuery($sql);
while ($row = WCF::getDB()->fetchArray($result)) {
$dependency = new Package(null, $row);
$dependencyDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $dependency->getDir()));
$prefix = strtoupper($dependency->getAbbreviation());
$file->write("// " . $dependency->getPackage() . " vars\n");
$file->write("// " . strtolower($prefix) . "\n");
$file->write("if (!defined('" . $prefix . "_DIR')) define('" . $prefix . "_DIR', " . ($dependency->getPackageID() == $package->getPackageID() ? "dirname(__FILE__).'/'" : "'" . $dependencyDir . "'") . ");\n");
$file->write("if (!defined('RELATIVE_" . $prefix . "_DIR')) define('RELATIVE_" . $prefix . "_DIR', " . ($dependency->getPackageID() == $package->getPackageID() ? "''" : "RELATIVE_" . $currentPrefix . "_DIR.'" . FileUtil::getRelativePath($packageDir, $dependencyDir) . "'") . ");\n");
$file->write("if (!defined('" . $prefix . "_N')) define('" . $prefix . "_N', '" . WCF_N . "_" . $dependency->getInstanceNo() . "');\n");
$file->write("\$packageDirs[] = " . $prefix . "_DIR;\n");
$file->write("\n");
}
// write general information
$file->write("// general info\n");
$file->write("if (!defined('RELATIVE_WCF_DIR'))\tdefine('RELATIVE_WCF_DIR', RELATIVE_" . $currentPrefix . "_DIR.'" . FileUtil::getRelativePath($packageDir, WCF_DIR) . "');\n");
$file->write("if (!defined('PACKAGE_ID')) define('PACKAGE_ID', " . $package->getPackageID() . ");\n");
$file->write("if (!defined('PACKAGE_NAME')) define('PACKAGE_NAME', '" . str_replace("'", "\\'", $package->getName()) . "');\n");
$file->write("if (!defined('PACKAGE_VERSION')) define('PACKAGE_VERSION', '" . $package->getVersion() . "');\n");
// write end
$file->write("?>");
$file->close();
}