1
0
mirror of https://gitnet.fr/deblan/gist.git synced 2021-08-14 08:30:49 +02:00

Implementation of Api action "delete"

This commit is contained in:
Simon Vieille 2017-08-23 19:54:58 +02:00
parent 87348c8335
commit ab58bdb82d
4 changed files with 52 additions and 2 deletions

View File

@ -5,6 +5,7 @@ use Gist\Command\CreateCommand;
use Gist\Command\ListCommand;
use Gist\Command\UpdateCommand;
use Gist\Command\StatsCommand;
use Gist\Command\DeleteCommand;
use Gist\Command\UserCreateCommand;
use Gist\Command\Migration\UpgradeTo1p4p1Command;
@ -13,6 +14,7 @@ $app = require __DIR__.'/bootstrap.php';
$app['console']->add(new CreateCommand());
$app['console']->add(new ListCommand());
$app['console']->add(new UpdateCommand());
$app['console']->add(new DeleteCommand());
$app['console']->add(new StatsCommand());
$app['console']->add(new UserCreateCommand());
$app['console']->add(new UpgradeTo1p4p1Command());

View File

@ -0,0 +1,48 @@
<?php
namespace Gist\Command;
use Knp\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
/**
* class DeleteCommand.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class DeleteCommand extends Command
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('delete')
->setDescription('Delete a gist using the API')
->addOption('gist', null, InputOption::VALUE_REQUIRED, 'Id or File of the gist')
->setHelp(<<<'EOF'
Provides a client to delete a gist using the API.
Arguments:
none.
Options:
<info>--gist</info>
Defines the Gist to delete by using its Id or its File
EOF
);
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$result = $this->getSilexApplication()['api_client']->delete($input->getOption('gist'));
$output->writeln(empty($result['error']) ? 'OK' : '<error>An error occured.</error>');
}
}

View File

@ -26,7 +26,7 @@ class ListCommand extends Command
{
$this
->setName('list')
->setDescription('Listing gists using the API');
->setDescription('List gists using the API');
}
/**

View File

@ -216,7 +216,7 @@ class ApiController extends Controller
}
if (false === $request->isMethod('post')) {
// return $this->invalidMethodResponse('POST method is required.');
return $this->invalidMethodResponse('POST method is required.');
}
$user = $app['user.provider']->loadUserByApiKey($apiKey);