Skip to content

Commit

Permalink
add new command
Browse files Browse the repository at this point in the history
php bin/console fop:translations:import ISO_CODE
  • Loading branch information
PrestaSafe committed Apr 8, 2024
1 parent 5da0635 commit 4dbbed3
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 33 deletions.
69 changes: 36 additions & 33 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,136 +11,139 @@ services:

fop.console.cache.clear.command:
class: FOP\Console\Commands\Cache\CacheClear
tags: [ console.command ]
tags: [console.command]

fop.console.category.clean.command:
class: FOP\Console\Commands\Category\CategoryClean
tags: [ console.command ]
tags: [console.command]

fop.console.category.products_count.command:
class: FOP\Console\Commands\Category\CategoryProductsCount
tags: [ console.command ]
tags: [console.command]

fop.console.configuration.export.command:
class: FOP\Console\Commands\Configuration\ConfigurationExport
tags: [ console.command ]
tags: [console.command]

fop.console.configuration.import.command:
class: FOP\Console\Commands\Configuration\ConfigurationImport
tags: [ console.command ]
tags: [console.command]

fop.console.container.check.command:
class: FOP\Console\Commands\Container\ContainerCheck
tags: [ console.command ]
tags: [console.command]

fop.console.employee.list.command:
class: FOP\Console\Commands\Employee\EmployeeList
tags: [ console.command ]
tags: [console.command]

fop.console.employee.change_password.command:
class: FOP\Console\Commands\Employee\EmployeeChangePassword
tags: [ console.command ]
tags: [console.command]

fop.console.environment.debug.command:
class: FOP\Console\Commands\Environment\EnvironmentDebug
tags: [ console.command ]
tags: [console.command]

fop.console.environment.get_parameters.command:
class: FOP\Console\Commands\Environment\EnvironmentGetParameters
tags: [ console.command ]
tags: [console.command]

fop.console.environment.setup_dev.command:
class: FOP\Console\Commands\Environment\EnvironmentSetupDev
tags: [ console.command ]
tags: [console.command]

fop.console.export.data.command:
class: FOP\Console\Commands\Export\ExportData
tags: [ console.command ]
tags: [console.command]

fop.console.generate.htaccess.command:
class: FOP\Console\Commands\Generate\GenerateHtaccess
tags: [ console.command ]
tags: [console.command]

fop.console.generate.robots.command:
class: FOP\Console\Commands\Generate\GenerateRobots
tags: [ console.command ]
tags: [console.command]

fop.console.group.transfer_customers.command:
class: FOP\Console\Commands\Group\GroupTransferCustomers
tags: [ console.command ]
tags: [console.command]

fop.console.hook.add.command:
class: FOP\Console\Commands\Hook\HookAdd
tags: [ console.command ]
tags: [console.command]

fop.console.image.generate_products.command:
class: FOP\Console\Commands\Image\ImageGenerateProducts
tags: [ console.command ]
tags: [console.command]

fop.console.image.generate_categories.command:
class: FOP\Console\Commands\Image\ImageGenerateCategories
tags: [ console.command ]
tags: [console.command]

fop.console.image.generate_manufacturers.command:
class: FOP\Console\Commands\Image\ImageGenerateManufacturers
tags: [ console.command ]
tags: [console.command]

fop.console.image.generate_suppliers.command:
class: FOP\Console\Commands\Image\ImageGenerateSuppliers
tags: [ console.command ]
tags: [console.command]

fop.console.image.generate_stores.command:
class: FOP\Console\Commands\Image\ImageGenerateStores
tags: [ console.command ]
tags: [console.command]

fop.console.module.unhook.command:
class: FOP\Console\Commands\Module\ModuleUnhook
tags: [ console.command ]
tags: [console.command]

fop.console.module.hook.command:
class: FOP\Console\Commands\Module\ModuleHook
tags: [ console.command ]
tags: [console.command]

fop.console.module.hooks.command:
class: FOP\Console\Commands\Module\ModuleHooks
tags: [ console.command ]
tags: [console.command]

fop.console.module.rename.command:
class: FOP\Console\Commands\Module\ModuleRename
tags: [ console.command ]
tags: [console.command]

fop.console.module.non_essential.command:
class: FOP\Console\Commands\Module\ModuleNonEssential
tags: [ console.command ]
tags: [console.command]

fop.console.module.generate.command:
class: FOP\Console\Commands\Module\ModuleGenerate
tags: [ console.command ]
tags: [console.command]

fop.console.override.make.command:
class: FOP\Console\Commands\Override\OverrideMake
tags: [ console.command ]
tags: [console.command]

fop.console.product.latest.command:
class: FOP\Console\Commands\Product\ProductLatest
tags: [ console.command ]
tags: [console.command]

fop.console.shop.status.command:
class: FOP\Console\Commands\Shop\ShopStatus
tags: [ console.command ]
tags: [console.command]

fop.console.shop.maintenance.command:
class: FOP\Console\Commands\Shop\ShopMaintenance
tags: [ console.command ]
tags: [console.command]

fop.console.theme.reset_layout.command:
class: FOP\Console\Commands\Theme\ThemeResetLayout
tags: [ console.command ]
tags: [console.command]

fop.console.about.version.command:
class: FOP\Console\Commands\About\AboutVersion
tags: [ console.command ]
tags: [console.command]

fop.console.translations.command:
class: FOP\Console\Commands\Translations\ImportLanguage
tags: [console.command]

imports:
- { resource: overriders.yml }
44 changes: 44 additions & 0 deletions src/Commands/Translations/ImportLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.5.2)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.6.9)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.7.8)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

Check failure on line 1 in src/Commands/Translations/ImportLanguage.php

View workflow job for this annotation

GitHub Actions / PHPStan (1.7.8.5)

ParseError (syntax error, unexpected ')') thrown while looking for class FOP\Console\Commands\Translations\ImportLanguage.

namespace FOP\Console\Commands\Translations;

use FOP\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class ImportLanguage extends Command
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('fop:translations')
->setName('fop:translations:import')
->setDescription('Import a translation by iso code')
->setHelp('This command will import or update a translation package')
->addUsage('./bin/console op:translations:import fr ( import fr translation package )')
->addArgument(
'iso',
InputOption::VALUE_REQUIRED,
'iso of language to import ex: fr',
);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$iso = $input->getArgument('iso');
$languagePackImporter = $this->getContainer()->get('prestashop.adapter.language.pack.importer');
$errors = $languagePackImporter->import($iso);
if (empty($errors)) {
$this->io->text('lang '.$iso.' added !');
}

return 0; // return 0 on success or 1 on failure.
}
}

0 comments on commit 4dbbed3

Please sign in to comment.