Skip to content

Commit

Permalink
fix: Fixed Attributes import
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed May 7, 2024
1 parent ed4df8a commit 5773880
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
5 changes: 0 additions & 5 deletions .travis/backoffice_assets.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .travis/composer_install.sh

This file was deleted.

5 changes: 0 additions & 5 deletions .travis/php_lint.sh

This file was deleted.

10 changes: 9 additions & 1 deletion src/Controllers/Attributes/AttributeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,21 @@ public function importAction(Request $request): Response
$file = $form->get('file')->getData();

if ($file->isValid()) {
$serializedData = file_get_contents($file->getPathname());
$serializedData = \file_get_contents($file->getPathname());
if (false === $serializedData) {
throw new \RuntimeException('Cannot read uploaded file.');
}

$this->attributeImporter->import($serializedData);
$this->em()->flush();

$msg = $this->getTranslator()->trans(
'%namespace%.imported',
[
'%namespace%' => $this->getTranslator()->trans($this->getNamespace())
]
);
$this->publishConfirmMessage($request, $msg);
return $this->redirectToRoute('attributesHomePage');
}
$form->addError(new FormError($this->getTranslator()->trans('file.not_uploaded')));
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="./themes/Rozier/Resources/translations/messages.po" source-language="en-US" datatype="plaintext">
<body>
<trans-unit xml:space="preserve" id="%namespace%.imported"><source>%namespace%.imported</source></trans-unit>
<trans-unit xml:space="preserve" id="2"><source>node.%name%.updated</source></trans-unit>
<trans-unit xml:space="preserve" id="node.%name%.was_moved"><source>node.%name%.was_moved</source></trans-unit>
<trans-unit xml:space="preserve" id="3"><source>node.%nodeId%.not_exists</source></trans-unit>
Expand Down

0 comments on commit 5773880

Please sign in to comment.