当前位置: 首页>>代码示例>>PHP>>正文


PHP Assert::nullOrPackageName方法代码示例

本文整理汇总了PHP中Puli\Manager\Assert\Assert::nullOrPackageName方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::nullOrPackageName方法的具体用法?PHP Assert::nullOrPackageName怎么用?PHP Assert::nullOrPackageName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Puli\Manager\Assert\Assert的用法示例。


在下文中一共展示了Assert::nullOrPackageName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: installPackage

 /**
  * {@inheritdoc}
  */
 public function installPackage($installPath, $name = null, $installerName = InstallInfo::DEFAULT_INSTALLER_NAME)
 {
     Assert::string($installPath, 'The install path must be a string. Got: %s');
     Assert::string($installerName, 'The installer name must be a string. Got: %s');
     Assert::nullOrPackageName($name);
     $this->assertPackagesLoaded();
     $installPath = Path::makeAbsolute($installPath, $this->rootDir);
     foreach ($this->packages as $package) {
         if ($installPath === $package->getInstallPath()) {
             return;
         }
     }
     if (null === $name) {
         // Read the name from the package file
         $name = $this->loadPackageFile($installPath)->getPackageName();
     }
     if (null === $name) {
         throw new InvalidConfigException(sprintf('Could not find a name for the package at %s. The name should ' . 'either be passed to the installer or be set in the "name" ' . 'property of %s.', $installPath, $installPath . '/puli.json'));
     }
     if ($this->packages->contains($name)) {
         throw NameConflictException::forName($name);
     }
     $relInstallPath = Path::makeRelative($installPath, $this->rootDir);
     $installInfo = new InstallInfo($name, $relInstallPath);
     $installInfo->setInstallerName($installerName);
     $package = $this->loadPackage($installInfo);
     $this->assertNoLoadErrors($package);
     $this->rootPackageFile->addInstallInfo($installInfo);
     try {
         $this->packageFileStorage->saveRootPackageFile($this->rootPackageFile);
     } catch (Exception $e) {
         $this->rootPackageFile->removeInstallInfo($name);
         throw $e;
     }
     $this->packages->add($package);
 }
开发者ID:niklongstone,项目名称:manager,代码行数:39,代码来源:PackageManagerImpl.php

示例2: setPackageName

 /**
  * Sets the package name.
  *
  * @param string|null $packageName The package name or `null` to unset.
  *
  * @throws InvalidArgumentException If the name is not a string or empty.
  */
 public function setPackageName($packageName)
 {
     Assert::nullOrPackageName($packageName);
     $this->packageName = $packageName;
 }
开发者ID:kormik,项目名称:manager,代码行数:12,代码来源:PackageFile.php


注:本文中的Puli\Manager\Assert\Assert::nullOrPackageName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。