LinkORB\Component\Etcd\Client::rmdir PHP 메소드

rmdir() 공개 메소드

Removes the key if it is directory
public rmdir ( string $key, boolean $recursive = false ) : mixed
$key string
$recursive boolean
리턴 mixed
    public function rmdir($key, $recursive = false)
    {
        $query = array('dir' => 'true');
        if ($recursive === true) {
            $query['recursive'] = 'true';
        }
        $request = $this->guzzleclient->delete($this->buildKeyUri($key), null, null, array('query' => $query));
        $response = $request->send();
        $body = $response->json();
        if (isset($body['errorCode'])) {
            throw new EtcdException($body['message'], $body['errorCode']);
        }
        return $body;
    }

Usage Example

예제 #1
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $server = $input->getArgument('server');
     $key = $input->getArgument('key');
     $recursive = $input->getOption('recursive');
     $output->writeln("<info>Removing key `{$key}`</info>");
     $client = new EtcdClient($server);
     $data = $client->rmdir($key, $recursive);
     $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     echo $json;
 }
All Usage Examples Of LinkORB\Component\Etcd\Client::rmdir