本文整理汇总了PHP中Puli\Manager\Assert\Assert::nullOrModuleName方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::nullOrModuleName方法的具体用法?PHP Assert::nullOrModuleName怎么用?PHP Assert::nullOrModuleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Puli\Manager\Assert\Assert
的用法示例。
在下文中一共展示了Assert::nullOrModuleName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installModule
/**
* {@inheritdoc}
*/
public function installModule($installPath, $name = null, $installerName = InstallInfo::DEFAULT_INSTALLER_NAME, $env = Environment::PROD)
{
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::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
Assert::nullOrModuleName($name);
$this->assertModulesLoaded();
$installPath = Path::makeAbsolute($installPath, $this->rootDir);
foreach ($this->modules as $module) {
if ($installPath === $module->getInstallPath()) {
return;
}
}
if (null === $name && ($moduleFile = $this->loadModuleFile($installPath))) {
// Read the name from the module file
$name = $moduleFile->getModuleName();
}
if (null === $name) {
throw new InvalidConfigException(sprintf('Could not find a name for the module 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->modules->contains($name)) {
throw NameConflictException::forName($name);
}
$relInstallPath = Path::makeRelative($installPath, $this->rootDir);
$installInfo = new InstallInfo($name, $relInstallPath);
$installInfo->setInstallerName($installerName);
$installInfo->setEnvironment($env);
$module = $this->loadModule($installInfo);
$this->assertNoLoadErrors($module);
$this->rootModuleFile->addInstallInfo($installInfo);
try {
$this->moduleFileStorage->saveRootModuleFile($this->rootModuleFile);
} catch (Exception $e) {
$this->rootModuleFile->removeInstallInfo($name);
throw $e;
}
$this->modules->add($module);
}
示例2: setModuleName
/**
* Sets the module name.
*
* @param string|null $moduleName The module name or `null` to unset.
*
* @throws InvalidArgumentException If the name is not a string or empty.
*/
public function setModuleName($moduleName)
{
Assert::nullOrModuleName($moduleName);
$this->moduleName = $moduleName;
}