Commit 0a1e6538 authored by Emma's avatar Emma 🦉

rearrange some classes, remove dead code

parent 8568c41a
......@@ -38,6 +38,10 @@ services:
arguments:
$defaultLocale: "%env(APP_LOCALE)%"
App\CommonMark\CachedMarkdownConverter:
arguments:
$cacheItemPool: "@cache.markdown"
App\Controller\ForumController:
arguments:
$enableWebhooks: "%env(bool:APP_ENABLE_WEBHOOKS)%"
......@@ -77,6 +81,11 @@ services:
$noReplyAddress: "%env(NO_REPLY_ADDRESS)%"
$salt: "%env(APP_SECRET)%"
App\Security\AuthenticationHelper:
arguments:
$rememberMeServices: "@security.authentication.rememberme.services.simplehash.main"
$secret: "%env(APP_SECRET)%"
App\Security\Voter\TokenVoter:
arguments:
$forumCreationInterval: "%user_forum_creation_interval%"
......@@ -86,15 +95,6 @@ services:
$siteName: "%env(SITE_NAME)%"
$enableWebhooks: "%env(bool:APP_ENABLE_WEBHOOKS)%"
App\Utils\CachedMarkdownConverter:
arguments:
$cacheItemPool: "@cache.markdown"
App\Utils\AuthenticationHelper:
arguments:
$rememberMeServices: "@security.authentication.rememberme.services.simplehash.main"
$secret: "%env(APP_SECRET)%"
## Misc
......
<?php
namespace App\Utils;
namespace App\CommonMark;
use Psr\Cache\CacheItemPoolInterface;
......
<?php
namespace App\Utils;
namespace App\CommonMark;
use App\Entity\User;
use Symfony\Component\HttpFoundation\RequestStack;
......
<?php
namespace App\Utils;
namespace App\CommonMark;
use App\CommonMark\AppExtension;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
......
......@@ -2,8 +2,8 @@
namespace App\Controller;
use App\Utils\MarkdownContext;
use App\Utils\MarkdownConverter;
use App\CommonMark\MarkdownContext;
use App\CommonMark\MarkdownConverter;
use Embed\Embed;
use Embed\Exceptions\InvalidUrlException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
......
......@@ -15,7 +15,7 @@ use App\Form\UserType;
use App\Repository\ForumBanRepository;
use App\Repository\NotificationRepository;
use App\Repository\UserRepository;
use App\Utils\AuthenticationHelper;
use App\Security\AuthenticationHelper;
use Doctrine\ORM\EntityManager;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
......
<?php
namespace App\Utils;
namespace App\Security;
use App\Entity\User;
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
......
......@@ -2,9 +2,9 @@
namespace App\Twig;
use App\Utils\CachedMarkdownConverter;
use App\Utils\MarkdownContext;
use App\Utils\MarkdownConverter;
use App\CommonMark\CachedMarkdownConverter;
use App\CommonMark\MarkdownContext;
use App\CommonMark\MarkdownConverter;
use App\Utils\Slugger;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
......
<?php
namespace App\Utils;
use Doctrine\DBAL\Query\QueryBuilder as SQLQueryBuilder;
use Doctrine\ORM\QueryBuilder as DQLQueryBuilder;
/**
* Work around missing ability to prepend orderBy clauses in Doctrine's query
* builder classes.
*/
final class PrependOrderBy {
/**
* @param DQLQueryBuilder|SQLQueryBuilder $qb
* @param string $clause
* @param string $order
*/
public static function prepend($qb, string $clause, string $order = 'ASC') {
if ($qb instanceof SQLQueryBuilder) {
self::prependWithSqlBuilder($qb, $clause, $order);
} elseif ($qb instanceof DQLQueryBuilder) {
self::prependWithDqlBuilder($qb, $clause, $order);
} else {
throw new \InvalidArgumentException(sprintf(
'Parameter 1 must be %s or %s',
DQLQueryBuilder::class,
SQLQueryBuilder::class
));
}
}
private static function prependWithSqlBuilder(SQLQueryBuilder $qb, string $clause, string $order) {
$orderBy = $qb->getQueryPart('orderBy');
$qb->orderBy($clause, $order);
foreach ($orderBy as $clause) {
preg_match('/^(.*) (ASC|DESC)$/', $clause, $matches);
$qb->addOrderBy($matches[1], $matches[2]);
}
}
private static function prependWithDqlBuilder(DQLQueryBuilder $qb, string $clause, string $order) {
$orderBy = $qb->getDQLPart('orderBy');
$qb->orderBy($clause, $order);
foreach ($orderBy as $clause) {
$qb->addOrderBy($clause);
}
}
}
......@@ -2,8 +2,8 @@
namespace App\Tests\Utils;
use App\Utils\CachedMarkdownConverter;
use App\Utils\MarkdownConverter;
use App\CommonMark\CachedMarkdownConverter;
use App\CommonMark\MarkdownConverter;
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
......@@ -42,7 +42,7 @@ class CachedMarkdownConverterTest extends TestCase {
->expects($this->never())
->method('convertToHtml');
/* @var \App\Utils\CachedMarkdownConverter $cachedConverter */
/* @var \App\CommonMark\CachedMarkdownConverter $cachedConverter */
$cachedConverter = $this->getMockBuilder(CachedMarkdownConverter::class)
->setConstructorArgs([$cacheItemPool, $converter])
->enableProxyingToOriginalMethods()
......@@ -96,7 +96,7 @@ class CachedMarkdownConverterTest extends TestCase {
)
->willReturn('html output');
/* @var \App\Utils\CachedMarkdownConverter $cachedConverter */
/* @var \App\CommonMark\CachedMarkdownConverter $cachedConverter */
$cachedConverter = $this->getMockBuilder(CachedMarkdownConverter::class)
->setConstructorArgs([$cacheItemPool, $converter])
->enableProxyingToOriginalMethods()
......
......@@ -2,8 +2,8 @@
namespace App\Tests\Utils;
use App\CommonMark\MarkdownContext;
use App\Entity\User;
use App\Utils\MarkdownContext;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
......
......@@ -2,7 +2,7 @@
namespace App\Tests\Utils;
use App\Utils\MarkdownConverter;
use App\CommonMark\MarkdownConverter;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment