forked from wallabag/wallabag
Add flashes messages
This commit is contained in:
@ -52,8 +52,9 @@ class PocketController extends Controller
|
||||
*/
|
||||
public function callbackAction()
|
||||
{
|
||||
$message = 'Import failed, please try again.';
|
||||
$message = 'flashes.import.notice.failed';
|
||||
$pocket = $this->get('wallabag_import.pocket.import');
|
||||
|
||||
$markAsRead = $this->get('session')->get('mark_as_read');
|
||||
$this->get('session')->remove('mark_as_read');
|
||||
|
||||
@ -69,7 +70,10 @@ class PocketController extends Controller
|
||||
|
||||
if (true === $pocket->setMarkAsRead($markAsRead)->import()) {
|
||||
$summary = $pocket->getSummary();
|
||||
$message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.';
|
||||
$message = $this->get('translator')->trans('flashes.import.notice.summary', array(
|
||||
'%imported%' => $summary['imported'],
|
||||
'%skipped%' => $summary['skipped'],
|
||||
));
|
||||
}
|
||||
|
||||
$this->get('session')->getFlashBag()->add(
|
||||
|
||||
@ -31,11 +31,14 @@ class WallabagV1Controller extends Controller
|
||||
->setMarkAsRead($markAsRead)
|
||||
->import();
|
||||
|
||||
$message = 'Import failed, please try again.';
|
||||
$message = 'flashes.import.notice.failed';
|
||||
|
||||
if (true === $res) {
|
||||
$summary = $wallabag->getSummary();
|
||||
$message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.';
|
||||
$message = $this->get('translator')->trans('flashes.import.notice.summary', array(
|
||||
'%imported%' => $summary['imported'],
|
||||
'%skipped%' => $summary['skipped'],
|
||||
));
|
||||
|
||||
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
|
||||
}
|
||||
@ -49,7 +52,7 @@ class WallabagV1Controller extends Controller
|
||||
} else {
|
||||
$this->get('session')->getFlashBag()->add(
|
||||
'notice',
|
||||
'Error while processing import. Please verify your import file.'
|
||||
'flashes.import.notice.failed_on_file'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,11 +31,14 @@ class WallabagV2Controller extends Controller
|
||||
->setMarkAsRead($markAsRead)
|
||||
->import();
|
||||
|
||||
$message = 'Import failed, please try again.';
|
||||
$message = 'flashes.import.notice.failed';
|
||||
|
||||
if (true === $res) {
|
||||
$summary = $wallabag->getSummary();
|
||||
$message = 'Import summary: '.$summary['imported'].' imported, '.$summary['skipped'].' already saved.';
|
||||
$message = $this->get('translator')->trans('flashes.import.notice.summary', array(
|
||||
'%imported%' => $summary['imported'],
|
||||
'%skipped%' => $summary['skipped'],
|
||||
));
|
||||
|
||||
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
|
||||
}
|
||||
@ -49,7 +52,7 @@ class WallabagV2Controller extends Controller
|
||||
} else {
|
||||
$this->get('session')->getFlashBag()->add(
|
||||
'notice',
|
||||
'Error while processing import. Please verify your import file.'
|
||||
'flashes.import.notice.failed_on_file'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +37,6 @@ class PocketControllerTest extends WallabagCoreTestCase
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
$this->assertContains('import/pocket', $client->getResponse()->headers->get('location'));
|
||||
$this->assertEquals('Import failed, please try again.', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
|
||||
$this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
|
||||
$this->assertTrue($content->getTags()->contains($tag));
|
||||
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||
$this->assertContains('Import summary', $body[0]);
|
||||
$this->assertContains('flashes.import.notice.summary', $body[0]);
|
||||
}
|
||||
|
||||
public function testImportWallabagWithFileAndMarkAllAsRead()
|
||||
@ -100,7 +100,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
|
||||
$this->assertTrue($content2->isArchived());
|
||||
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||
$this->assertContains('Import summary', $body[0]);
|
||||
$this->assertContains('flashes.import.notice.summary', $body[0]);
|
||||
}
|
||||
|
||||
public function testImportWallabagWithEmptyFile()
|
||||
@ -124,6 +124,6 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||
$this->assertContains('Import failed, please try again', $body[0]);
|
||||
$this->assertContains('flashes.import.notice.failed', $body[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||
$this->assertContains('Import summary', $body[0]);
|
||||
$this->assertContains('flashes.import.notice.summary', $body[0]);
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
@ -88,6 +88,6 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
|
||||
$crawler = $client->followRedirect();
|
||||
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||
$this->assertContains('Import failed, please try again', $body[0]);
|
||||
$this->assertContains('flashes.import.notice.failed', $body[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user