Skip to content

Commit a4c30e5

Browse files
welcoMatticNyholm
authored andcommitted
Fix type of data returned by translation data collector since sf 3.3 (#96)
* Fix type of data returned by translation data collector since sf 3.3 * Fix wrong path for createAssets route
1 parent 16dae76 commit a4c30e5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Controller/SymfonyProfilerController.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\Translation\DataCollectorTranslator;
18+
use Symfony\Component\VarDumper\Cloner\Data;
1819
use Translation\Bundle\Model\SfProfilerMessage;
1920
use Translation\Bundle\Service\StorageService;
2021
use Translation\Common\Model\Message;
@@ -154,6 +155,11 @@ private function getMessage(Request $request, $token)
154155
}
155156

156157
$messages = $dataCollector->getMessages();
158+
159+
if ($messages instanceof Data) {
160+
$messages = $messages->getValue(true);
161+
}
162+
157163
if (!isset($messages[$messageId])) {
158164
throw $this->createNotFoundException(sprintf('No message with key "%s" was found.', $messageId));
159165
}
@@ -185,7 +191,13 @@ protected function getSelectedMessages(Request $request, $token)
185191

186192
$profile = $profiler->loadProfile($token);
187193
$dataCollector = $profile->getCollector('translation');
188-
$toSave = array_intersect_key($dataCollector->getMessages(), array_flip($selected));
194+
$messages = $dataCollector->getMessages();
195+
196+
if ($messages instanceof Data) {
197+
$messages = $messages->getValue(true);
198+
}
199+
200+
$toSave = array_intersect_key($messages, array_flip($selected));
189201

190202
$messages = [];
191203
foreach ($toSave as $data) {

Resources/config/routing_symfony_profiler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ php_translation_profiler_translation_sync_all:
1515
defaults: { _controller: TranslationBundle:SymfonyProfiler:syncAll }
1616

1717
php_translation_profiler_translation_create_assets:
18-
path: /{token}/translation/sync_all
18+
path: /{token}/translation/create_assets
1919
methods: ["POST"]
2020
defaults: { _controller: TranslationBundle:SymfonyProfiler:createAssets }

0 commit comments

Comments
 (0)