本文整理匯總了PHP中Puli\Manager\Assert\Assert::oneOf方法的典型用法代碼示例。如果您正苦於以下問題:PHP Assert::oneOf方法的具體用法?PHP Assert::oneOf怎麽用?PHP Assert::oneOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Puli\Manager\Assert\Assert
的用法示例。
在下文中一共展示了Assert::oneOf方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Creates the context.
*
* @param string|null $homeDir The path to the
* home directory or
* `null` if none
* exists.
* @param string $rootDir The path to the
* project's root
* directory.
* @param Config $config The configuration.
* @param RootModuleFile $rootModuleFile The root module
* file.
* @param ConfigFile|null $configFile The configuration
* file or `null` if
* none exists.
* @param EventDispatcherInterface|null $dispatcher The event
* dispatcher.
* @param string $env The environment
* that Puli is
* running in.
*/
public function __construct($homeDir, $rootDir, Config $config, RootModuleFile $rootModuleFile, ConfigFile $configFile = null, EventDispatcherInterface $dispatcher = null, $env = Environment::DEV)
{
Assert::directory($rootDir, 'The root directory %s is not a directory.');
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
parent::__construct($homeDir, $config, $configFile, $dispatcher);
$this->rootDir = Path::canonicalize($rootDir);
$this->rootModuleFile = $rootModuleFile;
$this->env = $env;
}
示例2: 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);
}
示例3: setEnvironment
/**
* Sets the environment that the package is installed in.
*
* @param string $env One of the {@link Environment} constants.
*/
public function setEnvironment($env)
{
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
$this->env = $env;
}
示例4: setEnvironment
/**
* Sets the environment of the managed Puli project.
*
* @param string $env One of the {@link Environment} constants.
*/
public function setEnvironment($env)
{
if ($this->started) {
throw new LogicException('Puli is already started');
}
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
$this->env = $env;
}