Skip to content

Commit 24283d0

Browse files
Add a method to remove the cache for translation
1 parent b4c0e63 commit 24283d0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Controller/EditInPlaceController.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,31 @@ public function editAction(Request $request, $configName, $locale)
4444
$storage->update($message->convertToMessage($locale));
4545
}
4646

47+
$this->rebuildTranslations();
48+
4749
return new Response();
4850
}
4951

52+
/**
53+
* Remove the Symfony translation cache and warm it up again.
54+
*/
55+
private function rebuildTranslations()
56+
{
57+
$cacheDir = $this->getParameter('kernel.cache_dir');
58+
$translationDir = sprintf("%s/translations", $cacheDir);
59+
60+
$filesystem = $this->get('filesystem');
61+
if (!is_writable($translationDir)) {
62+
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $translationDir));
63+
}
64+
65+
if ($filesystem->exists($translationDir)) {
66+
$filesystem->remove($translationDir);
67+
}
68+
69+
$this->get('translator')->warmUp();
70+
}
71+
5072
/**
5173
* Get and validate messages from the request.
5274
*

0 commit comments

Comments
 (0)