Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added check for already merged file from reverting back via callback #487

Merged
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
23 changes: 15 additions & 8 deletions src/controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ public function actionOrderCallback()
echo 'Starting file sync' . PHP_EOL;

foreach($order->getFiles() as $file) {
$translationService->updateFile($order, $file);
Translations::$plugin->fileRepository->saveFile($file);
// Only process the file is not already done
if ($file->isNew() || $file->isInProgress()) {
$translationService->updateFile($order, $file);
Translations::$plugin->fileRepository->saveFile($file);
}
}

echo 'File sync successful' . PHP_EOL;
Expand Down Expand Up @@ -178,16 +181,20 @@ public function actionFileCallback()
echo 'Translation service found'.PHP_EOL;
}

$translationService->updateFile($order, $file);

echo 'Updating file'.PHP_EOL;
// Skip if file already has target content
if ($file->isNew() || $file->isInProgress()) {
$translationService->updateFile($order, $file);

$success = Translations::$plugin->fileRepository->saveFile($file);
$success = Translations::$plugin->fileRepository->saveFile($file);

if (!$success) {
Craft::$app->end('Couldn’t save the file');
if (!$success) {
Craft::$app->end('Couldn’t save the file');
} else {
echo 'File saved'.PHP_EOL;
}
} else {
echo 'Saving file'.PHP_EOL;
echo 'File skipped'.PHP_EOL;
}

Craft::$app->end('OK');
Expand Down
2 changes: 1 addition & 1 deletion src/models/GlobalSetDraftModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function rules(): array
return $rules;
}

public function getFieldLayout(): ?\craft\models\FieldLayout
public function getFieldLayout(): \craft\models\FieldLayout
{
$globalSet = $this->getGlobalSet();

Expand Down