WIP: Symfony 6 project remake #2

Draft
skobkin wants to merge 103 commits from symfony6_remake into master
18 changed files with 526 additions and 43 deletions
Showing only changes of commit 3a69565ecb - Show all commits

View file

@ -15,6 +15,7 @@
"doctrine/orm": "^2.14", "doctrine/orm": "^2.14",
"jms/serializer-bundle": "^5.2", "jms/serializer-bundle": "^5.2",
"knplabs/knp-paginator-bundle": "^6.2", "knplabs/knp-paginator-bundle": "^6.2",
"league/commonmark": "^2.4",
"phpdocumentor/reflection-docblock": "^5.3", "phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.16", "phpstan/phpdoc-parser": "^1.16",
"sensio/framework-extra-bundle": "^6.1", "sensio/framework-extra-bundle": "^6.1",
@ -39,6 +40,7 @@
"symfony/yaml": "6.3.*", "symfony/yaml": "6.3.*",
"telegram-bot/api": "^2.3", "telegram-bot/api": "^2.3",
"twig/extra-bundle": "^2.12|^3.0", "twig/extra-bundle": "^2.12|^3.0",
"twig/markdown-extra": "^3.7",
"twig/twig": "^2.12|^3.0" "twig/twig": "^2.12|^3.0"
}, },
"config": { "config": {

482
composer.lock generated
View file

@ -4,8 +4,83 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "79648732c4eb68062e080a5c4e5c25b7", "content-hash": "6088d0629768085da296aa5598445c4f",
"packages": [ "packages": [
{
"name": "dflydev/dot-access-data",
"version": "v3.0.2",
"source": {
"type": "git",
"url": "https://github.com/dflydev/dflydev-dot-access-data.git",
"reference": "f41715465d65213d644d3141a6a93081be5d3549"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/f41715465d65213d644d3141a6a93081be5d3549",
"reference": "f41715465d65213d644d3141a6a93081be5d3549",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.42",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
"scrutinizer/ocular": "1.6.0",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^4.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Dflydev\\DotAccessData\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Dragonfly Development Inc.",
"email": "info@dflydev.com",
"homepage": "http://dflydev.com"
},
{
"name": "Beau Simensen",
"email": "beau@dflydev.com",
"homepage": "http://beausimensen.com"
},
{
"name": "Carlos Frutos",
"email": "carlos@kiwing.it",
"homepage": "https://github.com/cfrutos"
},
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com"
}
],
"description": "Given a deep data structure, access data by dot notation.",
"homepage": "https://github.com/dflydev/dflydev-dot-access-data",
"keywords": [
"access",
"data",
"dot",
"notation"
],
"support": {
"issues": "https://github.com/dflydev/dflydev-dot-access-data/issues",
"source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.2"
},
"time": "2022-10-27T11:44:00+00:00"
},
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "2.0.1", "version": "2.0.1",
@ -1967,6 +2042,194 @@
}, },
"time": "2023-03-25T06:51:40+00:00" "time": "2023-03-25T06:51:40+00:00"
}, },
{
"name": "league/commonmark",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "d44a24690f16b8c1808bf13b1bd54ae4c63ea048"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d44a24690f16b8c1808bf13b1bd54ae4c63ea048",
"reference": "d44a24690f16b8c1808bf13b1bd54ae4c63ea048",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"league/config": "^1.1.1",
"php": "^7.4 || ^8.0",
"psr/event-dispatcher": "^1.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0",
"symfony/polyfill-php80": "^1.16"
},
"require-dev": {
"cebe/markdown": "^1.0",
"commonmark/cmark": "0.30.0",
"commonmark/commonmark.js": "0.30.0",
"composer/package-versions-deprecated": "^1.8",
"embed/embed": "^4.4",
"erusev/parsedown": "^1.0",
"ext-json": "*",
"github/gfm": "0.29.0",
"michelf/php-markdown": "^1.4 || ^2.0",
"nyholm/psr7": "^1.5",
"phpstan/phpstan": "^1.8.2",
"phpunit/phpunit": "^9.5.21",
"scrutinizer/ocular": "^1.8.1",
"symfony/finder": "^5.3 | ^6.0",
"symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0",
"unleashedtech/php-coding-standard": "^3.1.1",
"vimeo/psalm": "^4.24.0 || ^5.0.0"
},
"suggest": {
"symfony/yaml": "v2.3+ required if using the Front Matter extension"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.5-dev"
}
},
"autoload": {
"psr-4": {
"League\\CommonMark\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)",
"homepage": "https://commonmark.thephpleague.com",
"keywords": [
"commonmark",
"flavored",
"gfm",
"github",
"github-flavored",
"markdown",
"md",
"parser"
],
"support": {
"docs": "https://commonmark.thephpleague.com/",
"forum": "https://github.com/thephpleague/commonmark/discussions",
"issues": "https://github.com/thephpleague/commonmark/issues",
"rss": "https://github.com/thephpleague/commonmark/releases.atom",
"source": "https://github.com/thephpleague/commonmark"
},
"funding": [
{
"url": "https://www.colinodell.com/sponsor",
"type": "custom"
},
{
"url": "https://www.paypal.me/colinpodell/10.00",
"type": "custom"
},
{
"url": "https://github.com/colinodell",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/league/commonmark",
"type": "tidelift"
}
],
"time": "2023-03-24T15:16:10+00:00"
},
{
"name": "league/config",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/config.git",
"reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
"reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
"shasum": ""
},
"require": {
"dflydev/dot-access-data": "^3.0.1",
"nette/schema": "^1.2",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.8.2",
"phpunit/phpunit": "^9.5.5",
"scrutinizer/ocular": "^1.8.1",
"unleashedtech/php-coding-standard": "^3.1",
"vimeo/psalm": "^4.7.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.2-dev"
}
},
"autoload": {
"psr-4": {
"League\\Config\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Colin O'Dell",
"email": "colinodell@gmail.com",
"homepage": "https://www.colinodell.com",
"role": "Lead Developer"
}
],
"description": "Define configuration arrays with strict schemas and access values with dot notation",
"homepage": "https://config.thephpleague.com",
"keywords": [
"array",
"config",
"configuration",
"dot",
"dot-access",
"nested",
"schema"
],
"support": {
"docs": "https://config.thephpleague.com/",
"issues": "https://github.com/thephpleague/config/issues",
"rss": "https://github.com/thephpleague/config/releases.atom",
"source": "https://github.com/thephpleague/config"
},
"funding": [
{
"url": "https://www.colinodell.com/sponsor",
"type": "custom"
},
{
"url": "https://www.paypal.me/colinpodell/10.00",
"type": "custom"
},
{
"url": "https://github.com/colinodell",
"type": "github"
}
],
"time": "2022-12-11T20:36:23+00:00"
},
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "3.4.0", "version": "3.4.0",
@ -2068,6 +2331,155 @@
], ],
"time": "2023-06-21T08:46:11+00:00" "time": "2023-06-21T08:46:11+00:00"
}, },
{
"name": "nette/schema",
"version": "v1.2.4",
"source": {
"type": "git",
"url": "https://github.com/nette/schema.git",
"reference": "c9ff517a53903b3d4e29ec547fb20feecb05b8ab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/schema/zipball/c9ff517a53903b3d4e29ec547fb20feecb05b8ab",
"reference": "c9ff517a53903b3d4e29ec547fb20feecb05b8ab",
"shasum": ""
},
"require": {
"nette/utils": "^2.5.7 || ^3.1.5 || ^4.0",
"php": "7.1 - 8.3"
},
"require-dev": {
"nette/tester": "^2.3 || ^2.4",
"phpstan/phpstan-nette": "^1.0",
"tracy/tracy": "^2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0-only",
"GPL-3.0-only"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "📐 Nette Schema: validating data structures against a given Schema.",
"homepage": "https://nette.org",
"keywords": [
"config",
"nette"
],
"support": {
"issues": "https://github.com/nette/schema/issues",
"source": "https://github.com/nette/schema/tree/v1.2.4"
},
"time": "2023-08-05T18:56:25+00:00"
},
{
"name": "nette/utils",
"version": "v4.0.1",
"source": {
"type": "git",
"url": "https://github.com/nette/utils.git",
"reference": "9124157137da01b1f5a5a22d6486cb975f26db7e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/utils/zipball/9124157137da01b1f5a5a22d6486cb975f26db7e",
"reference": "9124157137da01b1f5a5a22d6486cb975f26db7e",
"shasum": ""
},
"require": {
"php": ">=8.0 <8.4"
},
"conflict": {
"nette/finder": "<3",
"nette/schema": "<1.2.2"
},
"require-dev": {
"jetbrains/phpstorm-attributes": "dev-master",
"nette/tester": "^2.5",
"phpstan/phpstan": "^1.0",
"tracy/tracy": "^2.9"
},
"suggest": {
"ext-gd": "to use Image",
"ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()",
"ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()",
"ext-json": "to use Nette\\Utils\\Json",
"ext-mbstring": "to use Strings::lower() etc...",
"ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()",
"ext-xml": "to use Strings::length() etc. when mbstring is not available"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause",
"GPL-2.0-only",
"GPL-3.0-only"
],
"authors": [
{
"name": "David Grudl",
"homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
"homepage": "https://nette.org/contributors"
}
],
"description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
"homepage": "https://nette.org",
"keywords": [
"array",
"core",
"datetime",
"images",
"json",
"nette",
"paginator",
"password",
"slugify",
"string",
"unicode",
"utf-8",
"utility",
"validation"
],
"support": {
"issues": "https://github.com/nette/utils/issues",
"source": "https://github.com/nette/utils/tree/v4.0.1"
},
"time": "2023-07-30T15:42:21+00:00"
},
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
"version": "2.2.0", "version": "2.2.0",
@ -7030,6 +7442,74 @@
], ],
"time": "2023-05-06T11:11:46+00:00" "time": "2023-05-06T11:11:46+00:00"
}, },
{
"name": "twig/markdown-extra",
"version": "v3.7.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/markdown-extra.git",
"reference": "8f1179e279cea6ef14066a4560b859df58acd5d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/8f1179e279cea6ef14066a4560b859df58acd5d8",
"reference": "8f1179e279cea6ef14066a4560b859df58acd5d8",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"twig/twig": "^2.7|^3.0"
},
"require-dev": {
"erusev/parsedown": "^1.7",
"league/commonmark": "^1.0|^2.0",
"league/html-to-markdown": "^4.8|^5.0",
"michelf/php-markdown": "^1.8|^2.0",
"symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Twig\\Extra\\Markdown\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
}
],
"description": "A Twig extension for Markdown",
"homepage": "https://twig.symfony.com",
"keywords": [
"html",
"markdown",
"twig"
],
"support": {
"source": "https://github.com/twigphp/markdown-extra/tree/v3.7.0"
},
"funding": [
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
"type": "tidelift"
}
],
"time": "2023-02-09T06:45:16+00:00"
},
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v3.7.0", "version": "v3.7.0",

View file

@ -1,3 +0,0 @@
{% extends '@SkobkinPointTools/Post/comment_tree.html.twig' %}
{% block comment_children %}{% endblock %}

View file

@ -1,5 +0,0 @@
{% if comments|length > 0 %}
{% for comment in comments %}
{% include '@SkobkinPointTools/Post/comment_list.html.twig' with {'comment': comment} only %}
{% endfor %}
{% endif %}

View file

@ -1,5 +0,0 @@
{% if comments|length > 0 %}
{% for comment in comments %}
{% include '@SkobkinPointTools/Post/comment_tree.html.twig' with {'comment': comment} only %}
{% endfor %}
{% endif %}

View file

@ -1,7 +0,0 @@
{% extends 'SkobkinPointToolsBundle:Post:base_feed.html.twig' %}
{% block header_title %}#{{ post.id }} @ Point Tools{% endblock %}
{% block content %}
{% include 'SkobkinPointToolsBundle:Post:post.html.twig' with {'post': post} %}
{% endblock %}

View file

@ -3,7 +3,6 @@ declare(strict_types=1);
namespace App\Controller; namespace App\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use App\Entity\Blog\Post; use App\Entity\Blog\Post;
use App\Repository\Blog\PostRepository; use App\Repository\Blog\PostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -11,12 +10,9 @@ use Symfony\Component\HttpFoundation\Response;
class PostController extends AbstractController class PostController extends AbstractController
{ {
/**
* @ParamConverter("post", class="SkobkinPointToolsBundle:Blogs\Post")
*/
public function show(Post $post, PostRepository $postRepository): Response public function show(Post $post, PostRepository $postRepository): Response
{ {
if ((!$post->getAuthor()->isPublic()) || $post->getAuthor()->isWhitelistOnly()) { if ($post->getAuthor()->isPrivate()) {
/** /**
* Throwing 404 instead of 403 because of * Throwing 404 instead of 403 because of
* @see \Symfony\Component\Security\Http\Firewall\ExceptionListener::handleAccessDeniedException() * @see \Symfony\Component\Security\Http\Firewall\ExceptionListener::handleAccessDeniedException()
@ -26,7 +22,7 @@ class PostController extends AbstractController
//throw $this->createAccessDeniedException('Author\'s blog is private.'); //throw $this->createAccessDeniedException('Author\'s blog is private.');
} }
return $this->render('SkobkinPointToolsBundle:Post:show.html.twig', [ return $this->render('Web/Post/show.html.twig', [
'post' => $postRepository->getPostWithComments($post->getId()), 'post' => $postRepository->getPostWithComments($post->getId()),
]); ]);
} }

View file

@ -21,10 +21,8 @@ class PublicFeedController extends AbstractController
); );
return $this->render( return $this->render(
'SkobkinPointToolsBundle:Post:feed.html.twig', 'Web/Post/feed.html.twig',
[ [
// @todo Move to translation
'feed_title' => 'Public feed',
'posts' => $postsPagination, 'posts' => $postsPagination,
// Special feed mark (to not show comments and other) // Special feed mark (to not show comments and other)
'is_feed' => true, 'is_feed' => true,

View file

@ -5,13 +5,13 @@ namespace App\Entity\Blog;
use App\Entity\User; use App\Entity\User;
use App\Enum\Blog\PostTypeEnum; use App\Enum\Blog\PostTypeEnum;
use App\Repository\Blog\TagRepository; use App\Repository\Blog\PostRepository;
use Doctrine\Common\Collections\{ArrayCollection, Collection}; use Doctrine\Common\Collections\{ArrayCollection, Collection};
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: TagRepository::class)] #[ORM\Entity(repositoryClass: PostRepository::class)]
#[ORM\HasLifecycleCallbacks] #[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'tags', schema: 'posts')] #[ORM\Table(name: 'posts', schema: 'posts')]
class Post class Post
{ {
#[ORM\Id] #[ORM\Id]

View file

@ -155,6 +155,11 @@ class User
return $this->public; return $this->public;
} }
public function isPrivate(): bool
{
return !$this->public || $this->whitelistOnly;
}
public function isWhitelistOnly(): bool public function isWhitelistOnly(): bool
{ {
return $this->whitelistOnly; return $this->whitelistOnly;

View file

@ -1,4 +1,4 @@
{% extends "::base.html.twig" %} {% extends 'Web/base.html.twig' %}
{% block css %} {% block css %}
{{ parent() }} {{ parent() }}

View file

@ -0,0 +1,3 @@
{% extends 'Web/Post/comment_tree.html.twig' %}
{% block comment_children %}{% endblock %}

View file

@ -39,7 +39,7 @@
{% block comment_children %} {% block comment_children %}
{% if comment.children|length > 0 %} {% if comment.children|length > 0 %}
<div class="children"> <div class="children">
{% include '@SkobkinPointTools/Post/comments_tree.html.twig' with { {% include 'Web/Post/comments_tree.html.twig' with {
'comments': comment.children 'comments': comment.children
} only %} } only %}
</div> </div>

View file

@ -0,0 +1,5 @@
{% if comments|length > 0 %}
{% for comment in comments %}
{% include 'Web/Post/comment_list.html.twig' with {'comment': comment} only %}
{% endfor %}
{% endif %}

View file

@ -0,0 +1,5 @@
{% if comments|length > 0 %}
{% for comment in comments %}
{% include 'Web/Post/comment_tree.html.twig' with {'comment': comment} only %}
{% endfor %}
{% endif %}

View file

@ -1,6 +1,6 @@
{% extends 'SkobkinPointToolsBundle:Post:base_feed.html.twig' %} {% extends 'Web/Post/base_feed.html.twig' %}
{% block header_title %}{{ feed_title|trans }} @ Point Tools{% endblock %} {% block header_title %}{{ 'Public feed' | trans }} @ Point Tools{% endblock %}
{% block content %} {% block content %}
{% if is_feed is defined %} {% if is_feed is defined %}
@ -11,7 +11,7 @@
{% for post in posts %} {% for post in posts %}
<div class="feed-post panel panel-default"> <div class="feed-post panel panel-default">
{% include 'SkobkinPointToolsBundle:Post:post.html.twig' with { {% include 'Web/Post/post.html.twig' with {
'post': post, 'post': post,
'is_feed': is_feed 'is_feed': is_feed
} %} } %}

View file

@ -15,7 +15,9 @@
</div> </div>
<div class="row post-text"> <div class="row post-text">
<div class="col-xs-12"> <div class="col-xs-12">
{{ post.text|markdown('app.point.markdown_parser') }} {# Until Point native Markdown parser is ported, use Twig's parser #}
{# {{ post.text|markdown('app.point.markdown_parser') }}#}
{{ post.text | markdown_to_html }}
</div> </div>
</div> </div>
<div class="row post-files"> <div class="row post-files">
@ -34,12 +36,12 @@
{% if is_feed is not defined and post.comments|length > 0 %} {% if is_feed is not defined and post.comments|length > 0 %}
<div class="row comments"> <div class="row comments">
{# {#
{% include '@SkobkinPointTools/Post/comments_tree.html.twig' with { {% include 'Web/Post/comments_tree.html.twig' with {
'comments': post.firstLevelComments 'comments': post.firstLevelComments
} only %} } only %}
#} #}
{% include 'SkobkinPointToolsBundle:Post:comments_list.html.twig' with { {% include 'Web/Post/comments_list.html.twig' with {
'comments': post.comments 'comments': post.comments
} %} } %}
</div> </div>

View file

@ -0,0 +1,7 @@
{% extends 'Web/Post/base_feed.html.twig' %}
{% block header_title %}#{{ post.id }} @ Point Tools{% endblock %}
{% block content %}
{% include 'Web/Post/post.html.twig' with {'post': post} %}
{% endblock %}