mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Add a real configuration for CS-Fixer
This commit is contained in:
parent
822c877949
commit
f808b01692
170 changed files with 3147 additions and 3120 deletions
|
@ -10,8 +10,8 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
use Wallabag\CoreBundle\Entity\TaggingRule;
|
||||
use Wallabag\CoreBundle\Form\Type\ConfigType;
|
||||
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
|
||||
use Wallabag\CoreBundle\Form\Type\ConfigType;
|
||||
use Wallabag\CoreBundle\Form\Type\RssType;
|
||||
use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
|
||||
use Wallabag\CoreBundle\Form\Type\UserInformationType;
|
||||
|
@ -54,7 +54,7 @@ class ConfigController extends Controller
|
|||
}
|
||||
|
||||
// handle changing password
|
||||
$pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config').'#set4']);
|
||||
$pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config') . '#set4']);
|
||||
$pwdForm->handleRequest($request);
|
||||
|
||||
if ($pwdForm->isSubmitted() && $pwdForm->isValid()) {
|
||||
|
@ -69,13 +69,13 @@ class ConfigController extends Controller
|
|||
|
||||
$this->get('session')->getFlashBag()->add('notice', $message);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set4');
|
||||
return $this->redirect($this->generateUrl('config') . '#set4');
|
||||
}
|
||||
|
||||
// handle changing user information
|
||||
$userForm = $this->createForm(UserInformationType::class, $user, [
|
||||
'validation_groups' => ['Profile'],
|
||||
'action' => $this->generateUrl('config').'#set3',
|
||||
'action' => $this->generateUrl('config') . '#set3',
|
||||
]);
|
||||
$userForm->handleRequest($request);
|
||||
|
||||
|
@ -87,11 +87,11 @@ class ConfigController extends Controller
|
|||
'flashes.config.notice.user_updated'
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set3');
|
||||
return $this->redirect($this->generateUrl('config') . '#set3');
|
||||
}
|
||||
|
||||
// handle rss information
|
||||
$rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config').'#set2']);
|
||||
$rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config') . '#set2']);
|
||||
$rssForm->handleRequest($request);
|
||||
|
||||
if ($rssForm->isSubmitted() && $rssForm->isValid()) {
|
||||
|
@ -103,12 +103,12 @@ class ConfigController extends Controller
|
|||
'flashes.config.notice.rss_updated'
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set2');
|
||||
return $this->redirect($this->generateUrl('config') . '#set2');
|
||||
}
|
||||
|
||||
// handle tagging rule
|
||||
$taggingRule = new TaggingRule();
|
||||
$action = $this->generateUrl('config').'#set5';
|
||||
$action = $this->generateUrl('config') . '#set5';
|
||||
|
||||
if ($request->query->has('tagging-rule')) {
|
||||
$taggingRule = $this->getDoctrine()
|
||||
|
@ -119,7 +119,7 @@ class ConfigController extends Controller
|
|||
return $this->redirect($action);
|
||||
}
|
||||
|
||||
$action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5';
|
||||
$action = $this->generateUrl('config') . '?tagging-rule=' . $taggingRule->getId() . '#set5';
|
||||
}
|
||||
|
||||
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
|
||||
|
@ -135,7 +135,7 @@ class ConfigController extends Controller
|
|||
'flashes.config.notice.tagging_rules_updated'
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set5');
|
||||
return $this->redirect($this->generateUrl('config') . '#set5');
|
||||
}
|
||||
|
||||
return $this->render('WallabagCoreBundle:Config:index.html.twig', [
|
||||
|
@ -182,7 +182,7 @@ class ConfigController extends Controller
|
|||
'flashes.config.notice.rss_token_updated'
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set2');
|
||||
return $this->redirect($this->generateUrl('config') . '#set2');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,7 +207,7 @@ class ConfigController extends Controller
|
|||
'flashes.config.notice.tagging_rules_deleted'
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set5');
|
||||
return $this->redirect($this->generateUrl('config') . '#set5');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -223,7 +223,7 @@ class ConfigController extends Controller
|
|||
{
|
||||
$this->validateRuleAction($rule);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
|
||||
return $this->redirect($this->generateUrl('config') . '?tagging-rule=' . $rule->getId() . '#set5');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,11 +241,9 @@ class ConfigController extends Controller
|
|||
->getRepository('WallabagAnnotationBundle:Annotation')
|
||||
->removeAllByUserId($this->getUser()->getId());
|
||||
break;
|
||||
|
||||
case 'tags':
|
||||
$this->removeAllTagsByUserId($this->getUser()->getId());
|
||||
break;
|
||||
|
||||
case 'entries':
|
||||
// SQLite doesn't care about cascading remove, so we need to manually remove associated stuff
|
||||
// otherwise they won't be removed ...
|
||||
|
@ -272,10 +270,63 @@ class ConfigController extends Controller
|
|||
|
||||
$this->get('session')->getFlashBag()->add(
|
||||
'notice',
|
||||
'flashes.config.notice.'.$type.'_reset'
|
||||
'flashes.config.notice.' . $type . '_reset'
|
||||
);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'#set3');
|
||||
return $this->redirect($this->generateUrl('config') . '#set3');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete account for current user.
|
||||
*
|
||||
* @Route("/account/delete", name="delete_account")
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws AccessDeniedHttpException
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function deleteAccountAction(Request $request)
|
||||
{
|
||||
$enabledUsers = $this->get('wallabag_user.user_repository')
|
||||
->getSumEnabledUsers();
|
||||
|
||||
if ($enabledUsers <= 1) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$user = $this->getUser();
|
||||
|
||||
// logout current user
|
||||
$this->get('security.token_storage')->setToken(null);
|
||||
$request->getSession()->invalidate();
|
||||
|
||||
$em = $this->get('fos_user.user_manager');
|
||||
$em->deleteUser($user);
|
||||
|
||||
return $this->redirect($this->generateUrl('fos_user_security_login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch view mode for current user.
|
||||
*
|
||||
* @Route("/config/view-mode", name="switch_view_mode")
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function changeViewModeAction(Request $request)
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$user->getConfig()->setListMode(!$user->getConfig()->getListMode());
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,7 +400,7 @@ class ConfigController extends Controller
|
|||
*/
|
||||
private function validateRuleAction(TaggingRule $rule)
|
||||
{
|
||||
if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
|
||||
if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) {
|
||||
throw $this->createAccessDeniedException('You can not access this tagging rule.');
|
||||
}
|
||||
}
|
||||
|
@ -373,57 +424,4 @@ class ConfigController extends Controller
|
|||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete account for current user.
|
||||
*
|
||||
* @Route("/account/delete", name="delete_account")
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws AccessDeniedHttpException
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function deleteAccountAction(Request $request)
|
||||
{
|
||||
$enabledUsers = $this->get('wallabag_user.user_repository')
|
||||
->getSumEnabledUsers();
|
||||
|
||||
if ($enabledUsers <= 1) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$user = $this->getUser();
|
||||
|
||||
// logout current user
|
||||
$this->get('security.token_storage')->setToken(null);
|
||||
$request->getSession()->invalidate();
|
||||
|
||||
$em = $this->get('fos_user.user_manager');
|
||||
$em->deleteUser($user);
|
||||
|
||||
return $this->redirect($this->generateUrl('fos_user_security_login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch view mode for current user.
|
||||
*
|
||||
* @Route("/config/view-mode", name="switch_view_mode")
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function changeViewModeAction(Request $request)
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$user->getConfig()->setListMode(!$user->getConfig()->getListMode());
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,17 +4,17 @@ namespace Wallabag\CoreBundle\Controller;
|
|||
|
||||
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
||||
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Form\Type\EntryFilterType;
|
||||
use Wallabag\CoreBundle\Form\Type\EditEntryType;
|
||||
use Wallabag\CoreBundle\Form\Type\NewEntryType;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
|
||||
use Wallabag\CoreBundle\Event\EntrySavedEvent;
|
||||
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
|
||||
use Wallabag\CoreBundle\Event\EntrySavedEvent;
|
||||
use Wallabag\CoreBundle\Form\Type\EditEntryType;
|
||||
use Wallabag\CoreBundle\Form\Type\EntryFilterType;
|
||||
use Wallabag\CoreBundle\Form\Type\NewEntryType;
|
||||
use Wallabag\CoreBundle\Form\Type\SearchEntryType;
|
||||
|
||||
class EntryController extends Controller
|
||||
|
@ -51,31 +51,6 @@ class EntryController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch content and update entry.
|
||||
* In case it fails, $entry->getContent will return an error message.
|
||||
*
|
||||
* @param Entry $entry
|
||||
* @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
|
||||
*/
|
||||
private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
|
||||
{
|
||||
$message = 'flashes.entry.notice.'.$prefixMessage;
|
||||
|
||||
try {
|
||||
$this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
|
||||
} catch (\Exception $e) {
|
||||
$this->get('logger')->error('Error while saving an entry', [
|
||||
'exception' => $e,
|
||||
'entry' => $entry,
|
||||
]);
|
||||
|
||||
$message = 'flashes.entry.notice.'.$prefixMessage.'_failed';
|
||||
}
|
||||
|
||||
$this->get('session')->getFlashBag()->add('notice', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
|
@ -220,7 +195,7 @@ class EntryController extends Controller
|
|||
public function showUnreadAction(Request $request, $page)
|
||||
{
|
||||
// load the quickstart if no entry in database
|
||||
if ($page == 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) == 0) {
|
||||
if ($page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
|
||||
return $this->redirect($this->generateUrl('quickstart'));
|
||||
}
|
||||
|
||||
|
@ -257,83 +232,6 @@ class EntryController extends Controller
|
|||
return $this->showEntries('starred', $request, $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global method to retrieve entries depending on the given type
|
||||
* It returns the response to be send.
|
||||
*
|
||||
* @param string $type Entries type: unread, starred or archive
|
||||
* @param Request $request
|
||||
* @param int $page
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
private function showEntries($type, Request $request, $page)
|
||||
{
|
||||
$repository = $this->get('wallabag_core.entry_repository');
|
||||
$searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
|
||||
$currentRoute = (!is_null($request->query->get('currentRoute')) ? $request->query->get('currentRoute') : '');
|
||||
|
||||
switch ($type) {
|
||||
case 'search':
|
||||
$qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
|
||||
|
||||
break;
|
||||
case 'untagged':
|
||||
$qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
|
||||
|
||||
break;
|
||||
case 'starred':
|
||||
$qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
|
||||
break;
|
||||
|
||||
case 'archive':
|
||||
$qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
|
||||
break;
|
||||
|
||||
case 'unread':
|
||||
$qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
|
||||
break;
|
||||
|
||||
case 'all':
|
||||
$qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
|
||||
}
|
||||
|
||||
$form = $this->createForm(EntryFilterType::class);
|
||||
|
||||
if ($request->query->has($form->getName())) {
|
||||
// manually bind values from the request
|
||||
$form->submit($request->query->get($form->getName()));
|
||||
|
||||
// build the query from the given form object
|
||||
$this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
|
||||
}
|
||||
|
||||
$pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
|
||||
|
||||
$entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
|
||||
|
||||
try {
|
||||
$entries->setCurrentPage($page);
|
||||
} catch (OutOfRangeCurrentPageException $e) {
|
||||
if ($page > 1) {
|
||||
return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'WallabagCoreBundle:Entry:entries.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'entries' => $entries,
|
||||
'currentPage' => $page,
|
||||
'searchTerm' => $searchTerm,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows entry content.
|
||||
*
|
||||
|
@ -487,37 +385,13 @@ class EntryController extends Controller
|
|||
|
||||
// don't redirect user to the deleted entry (check that the referer doesn't end with the same url)
|
||||
$referer = $request->headers->get('referer');
|
||||
$to = (1 !== preg_match('#'.$url.'$#i', $referer) ? $referer : null);
|
||||
$to = (1 !== preg_match('#' . $url . '$#i', $referer) ? $referer : null);
|
||||
|
||||
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to);
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the logged user can manage the given entry.
|
||||
*
|
||||
* @param Entry $entry
|
||||
*/
|
||||
private function checkUserAction(Entry $entry)
|
||||
{
|
||||
if (null === $this->getUser() || $this->getUser()->getId() != $entry->getUser()->getId()) {
|
||||
throw $this->createAccessDeniedException('You can not access this entry.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for existing entry, if it exists, redirect to it with a message.
|
||||
*
|
||||
* @param Entry $entry
|
||||
*
|
||||
* @return Entry|bool
|
||||
*/
|
||||
private function checkIfEntryAlreadyExists(Entry $entry)
|
||||
{
|
||||
return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get public URL for entry (and generate it if necessary).
|
||||
*
|
||||
|
@ -604,4 +478,126 @@ class EntryController extends Controller
|
|||
{
|
||||
return $this->showEntries('untagged', $request, $page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch content and update entry.
|
||||
* In case it fails, $entry->getContent will return an error message.
|
||||
*
|
||||
* @param Entry $entry
|
||||
* @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
|
||||
*/
|
||||
private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
|
||||
{
|
||||
$message = 'flashes.entry.notice.' . $prefixMessage;
|
||||
|
||||
try {
|
||||
$this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
|
||||
} catch (\Exception $e) {
|
||||
$this->get('logger')->error('Error while saving an entry', [
|
||||
'exception' => $e,
|
||||
'entry' => $entry,
|
||||
]);
|
||||
|
||||
$message = 'flashes.entry.notice.' . $prefixMessage . '_failed';
|
||||
}
|
||||
|
||||
$this->get('session')->getFlashBag()->add('notice', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global method to retrieve entries depending on the given type
|
||||
* It returns the response to be send.
|
||||
*
|
||||
* @param string $type Entries type: unread, starred or archive
|
||||
* @param Request $request
|
||||
* @param int $page
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
private function showEntries($type, Request $request, $page)
|
||||
{
|
||||
$repository = $this->get('wallabag_core.entry_repository');
|
||||
$searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
|
||||
$currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : '');
|
||||
|
||||
switch ($type) {
|
||||
case 'search':
|
||||
$qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
|
||||
|
||||
break;
|
||||
case 'untagged':
|
||||
$qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
|
||||
|
||||
break;
|
||||
case 'starred':
|
||||
$qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
|
||||
break;
|
||||
case 'archive':
|
||||
$qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
|
||||
break;
|
||||
case 'unread':
|
||||
$qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
|
||||
break;
|
||||
case 'all':
|
||||
$qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
|
||||
}
|
||||
|
||||
$form = $this->createForm(EntryFilterType::class);
|
||||
|
||||
if ($request->query->has($form->getName())) {
|
||||
// manually bind values from the request
|
||||
$form->submit($request->query->get($form->getName()));
|
||||
|
||||
// build the query from the given form object
|
||||
$this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
|
||||
}
|
||||
|
||||
$pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
|
||||
|
||||
$entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
|
||||
|
||||
try {
|
||||
$entries->setCurrentPage($page);
|
||||
} catch (OutOfRangeCurrentPageException $e) {
|
||||
if ($page > 1) {
|
||||
return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'WallabagCoreBundle:Entry:entries.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'entries' => $entries,
|
||||
'currentPage' => $page,
|
||||
'searchTerm' => $searchTerm,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the logged user can manage the given entry.
|
||||
*
|
||||
* @param Entry $entry
|
||||
*/
|
||||
private function checkUserAction(Entry $entry)
|
||||
{
|
||||
if (null === $this->getUser() || $this->getUser()->getId() !== $entry->getUser()->getId()) {
|
||||
throw $this->createAccessDeniedException('You can not access this entry.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for existing entry, if it exists, redirect to it with a message.
|
||||
*
|
||||
* @param Entry $entry
|
||||
*
|
||||
* @return Entry|bool
|
||||
*/
|
||||
private function checkIfEntryAlreadyExists(Entry $entry)
|
||||
{
|
||||
return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class ExceptionController extends BaseExceptionController
|
|||
protected function findTemplate(Request $request, $format, $code, $showException)
|
||||
{
|
||||
$name = $showException ? 'exception' : 'error';
|
||||
if ($showException && 'html' == $format) {
|
||||
if ($showException && 'html' === $format) {
|
||||
$name = 'exception_full';
|
||||
}
|
||||
|
||||
|
|
|
@ -55,10 +55,10 @@ class ExportController extends Controller
|
|||
public function downloadEntriesAction(Request $request, $format, $category)
|
||||
{
|
||||
$method = ucfirst($category);
|
||||
$methodBuilder = 'getBuilderFor'.$method.'ByUser';
|
||||
$methodBuilder = 'getBuilderFor' . $method . 'ByUser';
|
||||
$repository = $this->get('wallabag_core.entry_repository');
|
||||
|
||||
if ($category == 'tag_entries') {
|
||||
if ($category === 'tag_entries') {
|
||||
$tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
|
||||
|
||||
$entries = $repository->findAllByTagId(
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
namespace Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
||||
use Pagerfanta\Adapter\ArrayAdapter;
|
||||
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
||||
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
class RssController extends Controller
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ class RssController extends Controller
|
|||
$entries->setCurrentPage($page);
|
||||
} catch (OutOfRangeCurrentPageException $e) {
|
||||
if ($page > 1) {
|
||||
return $this->redirect($url.'?page='.$entries->getNbPages(), 302);
|
||||
return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ class RssController extends Controller
|
|||
'@WallabagCore/themes/common/Entry/entries.xml.twig',
|
||||
[
|
||||
'url_html' => $this->generateUrl('tag_entries', ['slug' => $tag->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
|
||||
'type' => 'tag ('.$tag->getLabel().')',
|
||||
'type' => 'tag (' . $tag->getLabel() . ')',
|
||||
'url' => $url,
|
||||
'entries' => $entries,
|
||||
],
|
||||
|
@ -147,19 +147,15 @@ class RssController extends Controller
|
|||
case 'starred':
|
||||
$qb = $repository->getBuilderForStarredByUser($user->getId());
|
||||
break;
|
||||
|
||||
case 'archive':
|
||||
$qb = $repository->getBuilderForArchiveByUser($user->getId());
|
||||
break;
|
||||
|
||||
case 'unread':
|
||||
$qb = $repository->getBuilderForUnreadByUser($user->getId());
|
||||
break;
|
||||
|
||||
case 'all':
|
||||
$qb = $repository->getBuilderForAllByUser($user->getId());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
|
||||
}
|
||||
|
@ -171,7 +167,7 @@ class RssController extends Controller
|
|||
$entries->setMaxPerPage($perPage);
|
||||
|
||||
$url = $this->generateUrl(
|
||||
$type.'_rss',
|
||||
$type . '_rss',
|
||||
[
|
||||
'username' => $user->getUsername(),
|
||||
'token' => $user->getConfig()->getRssToken(),
|
||||
|
@ -183,7 +179,7 @@ class RssController extends Controller
|
|||
$entries->setCurrentPage((int) $page);
|
||||
} catch (OutOfRangeCurrentPageException $e) {
|
||||
if ($page > 1) {
|
||||
return $this->redirect($url.'?page='.$entries->getNbPages(), 302);
|
||||
return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace Wallabag\CoreBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Wallabag\CoreBundle\Entity\SiteCredential;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* SiteCredential controller.
|
||||
|
@ -167,7 +167,7 @@ class SiteCredentialController extends Controller
|
|||
*/
|
||||
private function checkUserAction(SiteCredential $siteCredential)
|
||||
{
|
||||
if (null === $this->getUser() || $this->getUser()->getId() != $siteCredential->getUser()->getId()) {
|
||||
if (null === $this->getUser() || $this->getUser()->getId() !== $siteCredential->getUser()->getId()) {
|
||||
throw $this->createAccessDeniedException('You can not access this site credential.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,9 @@ class StaticController extends Controller
|
|||
|
||||
return $this->render(
|
||||
'@WallabagCore/themes/common/Static/howto.html.twig',
|
||||
['addonsUrl' => $addonsUrl]
|
||||
[
|
||||
'addonsUrl' => $addonsUrl,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -40,8 +42,7 @@ class StaticController extends Controller
|
|||
public function quickstartAction()
|
||||
{
|
||||
return $this->render(
|
||||
'@WallabagCore/themes/common/Static/quickstart.html.twig',
|
||||
[]
|
||||
'@WallabagCore/themes/common/Static/quickstart.html.twig'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ namespace Wallabag\CoreBundle\Controller;
|
|||
|
||||
use Pagerfanta\Adapter\ArrayAdapter;
|
||||
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Wallabag\CoreBundle\Entity\Entry;
|
||||
use Wallabag\CoreBundle\Entity\Tag;
|
||||
use Wallabag\CoreBundle\Form\Type\NewTagType;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
|
||||
class TagController extends Controller
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue