本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::error方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::error方法的具體用法?PHP OutputInterface::error怎麽用?PHP OutputInterface::error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::error方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: lock
/**
* Attempt to lock this command.
*
* @param OutputInterface $output The output object to use for any error messages
*
* @return void
*/
public function lock(OutputInterface $output)
{
# If this command doesn't require locking then don't do anything
if (!$this->lock) {
return;
}
$path = $this->getLockPath();
# If the lock file doesn't already exist then we are creating it, so we need to open the permissions on it
$newFile = !file_exists($path);
# Attempt to create/open a lock file for this command
if (!($this->lock = fopen($path, "w"))) {
$output->error("Unable to create a lock file (" . $path . ")");
exit(Application::STATUS_PERMISSIONS);
}
# Attempt to lock the file we've just opened
if (!flock($this->lock, LOCK_EX | LOCK_NB)) {
fclose($this->lock);
$output->error("Another instance of this command (" . $this->getName() . ") is currently running");
exit(Application::STATUS_LOCKED);
}
# Ensure the permissions are as open as possible to allow multiple users to run the same command
if ($newFile) {
chmod($path, 0777);
}
}
示例2: writeError
/**
* {@inheritdoc}
*/
protected function writeError(OutputInterface $output, \Exception $error)
{
if ($output instanceof SymfonyStyle) {
$output->newLine();
$output->error($error->getMessage());
return;
}
parent::writeError($output, $error);
}
示例3: loadConfig
protected function loadConfig(OutputInterface $output)
{
try {
$this->config = new Config(getcwd() . '/spacewave.yml');
} catch (FileNotFoundException $e) {
$output->error('Could not find spacewave.yml in directory');
exit;
}
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
// Database options
$dbType = $input->getOption('db-type');
$dbFile = $input->getOption('db-file');
$dbHost = $input->getOption('db-host');
$dbName = $input->getOption('db-name');
$dbUser = $input->getOption('db-user');
$dbPass = $input->getOption('db-pass');
$dbPrefix = $input->getOption('db-prefix');
$dbPort = $input->getOption('db-port');
$databases = $this->site->getDatabaseTypes();
if ($dbType === 'sqlite') {
$database = array('database' => $dbFile, 'prefix' => $dbPrefix, 'namespace' => $databases[$dbType]['namespace'], 'driver' => $dbType);
} else {
$database = array('database' => $dbName, 'username' => $dbUser, 'password' => $dbPass, 'prefix' => $dbPrefix, 'port' => $dbPort, 'host' => $dbHost, 'namespace' => $databases[$dbType]['namespace'], 'driver' => $dbType);
}
$this->backupSitesFile($io);
try {
$this->runInstaller($io, $input, $database);
} catch (Exception $e) {
$output->error($e->getMessage());
return;
}
$this->restoreSitesFile($io);
}