Compare commits

..

5 commits

Author SHA1 Message Date
Alexey Skobkin ab3a54bde9
Fixing main templates. 2023-08-17 01:40:29 +03:00
Alexey Skobkin 2673272fc7
Fixing controller action names and routing configuration accordingly. 2023-08-17 01:39:06 +03:00
Alexey Skobkin a58cd2a1ea
Fixing KNP Paginator template configuration. 2023-08-17 01:37:47 +03:00
Alexey Skobkin b7cf85fbcd
Fixing Doctrine DQL DAY function implementation configuration. 2023-08-17 01:37:24 +03:00
Alexey Skobkin 34718ceaf4
Fixing collection type hinting in entities. 2023-08-17 01:36:40 +03:00
15 changed files with 53 additions and 49 deletions

View file

@ -19,7 +19,7 @@ doctrine:
dql:
string_functions:
# TODO fix to receive correct DateTime instead of string
DAY: App\DQL\Day
DAY: App\Doctrine\DQL\Day
when@test:
doctrine:

View file

@ -1,4 +1,4 @@
# https://github.com/KnpLabs/KnpPaginatorBundle#yaml
knp_paginator:
template:
pagination: 'KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig'
pagination: '@KnpPaginator/Pagination/bootstrap_v5_pagination.html.twig'

View file

@ -6,7 +6,7 @@
index:
path: /
defaults: { _controller: App\Controller\MainController::indexAction }
defaults: { _controller: App\Controller\MainController::index }
methods: [POST, GET]
user_search_ajax:

View file

@ -15,7 +15,7 @@ class ApiController
*
* @ParamConverter("user", class="SkobkinPointToolsBundle:User")
*/
public function lastUserSubscribersByIdAction(User $user, SubscriptionEventRepository $subscriptionEventRepository): Response
public function lastUserSubscribersById(User $user, SubscriptionEventRepository $subscriptionEventRepository): Response
{
$qb = $subscriptionEventRepository->createQueryBuilder('se');
$qb

View file

@ -10,7 +10,7 @@ use Symfony\Component\HttpFoundation\{Request, Response};
class EventsController extends AbstractController
{
public function lastAction(Request $request, SubscriptionEventRepository $eventRepository, PaginatorInterface $paginator): Response
public function last(Request $request, SubscriptionEventRepository $eventRepository, PaginatorInterface $paginator): Response
{
$eventsPagination = $paginator->paginate(
$eventRepository->createLastSubscriptionEventsQuery(),

View file

@ -19,7 +19,7 @@ class MainController extends AbstractController
) {
}
public function indexAction(
public function index(
Request $request,
UserRepository $userRepository,
SubscriptionRepository $subscriptionRepository,
@ -56,7 +56,7 @@ class MainController extends AbstractController
}
/** Returns user search autocomplete data in JSON */
public function searchUserAjaxAction(string $login, UserRepository $userRepository): JsonResponse
public function searchUserAjax(string $login, UserRepository $userRepository): JsonResponse
{
$result = [];

View file

@ -14,7 +14,7 @@ class PostController extends AbstractController
/**
* @ParamConverter("post", class="SkobkinPointToolsBundle:Blogs\Post")
*/
public function showAction(Post $post, PostRepository $postRepository): Response
public function show(Post $post, PostRepository $postRepository): Response
{
if ((!$post->getAuthor()->isPublic()) || $post->getAuthor()->isWhitelistOnly()) {
/**

View file

@ -12,7 +12,7 @@ class PublicFeedController extends AbstractController
{
private const POSTS_PER_PAGE = 20;
public function indexAction(Request $request, PostRepository $postRepository, PaginatorInterface $paginator): Response
public function index(Request $request, PostRepository $postRepository, PaginatorInterface $paginator): Response
{
$postsPagination = $paginator->paginate(
$postRepository->createPublicFeedPostsQuery(),

View file

@ -19,7 +19,7 @@ class UserController extends AbstractController
) {
}
public function showAction(
public function show(
Request $request,
string $login,
SubscriptionEventRepository $subscriptionEventRepository,
@ -40,7 +40,7 @@ class UserController extends AbstractController
10
);
return $this->render('SkobkinPointToolsBundle:User:show.html.twig', [
return $this->render('Web/User/show.html.twig', [
'user' => $user,
'subscribers' => $userRepository->findUserSubscribersById($user->getId()),
'subscriptions_log' => $subscriberEventsPagination,
@ -48,12 +48,12 @@ class UserController extends AbstractController
]);
}
public function topAction(UserRepository $userRepository, SubscriptionEventRepository $subscriptionEventRepository): Response
public function top(UserRepository $userRepository, SubscriptionEventRepository $subscriptionEventRepository): Response
{
$topUsers = $userRepository->getTopUsers();
$eventsByDay = $subscriptionEventRepository->getLastEventsByDay();
return $this->render('@SkobkinPointTools/User/top.html.twig', [
return $this->render('Web/User/top.html.twig', [
'events_dynamic_chat' => $this->createEventsDynamicChart($eventsByDay),
'top_chart' => $this->createTopUsersGraph($topUsers),
]);

View file

@ -3,11 +3,10 @@ declare(strict_types=1);
namespace App\Entity\Blog;
use App\Entity\Blog\File;
use App\Entity\Blog\Post;
use App\Entity\User;
use App\Repository\Blog\CommentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CommentRepository::class)]
@ -43,20 +42,20 @@ class Comment
#[ORM\JoinColumn(name: 'author_id')]
private User $author;
/** @var ArrayCollection|File[] */
/** @var Collection<int, File> */
#[ORM\ManyToMany(targetEntity: File::class, fetch: 'EXTRA_LAZY')]
#[ORM\JoinTable(name: 'comments_files', schema: 'posts')]
#[ORM\JoinColumn(name: 'comment_id')]
#[ORM\InverseJoinColumn(name: 'file_id')]
private ArrayCollection $files;
private Collection $files;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinColumn(name: 'parent_id', nullable: true)]
private ?self $parent;
/** @var ArrayCollection|self[] */
/** @var Collection<int, self> */
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class, fetch: 'EXTRA_LAZY')]
private ArrayCollection $children;
private Collection $children;
public function __construct()
@ -159,10 +158,8 @@ class Comment
$this->files->removeElement($files);
}
/**
* @return File[]|ArrayCollection
*/
public function getFiles(): iterable
/** @return Collection<int, File> */
public function getFiles(): Collection
{
return $this->files;
}
@ -208,8 +205,8 @@ class Comment
$this->children->removeElement($children);
}
/** @return ArrayCollection|self[] */
public function getChildren(): iterable
/** @return Collection<int, self> */
public function getChildren(): Collection
{
return $this->children;
}

View file

@ -6,6 +6,7 @@ namespace App\Entity\Blog;
use App\Entity\User;
use App\Repository\Blog\TagRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: TagRepository::class)]
@ -29,6 +30,7 @@ class Post
#[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true)]
private ?\DateTime $updatedAt;
// TODO: Native Enum
#[ORM\Column(name: 'type', type: 'string', length: 6)]
private string $type = self::TYPE_POST;
@ -42,19 +44,20 @@ class Post
#[ORM\JoinColumn(name: 'author')]
private User $author;
/** @var ArrayCollection|File[] */
/** @var Collection<int, File> */
#[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], fetch: 'EXTRA_LAZY')]
#[ORM\JoinTable(name: 'posts_files', schema: 'posts')]
#[ORM\JoinColumn(name: 'post_id')]
#[ORM\InverseJoinColumn(name: 'file_id')]
private $files;
private Collection $files;
/** @var Collection<int, PostTag> */
#[ORM\OneToMany(mappedBy: 'post', targetEntity: PostTag::class, cascade: ['persist'], fetch: 'EXTRA_LAZY', orphanRemoval: true)]
private ArrayCollection $postTags;
private Collection $postTags;
/** @var ArrayCollection|Comment[] */
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'post', cascade: ['persist'], )]
private ArrayCollection $comments;
/** @var Collection<int, Comment> */
#[ORM\OneToMany(mappedBy: 'post', targetEntity: Comment::class, cascade: ['persist'])]
private Collection $comments;
public function __construct(string $id, User $author, \DateTime $createdAt, string $type)
@ -124,8 +127,8 @@ class Post
$this->files->removeElement($files);
}
/** @return File[]|ArrayCollection */
public function getFiles(): iterable
/** @return Collection<int, File> */
public function getFiles(): Collection
{
return $this->files;
}
@ -142,8 +145,8 @@ class Post
$this->postTags->removeElement($tag);
}
/** @return PostTag[]|ArrayCollection */
public function getPostTags(): iterable
/** @return Collection<int, PostTag> */
public function getPostTags(): Collection
{
return $this->postTags;
}
@ -195,8 +198,8 @@ class Post
$this->comments->removeElement($comment);
}
/** @return Comment[]|ArrayCollection */
public function getComments(): iterable
/** @return Collection<int, Comment> */
public function getComments(): Collection
{
return $this->comments;
}

View file

@ -6,6 +6,7 @@ namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: UserRepository::class)]
@ -41,14 +42,17 @@ class User
#[ORM\Column(name: 'whitelist_only', type: 'boolean', nullable: false, options: ['default' => false])]
private bool $whitelistOnly = false;
/** @var Collection<int, Subscription> */
#[ORM\OneToMany(mappedBy: 'author', targetEntity: Subscription::class, fetch: 'EXTRA_LAZY')]
private ArrayCollection $subscribers;
private Collection $subscribers;
/** @var Collection<int, Subscription> */
#[ORM\OneToMany(mappedBy: 'subscriber', targetEntity: Subscription::class, fetch: 'EXTRA_LAZY')]
private ArrayCollection $subscriptions;
private Collection $subscriptions;
/** @var Collection<int, SubscriptionEvent> */
#[ORM\OneToMany(mappedBy: 'author', targetEntity: SubscriptionEvent::class, fetch: 'EXTRA_LAZY')]
private ArrayCollection $newSubscriberEvents;
private Collection $newSubscriberEvents;
#[ORM\Column(name: 'is_removed', type: 'boolean', options: ['default' => false])]
private bool $removed = false;
@ -110,14 +114,14 @@ class User
$this->subscribers->removeElement($subscribers);
}
/** @return Subscription[]|ArrayCollection */
public function getSubscribers(): ArrayCollection
/** @return Collection<int, Subscription> */
public function getSubscribers(): Collection
{
return $this->subscribers;
}
/** @return Subscription[]|ArrayCollection */
public function getSubscriptions(): ArrayCollection
/** @return Collection<int, Subscription> */
public function getSubscriptions(): Collection
{
return $this->subscriptions;
}
@ -129,8 +133,8 @@ class User
return $this;
}
/** @return SubscriptionEvent[]|ArrayCollection */
public function getNewSubscriberEvents(): ArrayCollection
/** @return Collection<int, SubscriptionEvent> */
public function getNewSubscriberEvents(): Collection
{
return $this->newSubscriberEvents;
}

View file

@ -1,4 +1,4 @@
{% extends "::base.html.twig" %}
{% extends 'Web/base.html.twig' %}
{% block content %}
{# TODO classes #}

View file

@ -1,4 +1,4 @@
{% extends "::base.html.twig" %}
{% extends 'Web/base.html.twig' %}
{% block header_title %}{{ user.login }} @ Point Tools{% endblock %}

View file

@ -1,4 +1,4 @@
{% extends "::base.html.twig" %}
{% extends 'Web/base.html.twig' %}
{% block header_title %}Stats @ Point Tools{% endblock %}