Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Openl10n/Cli/ApplicationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ protected function getDefaultCommands()
new Command\InitCommand(),
new Command\PullCommand(),
new Command\PushCommand(),
new Command\RemoveTranslationCommand()
];
}

Expand Down
53 changes: 53 additions & 0 deletions src/Openl10n/Cli/Command/RemoveTranslationCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Openl10n\Cli\Command;

use Openl10n\Sdk\EntryPoint\ProjectEntryPoint;
use Openl10n\Sdk\EntryPoint\TranslationEntryPoint;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class RemoveTranslationCommand extends AbstractCommand
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('remove-translation')
->setDescription('Removes a translation given its identifier')
->addArgument(
'identifier',
InputArgument::REQUIRED,
'Translation\'s identifier you want to remove'
)
;
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$api = $this->get('api');
/* @var ProjectEntryPoint $projectApi */
$projectApi = $api->getEntryPoint('project');
/* @var TranslationEntryPoint $translationApi */
$translationApi = $api->getEntryPoint('translation');

$projectSlug = $this->get('project_handler')->getProjectSlug();
$project = $projectApi->get($projectSlug);

$identifier = $input->getArgument('identifier');

$translation = $translationApi->findOneByIdentifier($project, $identifier);
if (!$translation) {
$output->writeln(sprintf('<error>Translation "%s" does not exist</error>', $identifier));
} else {
$output->writeln(sprintf('<info>Removing</info> translation <comment>"%s"</comment>', $identifier));
$translationApi->delete($translation);
}
}
}