Skip to content

Commit

Permalink
Merge pull request #21 from maximehuran/feature/add-export-locale
Browse files Browse the repository at this point in the history
Add locale in export file
  • Loading branch information
maximehuran authored Apr 6, 2022
2 parents 52088b2 + cd3bb54 commit 497d058
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}

- name: Composer allow plugins
run: composer config -g allow-plugins true

- run: make install

- run: make test.composer
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ${APP_DIR}/node_modules: yarn.install
application: .php-version php.ini ${APP_DIR} setup_application ${APP_DIR}/docker-compose.yaml

${APP_DIR}:
(${COMPOSER} create-project --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard="${SYLIUS_VERSION}" ${APP_DIR})
(${COMPOSER} create-project --no-interaction --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard="${SYLIUS_VERSION}" ${APP_DIR})

setup_application:
rm -f ${APP_DIR}/yarn.lock
Expand All @@ -73,7 +73,8 @@ setup_application:
$(MAKE) apply_dist
$(MAKE) ${APP_DIR}/.php-version
$(MAKE) ${APP_DIR}/php.ini
(cd ${APP_DIR} && ${COMPOSER} install)
cd ${APP_DIR} && ${COMPOSER} install --no-interaction
cd ${APP_DIR} && ${COMPOSER} symfony:recipes:install --no-interaction

${APP_DIR}/docker-compose.yaml:
rm -f ${APP_DIR}/docker-compose.yml
Expand Down
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,13 @@
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"symfony/thanks": true,
"ergebnis/composer-normalize": true,
"symfony/flex": true
}
}
}
6 changes: 6 additions & 0 deletions src/Controller/Admin/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
namespace MonsieurBiz\SyliusColishipPlugin\Controller\Admin;

use MonsieurBiz\SyliusColishipPlugin\Exporter\ExporterInterface;
use MonsieurBiz\SyliusSettingsPlugin\Settings\SettingsInterface;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\StreamedResponse;

final class ExportController extends AbstractController
{
public function exportAction(
SettingsInterface $colishipSettings,
ChannelRepositoryInterface $channelRepository,
ExporterInterface $colishipExporter,
string $channelCode
Expand All @@ -29,6 +31,10 @@ public function exportAction(
throw $this->createNotFoundException('Channel not found');
}

$locale = $colishipSettings->getCurrentValue($channel, null, 'exportLocale');
if (!empty($locale)) {
setlocale(\LC_CTYPE, $locale);
}
$file = $colishipExporter->exportToFile($channel);

return new StreamedResponse(
Expand Down
5 changes: 5 additions & 0 deletions src/Form/SettingsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -95,6 +96,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'multiple' => true,
'choices' => $this->fmtDirectory->getValues(),
])
->addWithDefaultCheckbox($builder, 'exportLocale', TextType::class, [
'required' => false,
'label' => 'monsieurbiz_coliship.admin.settings.export_locale',
])
;
}
}
5 changes: 3 additions & 2 deletions src/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ monsieurbiz_coliship:
actions:
export: Coliship Export
download_fmt: Download the FMT file
settings:
method_code_deprecated: 'Method code (Deprecated, use Method Codes instead)'
shipping_method:
header: 'Coliship configuration for Shipping Method'
settings:
export_locale: 'Locale used to convert the export file'
method_code_deprecated: 'Method code (Deprecated, use Method Codes instead)'
form:
address:
service: Service
Expand Down
5 changes: 3 additions & 2 deletions src/Resources/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ monsieurbiz_coliship:
actions:
export: Export Coliship
download_fmt: Télécharger le fichier FMT
settings:
method_code_deprecated: 'Method code (Déprécié, utiliser Method Codes)'
shipping_method:
header: 'Paramètres Coliship du mode de livraison'
settings:
export_locale: 'Locale à utiliser dans le fichier d''export'
method_code_deprecated: 'Method code (Déprécié, utiliser Method Codes)'
form:
address:
service: Service
Expand Down

0 comments on commit 497d058

Please sign in to comment.