Add a real configuration for CS-Fixer

This commit is contained in:
Jeremy Benoist
2017-07-01 09:52:38 +02:00
parent 822c877949
commit f808b01692
170 changed files with 3147 additions and 3120 deletions

View File

@ -2,28 +2,14 @@
namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
abstract class BrowserController extends Controller
{
/**
* Return the service to handle the import.
*
* @return \Wallabag\ImportBundle\Import\ImportInterface
*/
abstract protected function getImportService();
/**
* Return the template used for the form.
*
* @return string
*/
abstract protected function getImportTemplate();
/**
* @Route("/browser", name="import_browser")
*
@ -42,11 +28,11 @@ abstract class BrowserController extends Controller
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
$name = $this->getUser()->getId().'.json';
$name = $this->getUser()->getId() . '.json';
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $wallabag
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@ -65,7 +51,7 @@ abstract class BrowserController extends Controller
]);
}
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
@ -74,12 +60,11 @@ abstract class BrowserController extends Controller
);
return $this->redirect($this->generateUrl('homepage'));
} else {
$this->get('session')->getFlashBag()->add(
}
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
}
return $this->render($this->getImportTemplate(), [
@ -87,4 +72,18 @@ abstract class BrowserController extends Controller
'import' => $wallabag,
]);
}
/**
* Return the service to handle the import.
*
* @return \Wallabag\ImportBundle\Import\ImportInterface
*/
abstract protected function getImportService();
/**
* Return the template used for the form.
*
* @return string
*/
abstract protected function getImportTemplate();
}

View File

@ -7,6 +7,14 @@ use Symfony\Component\HttpFoundation\Request;
class ChromeController extends BrowserController
{
/**
* @Route("/chrome", name="import_chrome")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
/**
* {@inheritdoc}
*/
@ -30,12 +38,4 @@ class ChromeController extends BrowserController
{
return 'WallabagImportBundle:Chrome:index.html.twig';
}
/**
* @Route("/chrome", name="import_chrome")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
}

View File

@ -7,6 +7,14 @@ use Symfony\Component\HttpFoundation\Request;
class FirefoxController extends BrowserController
{
/**
* @Route("/firefox", name="import_firefox")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
/**
* {@inheritdoc}
*/
@ -30,12 +38,4 @@ class FirefoxController extends BrowserController
{
return 'WallabagImportBundle:Firefox:index.html.twig';
}
/**
* @Route("/firefox", name="import_firefox")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
}

View File

@ -2,8 +2,8 @@
namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ImportController extends Controller
{
@ -86,9 +86,9 @@ class ImportController extends Controller
private function getTotalMessageInRabbitQueue($importService)
{
$message = $this
->get('old_sound_rabbit_mq.import_'.$importService.'_consumer')
->get('old_sound_rabbit_mq.import_' . $importService . '_consumer')
->getChannel()
->basic_get('wallabag.import.'.$importService);
->basic_get('wallabag.import.' . $importService);
if (null === $message) {
return 0;

View File

@ -2,8 +2,8 @@
namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
@ -29,11 +29,11 @@ class InstapaperController extends Controller
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
$name = 'instapaper_'.$this->getUser()->getId().'.csv';
$name = 'instapaper_' . $this->getUser()->getId() . '.csv';
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $instapaper
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@ -52,7 +52,7 @@ class InstapaperController extends Controller
]);
}
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
@ -61,12 +61,12 @@ class InstapaperController extends Controller
);
return $this->redirect($this->generateUrl('homepage'));
} else {
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [

View File

@ -2,8 +2,8 @@
namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
@ -29,11 +29,11 @@ class PinboardController extends Controller
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
$name = 'pinboard_'.$this->getUser()->getId().'.json';
$name = 'pinboard_' . $this->getUser()->getId() . '.json';
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $pinboard
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@ -52,7 +52,7 @@ class PinboardController extends Controller
]);
}
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
@ -61,12 +61,12 @@ class PinboardController extends Controller
);
return $this->redirect($this->generateUrl('homepage'));
} else {
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [

View File

@ -2,33 +2,14 @@
namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class PocketController extends Controller
{
/**
* Return Pocket Import Service with or without RabbitMQ enabled.
*
* @return \Wallabag\ImportBundle\Import\PocketImport
*/
private function getPocketImportService()
{
$pocket = $this->get('wallabag_import.pocket.import');
$pocket->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
$pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
$pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
}
return $pocket;
}
/**
* @Route("/pocket", name="import_pocket")
*/
@ -70,7 +51,7 @@ class PocketController extends Controller
$this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']);
return $this->redirect(
'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
'https://getpocket.com/auth/authorize?request_token=' . $requestToken . '&redirect_uri=' . $this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
301
);
}
@ -117,4 +98,23 @@ class PocketController extends Controller
return $this->redirect($this->generateUrl('homepage'));
}
/**
* Return Pocket Import Service with or without RabbitMQ enabled.
*
* @return \Wallabag\ImportBundle\Import\PocketImport
*/
private function getPocketImportService()
{
$pocket = $this->get('wallabag_import.pocket.import');
$pocket->setUser($this->getUser());
if ($this->get('craue_config')->get('import_with_rabbitmq')) {
$pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
} elseif ($this->get('craue_config')->get('import_with_redis')) {
$pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
}
return $pocket;
}
}

View File

@ -2,8 +2,8 @@
namespace Wallabag\ImportBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Wallabag\ImportBundle\Form\Type\UploadImportType;
@ -29,11 +29,11 @@ class ReadabilityController extends Controller
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
$name = 'readability_'.$this->getUser()->getId().'.json';
$name = 'readability_' . $this->getUser()->getId() . '.json';
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $readability
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@ -52,7 +52,7 @@ class ReadabilityController extends Controller
]);
}
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
@ -61,12 +61,12 @@ class ReadabilityController extends Controller
);
return $this->redirect($this->generateUrl('homepage'));
} else {
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
return $this->render('WallabagImportBundle:Readability:index.html.twig', [

View File

@ -11,20 +11,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType;
*/
abstract class WallabagController extends Controller
{
/**
* Return the service to handle the import.
*
* @return \Wallabag\ImportBundle\Import\ImportInterface
*/
abstract protected function getImportService();
/**
* Return the template used for the form.
*
* @return string
*/
abstract protected function getImportTemplate();
/**
* Handle import request.
*
@ -43,11 +29,11 @@ abstract class WallabagController extends Controller
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
$markAsRead = $form->get('mark_as_read')->getData();
$name = $this->getUser()->getId().'.json';
$name = $this->getUser()->getId() . '.json';
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
$res = $wallabag
->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@ -66,7 +52,7 @@ abstract class WallabagController extends Controller
]);
}
unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
}
$this->get('session')->getFlashBag()->add(
@ -75,12 +61,12 @@ abstract class WallabagController extends Controller
);
return $this->redirect($this->generateUrl('homepage'));
} else {
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.import.notice.failed_on_file'
);
}
return $this->render($this->getImportTemplate(), [
@ -88,4 +74,18 @@ abstract class WallabagController extends Controller
'import' => $wallabag,
]);
}
/**
* Return the service to handle the import.
*
* @return \Wallabag\ImportBundle\Import\ImportInterface
*/
abstract protected function getImportService();
/**
* Return the template used for the form.
*
* @return string
*/
abstract protected function getImportTemplate();
}

View File

@ -7,6 +7,14 @@ use Symfony\Component\HttpFoundation\Request;
class WallabagV1Controller extends WallabagController
{
/**
* @Route("/wallabag-v1", name="import_wallabag_v1")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
/**
* {@inheritdoc}
*/
@ -30,12 +38,4 @@ class WallabagV1Controller extends WallabagController
{
return 'WallabagImportBundle:WallabagV1:index.html.twig';
}
/**
* @Route("/wallabag-v1", name="import_wallabag_v1")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
}

View File

@ -7,6 +7,14 @@ use Symfony\Component\HttpFoundation\Request;
class WallabagV2Controller extends WallabagController
{
/**
* @Route("/wallabag-v2", name="import_wallabag_v2")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
/**
* {@inheritdoc}
*/
@ -30,12 +38,4 @@ class WallabagV2Controller extends WallabagController
{
return 'WallabagImportBundle:WallabagV2:index.html.twig';
}
/**
* @Route("/wallabag-v2", name="import_wallabag_v2")
*/
public function indexAction(Request $request)
{
return parent::indexAction($request);
}
}