/
githubmirror
/
ydb-php-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/app/Commands/RemoveDirectoryCommand.php
61 строка
1 KB
Ilya Kharev
Update RemoveDirectoryCommand.php
23 июн 2023, 14:41
23 июн 2023, 14:41
7c71a46
Код
Авторство
О чём код?
<?php namespace App\Commands; use App\AppService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use YdbPlatform\Ydb\Ydb; class RemoveDirectoryCommand extends Command { /** * @var string */ protected static $defaultName = 'rmdir'; /** * @var AppService */ protected $appService; public function __construct() { $this->appService = new AppService; parent::__construct(); } protected function configure() { $this->setDescription('Delete a directory.'); $this->addArgument('dirname', InputArgument::REQUIRED, 'The directory name.'); } /** * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $dirname = $input->getArgument('dirname') ?: ''; $ydb = $this->appService->initYdb(); $result = $ydb->retry(function (Ydb $ydb) use ($output, $dirname) { $scheme = $ydb->scheme(); return $scheme->removeDirectory($dirname); }, true); $output->writeln(json_encode($result, 480)); return Command::SUCCESS; } }