Compare commits
238 commits
Author | SHA1 | Date | |
---|---|---|---|
Simon Vieille | eb376dc36c | ||
Simon Vieille | 8e947b0b77 | ||
Simon Vieille | fd1a45c0e7 | ||
Simon Vieille | bc148f0b6b | ||
Simon Vieille | 4a3619919c | ||
Simon Vieille | 4054f6ccff | ||
Simon Vieille | 01ecac272e | ||
Simon Vieille | 89efd5475f | ||
Simon Vieille | 029d296bd8 | ||
Simon Vieille | 1120c20f05 | ||
Simon Vieille | f4a70bec66 | ||
Simon Vieille | d4ba8dc619 | ||
Simon Vieille | 26e422619b | ||
Simon Vieille | eb3c1a8879 | ||
Simon Vieille | 9963c4b3cf | ||
Simon Vieille | e322973e67 | ||
Simon Vieille | a15cf1559b | ||
Simon Vieille | 006b8cdbe6 | ||
Simon Vieille | 46f13d817d | ||
Simon Vieille | 0d5f248ca9 | ||
Simon Vieille | d1ca98eddd | ||
Simon Vieille | 62fbd936c6 | ||
Simon Vieille | d66fb7da78 | ||
Simon Vieille | 57dd7da162 | ||
Simon Vieille | d7ce3cb12f | ||
Simon Vieille | fea5319dc5 | ||
Simon Vieille | ff0ab092e4 | ||
Simon Vieille | a0211026ba | ||
Simon Vieille | c5dde3b184 | ||
Simon Vieille | b1ea641374 | ||
Simon Vieille | 62de6416c5 | ||
Simon Vieille | 246c249d3e | ||
Simon Vieille | be26d15b22 | ||
Simon Vieille | 3f5bd4f950 | ||
Simon Vieille | a80dc9999c | ||
Simon Vieille | b9566853ef | ||
Simon Vieille | bc7e8ef263 | ||
Simon Vieille | 25efd11ea3 | ||
Simon Vieille | e23f7d3c73 | ||
Simon Vieille | 85f054956c | ||
Simon Vieille | b12f4db16f | ||
Simon Vieille | 6bb29dd5c3 | ||
Simon Vieille | 7824e96bab | ||
Simon Vieille | 56177c14da | ||
Simon Vieille | 4f1c5b8f14 | ||
Simon Vieille | e8c9520378 | ||
Simon Vieille | 283223446a | ||
Simon Vieille | 46e01f504f | ||
Simon Vieille | a80ee03fcd | ||
Simon Vieille | d1649a4959 | ||
Simon Vieille | 38791f1d7a | ||
Simon Vieille | d74cd52711 | ||
Simon Vieille | b451df61e8 | ||
Simon Vieille | 7c124008c0 | ||
Simon Vieille | 9cf95dba64 | ||
Simon Vieille | b680946daf | ||
Simon Vieille | 1995298977 | ||
Simon Vieille | 4acba618cb | ||
Simon Vieille | 92eaaba699 | ||
Simon Vieille | 357856f8ce | ||
Simon Vieille | dfbe282d0e | ||
Simon Vieille | 857fcd9897 | ||
Simon Vieille | 48ca5a96e6 | ||
Simon Vieille | 065bb0db22 | ||
Simon Vieille | bf6777054f | ||
Simon Vieille | 51acd82432 | ||
Simon Vieille | c6cbc405e4 | ||
Simon Vieille | 150f3afd6a | ||
Simon Vieille | 4a0e616897 | ||
Simon Vieille | 4eb13a4022 | ||
Simon Vieille | 8bb6267a77 | ||
Simon Vieille | 8044ff3605 | ||
Simon Vieille | 71d3d40d5f | ||
Simon Vieille | 9324837bd9 | ||
Simon Vieille | b8dfaaed10 | ||
Simon Vieille | 2d49b8ddee | ||
Simon Vieille | 232b92267e | ||
Simon Vieille | ca23a22807 | ||
Simon Vieille | 78965bbf10 | ||
Simon Vieille | 7fe1acd47d | ||
Simon Vieille | 26cbaa8469 | ||
Simon Vieille | 7897bafcc2 | ||
Simon Vieille | 63a8a60e2d | ||
Simon Vieille | d01e9d618b | ||
Simon Vieille | 96347a1730 | ||
Simon Vieille | aeb0e6c109 | ||
Simon Vieille | 64258a2d8c | ||
Simon Vieille | 70329ceeda | ||
Simon Vieille | 1adb1ebe2b | ||
Simon Vieille | f57cc8e4d6 | ||
Simon Vieille | b21967028e | ||
Simon Vieille | 5b22851674 | ||
Simon Vieille | 4082bb171a | ||
Simon Vieille | dc19617fb1 | ||
Simon Vieille | dbd2036fb0 | ||
Simon Vieille | 8e2566abc8 | ||
Simon Vieille | 66e1a9c87f | ||
Simon Vieille | 6709c0a303 | ||
Simon Vieille | 614ae40901 | ||
Simon Vieille | 430bff9433 | ||
Simon Vieille | 6441da8a27 | ||
Simon Vieille | 801e3317e7 | ||
Simon Vieille | f7604d2a45 | ||
Simon Vieille | 8a632a1b14 | ||
Simon Vieille | 4701090134 | ||
Simon Vieille | c40c7e3362 | ||
Simon Vieille | 8edbf0cc08 | ||
Simon Vieille | 175321bc2d | ||
Simon Vieille | 5d6531d197 | ||
Simon Vieille | 90603f62e0 | ||
Simon Vieille | 053f4aa5b8 | ||
Simon Vieille | 79754d45c1 | ||
Simon Vieille | c98ea50f30 | ||
Simon Vieille | 0f1bc761b2 | ||
Simon Vieille | 50dbb07314 | ||
Simon Vieille | 72e783f865 | ||
Simon Vieille | ee28c9abb7 | ||
2bd6836a7f | |||
6f961ba79b | |||
e095fc4197 | |||
6736f94eea | |||
93a1e7811d | |||
a0027c0b69 | |||
498c71081d | |||
8713b401f9 | |||
1463f43298 | |||
b89e036c49 | |||
1d0b657c83 | |||
0cadf28738 | |||
ede8d4fdcb | |||
5c3f2ab1e7 | |||
c1eb277a6a | |||
d3f27d97ad | |||
5e392d469a | |||
67f79083ef | |||
b9b07c1409 | |||
521ed5ce64 | |||
dda43ef3cc | |||
c65cc26be8 | |||
2f884df602 | |||
8979fc5beb | |||
bd663838f6 | |||
177b23365b | |||
645ae700d4 | |||
7614c24012 | |||
1f2edf183b | |||
28a4f63640 | |||
7fceefa6d3 | |||
a08c62229d | |||
f97f1dfedf | |||
45b3f6bb80 | |||
21ee41ff29 | |||
8d5de79192 | |||
212afe2775 | |||
16dd0d5744 | |||
9957523c59 | |||
688f66e94e | |||
c9b997e75d | |||
374db9117f | |||
4048152a8e | |||
4385e7a525 | |||
5d3999f766 | |||
03c0d6cfd2 | |||
290a4750bc | |||
7d647d3bb4 | |||
d637c44e5c | |||
19d26e6bd0 | |||
109584d933 | |||
c3209c68dd | |||
4a5b67dd93 | |||
4573a8d31e | |||
405909a4e7 | |||
2b3e2027c9 | |||
76b25f3bca | |||
ca25210d1c | |||
0ab960ed0a | |||
8e0a7f178b | |||
200dd0b8d6 | |||
bd4338bb2d | |||
64b524b04e | |||
6a5c5d899f | |||
b38fe0fe00 | |||
d21ab30ebe | |||
a96a6377d5 | |||
946a421900 | |||
f7eb5b0b49 | |||
0dadc670d9 | |||
4a0b13e6e3 | |||
1936b366df | |||
4541bbfb8a | |||
f3674ad4e0 | |||
ddf1fecc90 | |||
0c61cb9355 | |||
fc1a1c617e | |||
bea2d1cc9f | |||
4bf6b048c3 | |||
81194a1d67 | |||
10221591c2 | |||
231742eb0d | |||
f1d956ee5c | |||
5de35c3408 | |||
f144760085 | |||
e2c9ecb941 | |||
f9a20716a0 | |||
b107f077de | |||
2729b38fd8 | |||
baeecc0f7f | |||
8667188675 | |||
895d5065ca | |||
c688cc0552 | |||
c0340ec5a9 | |||
650ea3ede0 | |||
497ee2f027 | |||
8b13d37e71 | |||
3219ba47aa | |||
7ca8a4aa04 | |||
7ba417a03e | |||
27cbfd1110 | |||
1069a4ad46 | |||
a134a41926 | |||
b915b8b3ed | |||
42ab4d85f0 | |||
902ac81e4b | |||
e74469a687 | |||
219526e3a2 | |||
1cea077598 | |||
de6ca18c0a | |||
3127018a73 | |||
9e0eda4338 | |||
03afb6fb4b | |||
e402c49835 | |||
0a7550940d | |||
5626a2522a | |||
8ebb54c9a9 | |||
98c2d70367 | |||
e623e9fb46 | |||
6b222dd4f7 | |||
bc1f8e7cf9 |
120
CHANGELOG.md
120
CHANGELOG.md
|
@ -1,5 +1,125 @@
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [v1.25.1] - 2024-05-13
|
||||||
|
### Added
|
||||||
|
* add drag&drop in the block builder
|
||||||
|
|
||||||
|
## [v1.25.0] - 2024-05-12
|
||||||
|
### Added
|
||||||
|
* add block builder widget
|
||||||
|
* allow to use `window.tinymceModes` to add or override tinymce modes
|
||||||
|
* add border color on tinymce editor
|
||||||
|
### Fixed
|
||||||
|
* fix default crud sort
|
||||||
|
* fix hidden save button in file manager
|
||||||
|
* fix template of CrudController (maker)
|
||||||
|
* fix undefined `window.tinymce.murph`
|
||||||
|
|
||||||
|
## [v1.24.1] - 2024-02-01
|
||||||
|
### Fixed
|
||||||
|
* update Murph version constant
|
||||||
|
|
||||||
|
## [v1.24.0] - 2024-01-27
|
||||||
|
### Added
|
||||||
|
* add CSS class `no-wrap`
|
||||||
|
* copy the pager of the CRUD at the bottom of the list
|
||||||
|
### Fixed
|
||||||
|
* fix an issue with the file manager when editing an item opened in a modal
|
||||||
|
* fix type casting in slugifier
|
||||||
|
|
||||||
|
## [v1.23.0] - 2023-11-01
|
||||||
|
### Added
|
||||||
|
* allow to define templates show before and after a murph collection item
|
||||||
|
* add global batch actions
|
||||||
|
* add constraint `Length` in forms
|
||||||
|
* add sass classes to mange with of elements
|
||||||
|
* set searchFields option on jschoice manager (search on labels)
|
||||||
|
### Changed
|
||||||
|
* refactor services using constructor property promotions
|
||||||
|
* remove twig in the mail notifier service
|
||||||
|
* change pills colors
|
||||||
|
* change border colors of inputs when focused
|
||||||
|
* change colors on js-choices element
|
||||||
|
### Fixed
|
||||||
|
* fix regression on crud sorting
|
||||||
|
* fix test in RepositoryQuery::addForcedFilterHandler
|
||||||
|
* remove parameter $option on CrudConfiguration::setForm and fix CrudController make template
|
||||||
|
* fix the aspect of the actions's column in the crud
|
||||||
|
|
||||||
|
## [v1.22.0] - 2023-09-28
|
||||||
|
### Added
|
||||||
|
* add new options in BooleanField: `toggle|checkbox_class_when_true` and `toggle|checkbox_class_when_false`
|
||||||
|
* add `count` method in repository query
|
||||||
|
* add `addForcedFilterHandler` method in repository query
|
||||||
|
* add `inline_form_validation` option to validate inline forms with custom algo
|
||||||
|
* add crud sorting parameters in the session
|
||||||
|
* add flush option in the entity manager on create, update, remove, and persist methods
|
||||||
|
|
||||||
|
## [1.21.1] - 2023-08-17
|
||||||
|
### Added
|
||||||
|
* add form error handle in inline edit action and refill the form using the previous request content
|
||||||
|
* add form error handle in ssettings actions and refill the form using the previous request content
|
||||||
|
### Fixed
|
||||||
|
* fix tinymce reload when modal is closed and reopened
|
||||||
|
* fix modal hiding when a file is successfuly uploaded in the file manager
|
||||||
|
|
||||||
|
## [1.21.0] - 2023-08-11
|
||||||
|
### Added
|
||||||
|
* allow to use array syntax in string builder filter
|
||||||
|
* add color property in Navigation
|
||||||
|
* add badge with navigation color in admin views
|
||||||
|
* add `default_value` option in crud fields
|
||||||
|
* add `display` option in BooleanField
|
||||||
|
* add associated nodes in page form
|
||||||
|
### Fixed
|
||||||
|
* fix routes in the global settings controller
|
||||||
|
|
||||||
|
## [1.20.0] - 2023-07-27
|
||||||
|
### Added
|
||||||
|
* enable double click on cruds
|
||||||
|
* add block class name for the choice type in the page maker
|
||||||
|
* update file details view on the file manager
|
||||||
|
* add form options in the crud filter action
|
||||||
|
* add trans filter in inline form modal title
|
||||||
|
* add setter to define all fields in a defined context
|
||||||
|
* add filename generator setter in FileUploadHandler
|
||||||
|
* add variable for the sidebar size
|
||||||
|
* add twig block to override defaults actions in crud index template
|
||||||
|
* add option to remove iterable values and/or specifics keys in the twig toArray function
|
||||||
|
* add boolean field for CRUD
|
||||||
|
* add context variable in each controllers to simplify overrides
|
||||||
|
* core.site.name and core.site.logo are not longer required
|
||||||
|
* add default templates when a crud is generated
|
||||||
|
* add boolean 'is_disabled' in the menu item template options
|
||||||
|
### Fixed
|
||||||
|
* fix filemanager date ordering
|
||||||
|
* fix maker CrudController template: remove bad pasted code
|
||||||
|
* fix redirect listener: use boolean instead of integer
|
||||||
|
* fix responsive of account edit template
|
||||||
|
* fix collection widget: allow_add/allow_delete and prototype
|
||||||
|
### Changed
|
||||||
|
* user admin routes are defined in core, custom controller is not required
|
||||||
|
|
||||||
|
## [1.19.0] - 2023-04-15
|
||||||
|
### Added
|
||||||
|
* feat(page): forms for metas, opengraph and extra informations can be removed
|
||||||
|
* feat(navigation): user interface is improved
|
||||||
|
* feat(file): webp is allowed and shown in form widgets and in file manager details
|
||||||
|
* feat(file): the file manager now show the size and the modification date of a file
|
||||||
|
* feat(crud): add option `action` in field to add a link to the view page or to the edition page
|
||||||
|
* feat(crud): add option `inline_form` in field to configure to edit the data
|
||||||
|
* feat(crud): add `setDoubleClick` in the crud configuration
|
||||||
|
|
||||||
|
## [1.18.0] - 2023-01-13
|
||||||
|
### Added
|
||||||
|
* feat(dep): add symfony/runtime
|
||||||
|
* feat(dep): add symfony/flex
|
||||||
|
### Fixed
|
||||||
|
* fix(crud): allow POST in delete actions
|
||||||
|
* fix(crud): remove default page value in abstract crud controller
|
||||||
|
* fix(admin): test site_logo before using it
|
||||||
|
* fix(ui): update z-index of choices__list--dropdown
|
||||||
|
|
||||||
## [1.17.1] - 2022-12-03
|
## [1.17.1] - 2022-12-03
|
||||||
### Fixed
|
### Fixed
|
||||||
* add mising attribute on timestampable (doctrine)
|
* add mising attribute on timestampable (doctrine)
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
"symfony/event-dispatcher": "5.4.*",
|
"symfony/event-dispatcher": "5.4.*",
|
||||||
"symfony/expression-language": "5.4.*",
|
"symfony/expression-language": "5.4.*",
|
||||||
"symfony/finder": "5.4.*",
|
"symfony/finder": "5.4.*",
|
||||||
"symfony/flex": "^1.3.1",
|
"symfony/flex": "^2.2",
|
||||||
"symfony/form": "5.4.*",
|
"symfony/form": "5.4.*",
|
||||||
"symfony/framework-bundle": "5.4.*",
|
"symfony/framework-bundle": "5.4.*",
|
||||||
"symfony/http-client": "5.4.*",
|
"symfony/http-client": "5.4.*",
|
||||||
|
@ -60,7 +60,8 @@
|
||||||
"symfony/webpack-encore-bundle": "^1.11",
|
"symfony/webpack-encore-bundle": "^1.11",
|
||||||
"symfony/yaml": "5.4.*",
|
"symfony/yaml": "5.4.*",
|
||||||
"twig/extra-bundle": "^2.12|^3.3",
|
"twig/extra-bundle": "^2.12|^3.3",
|
||||||
"twig/twig": "^2.12|^3.3"
|
"twig/twig": "^2.12|^3.3",
|
||||||
|
"symfony/runtime": "^5.4"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -10,14 +10,12 @@ namespace App\Core\Ab;
|
||||||
class AbTest implements AbTestInterface
|
class AbTest implements AbTestInterface
|
||||||
{
|
{
|
||||||
protected $results;
|
protected $results;
|
||||||
protected string $name;
|
|
||||||
protected array $variations = [];
|
protected array $variations = [];
|
||||||
protected array $probabilities = [];
|
protected array $probabilities = [];
|
||||||
protected int $duration = 3600 * 24;
|
protected int $duration = 3600 * 24;
|
||||||
|
|
||||||
public function __construct(string $name)
|
public function __construct(protected string $name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
|
|
|
@ -13,18 +13,16 @@ use App\Core\Repository\Analytic\ViewRepositoryQuery;
|
||||||
*/
|
*/
|
||||||
class DateRangeAnalytic
|
class DateRangeAnalytic
|
||||||
{
|
{
|
||||||
protected ViewRepositoryQuery $viewQuery;
|
|
||||||
protected RefererRepositoryQuery $refererQuery;
|
|
||||||
protected ?Node $node;
|
protected ?Node $node;
|
||||||
protected ?\DateTime $from;
|
protected ?\DateTime $from;
|
||||||
protected ?\DateTime $to;
|
protected ?\DateTime $to;
|
||||||
protected bool $reload = true;
|
protected bool $reload = true;
|
||||||
protected array $cache = [];
|
protected array $cache = [];
|
||||||
|
|
||||||
public function __construct(ViewRepositoryQuery $viewQuery, RefererRepositoryQuery $refererQuery)
|
public function __construct(
|
||||||
{
|
protected ViewRepositoryQuery $viewQuery,
|
||||||
$this->viewQuery = $viewQuery;
|
protected RefererRepositoryQuery $refererQuery
|
||||||
$this->refererQuery = $refererQuery;
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getViews(): array
|
public function getViews(): array
|
||||||
|
@ -83,7 +81,7 @@ class DateRangeAnalytic
|
||||||
$datas[$index]['mobileViews'] += $entity->getMobileViews();
|
$datas[$index]['mobileViews'] += $entity->getMobileViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
uasort($datas, function($a, $b) {
|
uasort($datas, function ($a, $b) {
|
||||||
if ($a['views'] > $b['views']) {
|
if ($a['views'] > $b['views']) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +128,7 @@ class DateRangeAnalytic
|
||||||
$datas[$index]['uris'][$path] += $entity->getViews();
|
$datas[$index]['uris'][$path] += $entity->getViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
uasort($datas, function($a, $b) {
|
uasort($datas, function ($a, $b) {
|
||||||
if ($a['views'] > $b['views']) {
|
if ($a['views'] > $b['views']) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,10 @@ namespace App\Core\Annotation;
|
||||||
#[\Attribute]
|
#[\Attribute]
|
||||||
class UrlGenerator
|
class UrlGenerator
|
||||||
{
|
{
|
||||||
public string $service;
|
public function __construct(
|
||||||
|
public string $service,
|
||||||
public string $method;
|
public string $method,
|
||||||
|
public array $options = []
|
||||||
public array $options = [];
|
) {
|
||||||
|
|
||||||
public function __construct(string $service, string $method, array $options = [])
|
|
||||||
{
|
|
||||||
$this->service = $service;
|
|
||||||
$this->method = $method;
|
|
||||||
$this->options = $options;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,20 +23,12 @@ class LoginFormAuthenticator extends AbstractFormLoginAuthenticator
|
||||||
{
|
{
|
||||||
use TargetPathTrait;
|
use TargetPathTrait;
|
||||||
|
|
||||||
private EntityManagerInterface $entityManager;
|
public function __construct(
|
||||||
|
private EntityManagerInterface $entityManager,
|
||||||
private UrlGeneratorInterface $urlGenerator;
|
private UrlGeneratorInterface $urlGenerator,
|
||||||
|
private CsrfTokenManagerInterface $csrfTokenManager,
|
||||||
private CsrfTokenManagerInterface $csrfTokenManager;
|
private UserPasswordEncoderInterface $passwordEncoder
|
||||||
|
) {
|
||||||
private UserPasswordEncoderInterface $passwordEncoder;
|
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager, UserPasswordEncoderInterface $passwordEncoder)
|
|
||||||
{
|
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->urlGenerator = $urlGenerator;
|
|
||||||
$this->csrfTokenManager = $csrfTokenManager;
|
|
||||||
$this->passwordEncoder = $passwordEncoder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(Request $request)
|
public function supports(Request $request)
|
||||||
|
|
47
src/core/BuilderBlock/Block/Bootstrap/AlertBlock.php
Normal file
47
src/core/BuilderBlock/Block/Bootstrap/AlertBlock.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Bootstrap;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
#[AutoconfigureTag('builder_block.widget')]
|
||||||
|
class AlertBlock extends BootstrapBlock
|
||||||
|
{
|
||||||
|
public function __construct(protected TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
parent::configure();
|
||||||
|
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
foreach ([
|
||||||
|
'Primary' => 'primary',
|
||||||
|
'Secondary' => 'secondary',
|
||||||
|
'Info' => 'info',
|
||||||
|
'Success' => 'success',
|
||||||
|
'Danger' => 'danger',
|
||||||
|
'Warning' => 'warning',
|
||||||
|
'Light' => 'light',
|
||||||
|
'Dark' => 'dark',
|
||||||
|
] as $k => $v) {
|
||||||
|
$options[] = [
|
||||||
|
'text' => $this->translator->trans($k),
|
||||||
|
'value' => $v,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this
|
||||||
|
->setName('bsAlert')
|
||||||
|
->setLabel('Alert')
|
||||||
|
->setOrder(4)
|
||||||
|
->setIsContainer(true)
|
||||||
|
->setIcon('<i class="fas fa-exclamation-circle"></i>')
|
||||||
|
->setTemplate('@Core/builder_block/bootstrap/alert.html.twig')
|
||||||
|
->addSetting(name: 'level', label: 'Level', type: 'select', extraOptions: ['options' => $options])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
14
src/core/BuilderBlock/Block/Bootstrap/BootstrapBlock.php
Normal file
14
src/core/BuilderBlock/Block/Bootstrap/BootstrapBlock.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Bootstrap;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlock;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
|
||||||
|
class BootstrapBlock extends BuilderBlock
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
$this->setCategory('Bootstrap');
|
||||||
|
}
|
||||||
|
}
|
31
src/core/BuilderBlock/Block/Bootstrap/ColumnBlock.php
Normal file
31
src/core/BuilderBlock/Block/Bootstrap/ColumnBlock.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Bootstrap;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlock;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
|
||||||
|
#[AutoconfigureTag('builder_block.widget')]
|
||||||
|
class ColumnBlock extends BootstrapBlock
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
parent::configure();
|
||||||
|
|
||||||
|
$this
|
||||||
|
->setName('bsColumn')
|
||||||
|
->setLabel('Column')
|
||||||
|
->setIsContainer(true)
|
||||||
|
->setOrder(3)
|
||||||
|
->setClass('col-12 col-lg-3 pr-md-1')
|
||||||
|
->setTemplate('@Core/builder_block/bootstrap/column.html.twig')
|
||||||
|
->setIcon('<i class="fas fa-columns"></i>')
|
||||||
|
->addSetting(name: 'size', label: 'Extra small', type: 'number', attributes: ['min' => 0, 'max' => 12])
|
||||||
|
->addSetting(name: 'sizeSm', label: 'Small', type: 'number', attributes: ['min' => 0, 'max' => 12])
|
||||||
|
->addSetting(name: 'sizeMd', label: 'Medium', type: 'number', attributes: ['min' => 0, 'max' => 12])
|
||||||
|
->addSetting(name: 'sizeLg', label: 'Large', type: 'number', attributes: ['min' => 0, 'max' => 12])
|
||||||
|
->addSetting(name: 'sizeXl', label: 'Extra large', type: 'number', attributes: ['min' => 0, 'max' => 12])
|
||||||
|
->addSetting(name: 'customClass', label: 'Custom class', type: 'text')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
26
src/core/BuilderBlock/Block/Bootstrap/ContainerBlock.php
Normal file
26
src/core/BuilderBlock/Block/Bootstrap/ContainerBlock.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Bootstrap;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlock;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
|
||||||
|
#[AutoconfigureTag('builder_block.widget')]
|
||||||
|
class ContainerBlock extends BootstrapBlock
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
parent::configure();
|
||||||
|
|
||||||
|
$this
|
||||||
|
->setName('bsContainer')
|
||||||
|
->setLabel('Container')
|
||||||
|
->setIsContainer(true)
|
||||||
|
->setOrder(1)
|
||||||
|
->setTemplate('@Core/builder_block/bootstrap/container.html.twig')
|
||||||
|
->setIcon('<i class="fas fa-th"></i>')
|
||||||
|
->addSetting(name: 'isFluid', label: 'Fluid', type: 'checkbox')
|
||||||
|
->addSetting(name: 'customClass', label: 'Custom class', type: 'text')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
26
src/core/BuilderBlock/Block/Bootstrap/RowBlock.php
Normal file
26
src/core/BuilderBlock/Block/Bootstrap/RowBlock.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Bootstrap;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlock;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
|
||||||
|
#[AutoconfigureTag('builder_block.widget')]
|
||||||
|
class RowBlock extends BootstrapBlock
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
parent::configure();
|
||||||
|
|
||||||
|
$this
|
||||||
|
->setName('bsRow')
|
||||||
|
->setLabel('Row')
|
||||||
|
->setOrder(2)
|
||||||
|
->setIsContainer(true)
|
||||||
|
->setIcon('<i class="fas fa-align-justify"></i>')
|
||||||
|
->setTemplate('@Core/builder_block/bootstrap/row.html.twig')
|
||||||
|
->addWidget('bsColumn')
|
||||||
|
->addSetting(name: 'customClass', label: 'Custom class', type: 'text')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
14
src/core/BuilderBlock/Block/Editor/EditorBlock.php
Normal file
14
src/core/BuilderBlock/Block/Editor/EditorBlock.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Editor;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlock;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
|
||||||
|
class EditorBlock extends BuilderBlock
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
$this->setCategory('Editors');
|
||||||
|
}
|
||||||
|
}
|
27
src/core/BuilderBlock/Block/Editor/TextareaBlock.php
Normal file
27
src/core/BuilderBlock/Block/Editor/TextareaBlock.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Editor;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlock;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
|
||||||
|
#[AutoconfigureTag('builder_block.widget')]
|
||||||
|
class TextareaBlock extends EditorBlock
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
parent::configure();
|
||||||
|
|
||||||
|
$this
|
||||||
|
->setName('textarea')
|
||||||
|
->setLabel('Text')
|
||||||
|
->setIsContainer(false)
|
||||||
|
->setIcon('<i class="fas fa-pencil-alt"></i>')
|
||||||
|
->setTemplate('@Core/builder_block/editor/textarea.html.twig')
|
||||||
|
->addSetting(name: 'nl2br', label: 'Insert line breaks', type: 'checkbox', default: true)
|
||||||
|
->addSetting(name: 'allowHtml', label: 'Allow HTML', type: 'checkbox', default: false)
|
||||||
|
->addSetting(name: 'value', type: 'textarea')
|
||||||
|
->setPreview('value')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
25
src/core/BuilderBlock/Block/Editor/TinymceBlock.php
Normal file
25
src/core/BuilderBlock/Block/Editor/TinymceBlock.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock\Block\Editor;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlock;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||||
|
|
||||||
|
#[AutoconfigureTag('builder_block.widget')]
|
||||||
|
class TinymceBlock extends EditorBlock
|
||||||
|
{
|
||||||
|
public function configure()
|
||||||
|
{
|
||||||
|
parent::configure();
|
||||||
|
|
||||||
|
$this
|
||||||
|
->setName('tinymce')
|
||||||
|
->setLabel('TinyMCE')
|
||||||
|
->setIsContainer(false)
|
||||||
|
->setIcon('<i class="fas fa-pencil-alt"></i>')
|
||||||
|
->setTemplate('@Core/builder_block/editor/tinymce.html.twig')
|
||||||
|
->addSetting(name: 'value', type: 'textarea', attributes: ['data-tinymce' => ''])
|
||||||
|
->setPreview('value')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
209
src/core/BuilderBlock/BuilderBlock.php
Normal file
209
src/core/BuilderBlock/BuilderBlock.php
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock;
|
||||||
|
|
||||||
|
abstract class BuilderBlock
|
||||||
|
{
|
||||||
|
protected string $name;
|
||||||
|
protected string $label;
|
||||||
|
protected ?string $class = 'col-12';
|
||||||
|
protected ?string $category = null;
|
||||||
|
protected array $settings = [];
|
||||||
|
protected array $widgets = [];
|
||||||
|
protected array $vars = [];
|
||||||
|
protected string $template = '';
|
||||||
|
protected ?string $preview = null;
|
||||||
|
protected bool $isContainer = false;
|
||||||
|
protected ?string $icon = null;
|
||||||
|
protected int $order = 1;
|
||||||
|
|
||||||
|
abstract public function configure();
|
||||||
|
|
||||||
|
public function setLabel(string $label): self
|
||||||
|
{
|
||||||
|
$this->label = $label;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabel(): string
|
||||||
|
{
|
||||||
|
return $this->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCategory(?string $category): self
|
||||||
|
{
|
||||||
|
$this->category = $category;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCategory(): ?string
|
||||||
|
{
|
||||||
|
return $this->category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIsContainer(bool $isContainer): self
|
||||||
|
{
|
||||||
|
$this->isContainer = $isContainer;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsContainer(): bool
|
||||||
|
{
|
||||||
|
return $this->isContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setWidgets(array $widgets): self
|
||||||
|
{
|
||||||
|
$this->widgets = $widgets;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addWidget(string $widget): self
|
||||||
|
{
|
||||||
|
if (!in_array($widget, $this->widgets)) {
|
||||||
|
$this->widgets[] = $widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWidgets(): array
|
||||||
|
{
|
||||||
|
return $this->widgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSettings(array $settings): self
|
||||||
|
{
|
||||||
|
$this->settings = $settings;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addSetting(
|
||||||
|
string $name,
|
||||||
|
string $type = 'input',
|
||||||
|
?string $label = null,
|
||||||
|
array $attributes = [],
|
||||||
|
array $extraOptions = [],
|
||||||
|
$default = null
|
||||||
|
) {
|
||||||
|
$this->settings[$name] = [
|
||||||
|
'label' => $label,
|
||||||
|
'type' => $type,
|
||||||
|
'attr' => $attributes,
|
||||||
|
'default' => $default,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($extraOptions as $key => $value) {
|
||||||
|
if (!in_array($key, array_keys($this->settings[$name]))) {
|
||||||
|
$this->settings[$name][$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSettings(): array
|
||||||
|
{
|
||||||
|
return $this->settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTemplate(string $template): self
|
||||||
|
{
|
||||||
|
$this->template = $template;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplate(): string
|
||||||
|
{
|
||||||
|
return $this->template;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setClass(?string $class): self
|
||||||
|
{
|
||||||
|
$this->class = $class;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getClass(): ?string
|
||||||
|
{
|
||||||
|
return $this->class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIcon(?string $icon): self
|
||||||
|
{
|
||||||
|
$this->icon = $icon;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIcon(): ?string
|
||||||
|
{
|
||||||
|
return $this->icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrder(int $order): self
|
||||||
|
{
|
||||||
|
$this->order = $order;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrder(): int
|
||||||
|
{
|
||||||
|
return $this->order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPreview(?string $preview): self
|
||||||
|
{
|
||||||
|
$this->preview = $preview;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPreview(): ?string
|
||||||
|
{
|
||||||
|
return $this->preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildVars(array $data, array $context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVars(): array
|
||||||
|
{
|
||||||
|
return $this->vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'label' => $this->getLabel(),
|
||||||
|
'category' => $this->getCategory(),
|
||||||
|
'isContainer' => $this->getIsContainer(),
|
||||||
|
'widgets' => $this->getWidgets(),
|
||||||
|
'settings' => $this->getSettings(),
|
||||||
|
'class' => $this->getClass(),
|
||||||
|
'icon' => $this->getIcon(),
|
||||||
|
'preview' => $this->getPreview(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
41
src/core/BuilderBlock/BuilderBlockContainer.php
Normal file
41
src/core/BuilderBlock/BuilderBlockContainer.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\BuilderBlock;
|
||||||
|
|
||||||
|
class BuilderBlockContainer
|
||||||
|
{
|
||||||
|
protected array $widgets = [];
|
||||||
|
|
||||||
|
public function addWidget(BuilderBlock $widget): self
|
||||||
|
{
|
||||||
|
$widget->configure();
|
||||||
|
|
||||||
|
$this->widgets[$widget->getName()] = $widget;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeWidget(string $name)
|
||||||
|
{
|
||||||
|
unset($this->widgets[$name]);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWidgets(): array
|
||||||
|
{
|
||||||
|
usort($this->widgets, fn(BuilderBlock $a, BuilderBlock $b) => $a->getOrder() <=> $b->getOrder());
|
||||||
|
|
||||||
|
return $this->widgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasWidget(string $name)
|
||||||
|
{
|
||||||
|
return isset($this->widgets[$name]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWidget(string $name): BuilderBlock
|
||||||
|
{
|
||||||
|
return $this->widgets[$name];
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,8 +12,8 @@
|
||||||
namespace App\Core\Bundle;
|
namespace App\Core\Bundle;
|
||||||
|
|
||||||
use App\Core\DependencyInjection\CoreExtension;
|
use App\Core\DependencyInjection\CoreExtension;
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|
||||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
|
|
||||||
class CoreBundle extends Bundle
|
class CoreBundle extends Bundle
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,13 +5,13 @@ namespace App\Core\Cache;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
use Symfony\Component\Finder\Finder;
|
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|
||||||
use Symfony\Component\HttpClient\Exception\ClientException;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Finder\Finder;
|
||||||
|
use Symfony\Component\HttpClient\Exception\ClientException;
|
||||||
use Symfony\Component\HttpClient\Exception\TransportException;
|
use Symfony\Component\HttpClient\Exception\TransportException;
|
||||||
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class SymfonyCacheManager.
|
* class SymfonyCacheManager.
|
||||||
|
@ -20,15 +20,11 @@ use Symfony\Component\HttpClient\Exception\TransportException;
|
||||||
*/
|
*/
|
||||||
class SymfonyCacheManager
|
class SymfonyCacheManager
|
||||||
{
|
{
|
||||||
protected KernelInterface $kernel;
|
public function __construct(
|
||||||
protected HttpClientInterface $httpClient;
|
protected KernelInterface $kernel,
|
||||||
protected UrlGeneratorInterface $urlGenerator;
|
protected HttpClientInterface $httpClient,
|
||||||
|
protected UrlGeneratorInterface $urlGenerator
|
||||||
public function __construct(KernelInterface $kernel, HttpClientInterface $httpClient, UrlGeneratorInterface $urlGenerator)
|
) {
|
||||||
{
|
|
||||||
$this->kernel = $kernel;
|
|
||||||
$this->httpClient = $httpClient;
|
|
||||||
$this->urlGenerator = $urlGenerator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cleanRouting()
|
public function cleanRouting()
|
||||||
|
|
|
@ -18,19 +18,12 @@ class UserCreateCommand extends Command
|
||||||
{
|
{
|
||||||
protected static $defaultName = 'murph:user:create';
|
protected static $defaultName = 'murph:user:create';
|
||||||
protected static $defaultDescription = 'Creates a user';
|
protected static $defaultDescription = 'Creates a user';
|
||||||
protected UserFactory $userFactory;
|
|
||||||
protected EntityManager $entityManager;
|
|
||||||
protected TokenGeneratorInterface $tokenGenerator;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
UserFactory $userFactory,
|
protected UserFactory $userFactory,
|
||||||
EntityManager $entityManager,
|
protected EntityManager $entityManager,
|
||||||
TokenGeneratorInterface $tokenGenerator
|
protected TokenGeneratorInterface $tokenGenerator
|
||||||
) {
|
) {
|
||||||
$this->userFactory = $userFactory;
|
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->tokenGenerator = $tokenGenerator;
|
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ abstract class CrudController extends AdminController
|
||||||
|
|
||||||
abstract protected function getConfiguration(): CrudConfiguration;
|
abstract protected function getConfiguration(): CrudConfiguration;
|
||||||
|
|
||||||
protected function doIndex(int $page = 1, RepositoryQuery $query, Request $request, Session $session): Response
|
protected function doIndex(int $page, RepositoryQuery $query, Request $request, Session $session, string $context = 'index'): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
|
|
||||||
|
@ -35,13 +35,14 @@ abstract class CrudController extends AdminController
|
||||||
|
|
||||||
$pager = $query
|
$pager = $query
|
||||||
->usefilters($this->filters)
|
->usefilters($this->filters)
|
||||||
->paginate($page, $configuration->getmaxperpage('index'))
|
->paginate($page, $configuration->getMaxPerPage($context))
|
||||||
;
|
;
|
||||||
|
|
||||||
return $this->render($this->getConfiguration()->getView('index'), [
|
return $this->render($this->getConfiguration()->getView($context), [
|
||||||
'configuration' => $configuration,
|
'configuration' => $configuration,
|
||||||
'pager' => $pager,
|
'pager' => $pager,
|
||||||
'sort' => $this->sort,
|
'sort' => $this->sort,
|
||||||
|
'context' => $context,
|
||||||
'filters' => [
|
'filters' => [
|
||||||
'show' => null !== $configuration->getForm('filter'),
|
'show' => null !== $configuration->getForm('filter'),
|
||||||
'isEmpty' => empty($this->filters),
|
'isEmpty' => empty($this->filters),
|
||||||
|
@ -49,13 +50,13 @@ abstract class CrudController extends AdminController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doNew(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeCreate = null): Response
|
protected function doNew(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeCreate = null, string $context = 'new'): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
|
|
||||||
$this->prepareEntity($entity);
|
$this->prepareEntity($entity);
|
||||||
|
|
||||||
$form = $this->createForm($configuration->getForm('new'), $entity, $configuration->getFormOptions('new'));
|
$form = $this->createForm($configuration->getForm('new'), $entity, $configuration->getFormOptions($context));
|
||||||
|
|
||||||
if ($request->isMethod('POST')) {
|
if ($request->isMethod('POST')) {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
@ -76,30 +77,32 @@ abstract class CrudController extends AdminController
|
||||||
$this->addFlash('warning', 'The form is not valid.');
|
$this->addFlash('warning', 'The form is not valid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($configuration->getView('new'), [
|
return $this->render($configuration->getView($context), [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'configuration' => $configuration,
|
'configuration' => $configuration,
|
||||||
|
'context' => $context,
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doShow(EntityInterface $entity): Response
|
protected function doShow(EntityInterface $entity, string $context = 'show'): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
|
|
||||||
return $this->render($configuration->getView('show'), [
|
return $this->render($configuration->getView($context), [
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
|
'context' => $context,
|
||||||
'configuration' => $configuration,
|
'configuration' => $configuration,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doEdit(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeUpdate = null): Response
|
protected function doEdit(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeUpdate = null, string $context = 'edit'): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
|
|
||||||
$this->prepareEntity($entity);
|
$this->prepareEntity($entity);
|
||||||
|
|
||||||
$form = $this->createForm($configuration->getForm('edit'), $entity, $configuration->getFormOptions('edit'));
|
$form = $this->createForm($configuration->getForm('edit'), $entity, $configuration->getFormOptions($context));
|
||||||
|
|
||||||
if ($request->isMethod('POST')) {
|
if ($request->isMethod('POST')) {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
@ -112,22 +115,109 @@ abstract class CrudController extends AdminController
|
||||||
$entityManager->update($entity);
|
$entityManager->update($entity);
|
||||||
$this->addFlash('success', 'The data has been saved.');
|
$this->addFlash('success', 'The data has been saved.');
|
||||||
|
|
||||||
return $this->redirectToRoute($configuration->getPageRoute('edit'), array_merge(
|
return $this->redirectToRoute($configuration->getPageRoute($context), array_merge(
|
||||||
['entity' => $entity->getId()],
|
['entity' => $entity->getId()],
|
||||||
$configuration->getPageRouteParams('edit')
|
$configuration->getPageRouteParams($context)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$this->addFlash('warning', 'The form is not valid.');
|
$this->addFlash('warning', 'The form is not valid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($configuration->getView('edit'), [
|
return $this->render($configuration->getView($context), [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
|
'context' => $context,
|
||||||
'configuration' => $configuration,
|
'configuration' => $configuration,
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doSort(int $page = 1, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response
|
protected function doInlineEdit(string $context, string $label, EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeUpdate = null): Response
|
||||||
|
{
|
||||||
|
$configuration = $this->getConfiguration();
|
||||||
|
|
||||||
|
$this->prepareEntity($entity);
|
||||||
|
|
||||||
|
$builder = $this->createFormBuilder($entity);
|
||||||
|
$callback = $configuration->getFields($context)[$label]['options']['inline_form'] ?? null;
|
||||||
|
$validationCallback = $configuration->getFields($context)[$label]['options']['inline_form_validation'] ?? null;
|
||||||
|
|
||||||
|
if (null === $callback) {
|
||||||
|
throw $this->createNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
call_user_func_array($callback, [$builder, $entity]);
|
||||||
|
|
||||||
|
$redirectTo = $request->query->get('redirectTo');
|
||||||
|
|
||||||
|
$form = $builder->getForm();
|
||||||
|
$session = $request->getSession();
|
||||||
|
|
||||||
|
$lastRequestId = sprintf(
|
||||||
|
'inline_request_%s_%s_%s_%s',
|
||||||
|
get_class($entity),
|
||||||
|
$entity->getId(),
|
||||||
|
$context,
|
||||||
|
$label
|
||||||
|
);
|
||||||
|
|
||||||
|
$lastRequest = $session->get($lastRequestId);
|
||||||
|
|
||||||
|
if (null !== $lastRequest && !$request->isMethod('POST')) {
|
||||||
|
$fakeRequest = Request::create(
|
||||||
|
uri: $request->getUri(),
|
||||||
|
method: 'POST',
|
||||||
|
parameters: [$form->getName() => $lastRequest]
|
||||||
|
);
|
||||||
|
|
||||||
|
$form->handleRequest($fakeRequest);
|
||||||
|
|
||||||
|
if (null !== $validationCallback) {
|
||||||
|
call_user_func_array($validationCallback, [$entity, $form, $request]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$session->remove($lastRequestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->isMethod('POST')) {
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if (null !== $validationCallback) {
|
||||||
|
call_user_func_array($validationCallback, [$entity, $form, $request]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
if (null !== $beforeUpdate) {
|
||||||
|
call_user_func_array($beforeUpdate, [$entity, $form, $request]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$session->remove($lastRequestId);
|
||||||
|
$entityManager->update($entity);
|
||||||
|
$this->addFlash('success', 'The data has been saved.');
|
||||||
|
|
||||||
|
return $this->redirect($redirectTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
$session->set($lastRequestId, $request->request->get('form'));
|
||||||
|
$this->addFlash('warning', 'The form is not valid.');
|
||||||
|
|
||||||
|
return $this->redirect(sprintf(
|
||||||
|
'%s?data-modal=%s',
|
||||||
|
$redirectTo,
|
||||||
|
urlencode($request->getUri())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render($configuration->getView('inline_edit'), [
|
||||||
|
'form' => $form->createView(),
|
||||||
|
'configuration' => $configuration,
|
||||||
|
'entity' => $entity,
|
||||||
|
'context' => $context,
|
||||||
|
'label' => $label,
|
||||||
|
'redirectTo' => $redirectTo,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doSort(int $page, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
$context = $request->query->get('context', 'index');
|
$context = $request->query->get('context', 'index');
|
||||||
|
@ -165,7 +255,7 @@ abstract class CrudController extends AdminController
|
||||||
return $this->json([]);
|
return $this->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doBatch(int $page = 1, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response
|
protected function doBatch(int $page, RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
$datas = $request->request->get('batch', []);
|
$datas = $request->request->get('batch', []);
|
||||||
|
@ -194,16 +284,39 @@ abstract class CrudController extends AdminController
|
||||||
|
|
||||||
$query->useFilters($this->filters);
|
$query->useFilters($this->filters);
|
||||||
|
|
||||||
if ('selection' === $target) {
|
$useSelection = 'selection' === $target;
|
||||||
$isSelection = true;
|
|
||||||
$pager = $query->paginate($page, $configuration->getMaxPerPage($context));
|
if ($batchAction['isGlobal']) {
|
||||||
} else {
|
$selection = null;
|
||||||
$isSelection = false;
|
|
||||||
$pager = $query->find();
|
if ($useSelection) {
|
||||||
|
$queryClone = clone $query;
|
||||||
|
$pager = $queryClone->paginate($page, $configuration->getMaxPerPage($context));
|
||||||
|
$selection = [];
|
||||||
|
|
||||||
|
foreach ($pager as $key => $entity) {
|
||||||
|
if (isset($items[$key + 1])) {
|
||||||
|
$selection[] = $entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $callback($query, $entityManager, $selection);
|
||||||
|
|
||||||
|
if ($result instanceof Response) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->redirect($request->query->get('redirectTo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pager = $useSelection
|
||||||
|
? $query->paginate($page, $configuration->getMaxPerPage($context))
|
||||||
|
: $query->find()
|
||||||
|
;
|
||||||
|
|
||||||
foreach ($pager as $key => $entity) {
|
foreach ($pager as $key => $entity) {
|
||||||
if (($isSelection && isset($items[$key + 1])) || !$isSelection) {
|
if (($useSelection && isset($items[$key + 1])) || !$useSelection) {
|
||||||
$callback($entity, $entityManager);
|
$callback($entity, $entityManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +326,7 @@ abstract class CrudController extends AdminController
|
||||||
return $this->json([]);
|
return $this->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doDelete(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeDelete = null): Response
|
protected function doDelete(EntityInterface $entity, EntityManager $entityManager, Request $request, callable $beforeDelete = null, string $route = 'index'): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
|
|
||||||
|
@ -227,10 +340,10 @@ abstract class CrudController extends AdminController
|
||||||
$this->addFlash('success', 'The data has been removed.');
|
$this->addFlash('success', 'The data has been removed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirectToRoute($configuration->getPageRoute('index'));
|
return $this->redirectToRoute($configuration->getPageRoute($route));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doFilter(Session $session): Response
|
protected function doFilter(Session $session, string $context = 'filter'): Response
|
||||||
{
|
{
|
||||||
$configuration = $this->getConfiguration();
|
$configuration = $this->getConfiguration();
|
||||||
$type = $configuration->getForm('filter');
|
$type = $configuration->getForm('filter');
|
||||||
|
@ -239,11 +352,12 @@ abstract class CrudController extends AdminController
|
||||||
throw $this->createNotFoundException();
|
throw $this->createNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm($type);
|
$form = $this->createForm($type, null, $configuration->getFormOptions('filter'));
|
||||||
$form->submit($session->get($form->getName(), []));
|
$form->submit($session->get($form->getName(), []));
|
||||||
|
|
||||||
return $this->render($configuration->getView('filter'), [
|
return $this->render($configuration->getView($context), [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
|
'context' => $context,
|
||||||
'configuration' => $configuration,
|
'configuration' => $configuration,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +371,7 @@ abstract class CrudController extends AdminController
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm($type);
|
$form = $this->createForm($type, null, $configuration->getFormOptions('filter'));
|
||||||
|
|
||||||
if ($request->query->has($form->getName())) {
|
if ($request->query->has($form->getName())) {
|
||||||
$filters = $request->query->get($form->getName());
|
$filters = $request->query->get($form->getName());
|
||||||
|
@ -304,9 +418,27 @@ abstract class CrudController extends AdminController
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultSort = $configuration->getDefaultSort($context);
|
$defaultSort = $configuration->getDefaultSort($context);
|
||||||
|
$session = $request->getSession();
|
||||||
|
|
||||||
$name = $request->query->get('_sort', $defaultSort['label'] ?? null);
|
$sessionId = sprintf('%s_%s_sort', $context, get_called_class());
|
||||||
$direction = strtolower($request->query->get('_sort_direction', $defaultSort['direction'] ?? 'asc'));
|
$sessionSortName = sprintf('%s_label', $sessionId);
|
||||||
|
$sessionSortDirection = sprintf('%s_direction', $sessionId);
|
||||||
|
|
||||||
|
$name = $request->query->get('_sort', $session->get($sessionSortName)) ?? $defaultSort['label'] ?? null;
|
||||||
|
|
||||||
|
$direction = strtolower(
|
||||||
|
$request->query->get(
|
||||||
|
'_sort_direction',
|
||||||
|
$session->get($sessionSortDirection)
|
||||||
|
) ?? $defaultSort['direction'] ?? 'asc'
|
||||||
|
);
|
||||||
|
|
||||||
|
$session->set($sessionSortName, $name);
|
||||||
|
$session->set($sessionSortDirection, $direction);
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!in_array($direction, ['asc', 'desc'])) {
|
if (!in_array($direction, ['asc', 'desc'])) {
|
||||||
$direction = 'asc';
|
$direction = 'asc';
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
namespace App\Core\Controller\Dashboard;
|
namespace App\Core\Controller\Dashboard;
|
||||||
|
|
||||||
use App\Core\Controller\Admin\AdminController;
|
use App\Core\Controller\Admin\AdminController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
|
|
||||||
class DashboardAdminController extends AdminController
|
class DashboardAdminController extends AdminController
|
||||||
{
|
{
|
||||||
|
|
41
src/core/Controller/Editor/BuilderBlockController.php
Normal file
41
src/core/Controller/Editor/BuilderBlockController.php
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Controller\Editor;
|
||||||
|
|
||||||
|
use App\Core\BuilderBlock\BuilderBlockContainer;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
#[Route(path: '/admin/editor/builder_block')]
|
||||||
|
class BuilderBlockController extends AbstractController
|
||||||
|
{
|
||||||
|
public function __construct(protected TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/widgets', name: 'admin_editor_builder_block_widgets', options: ['expose' => true])]
|
||||||
|
public function widgets(BuilderBlockContainer $container): JsonResponse
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($container->getWidgets() as $widget) {
|
||||||
|
$data[$widget->getName()] = $this->translate($widget->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function translate(array $data)
|
||||||
|
{
|
||||||
|
$data['label'] = $this->translator->trans($data['label']);
|
||||||
|
$data['category'] = $this->translator->trans($data['category']);
|
||||||
|
|
||||||
|
foreach ($data['settings'] as $key => $value) {
|
||||||
|
$data['settings'][$key]['label'] = $this->translator->trans($data['settings'][$key]['label']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -390,7 +390,7 @@ class FileManagerAdminController extends AdminController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/delete', name: 'admin_file_manager_delete', methods: ['DELETE'])]
|
#[Route(path: '/delete', name: 'admin_file_manager_delete', methods: ['DELETE', 'POST'])]
|
||||||
public function delete(FsFileManager $manager, Request $request): Response
|
public function delete(FsFileManager $manager, Request $request): Response
|
||||||
{
|
{
|
||||||
$path = $request->request->get('file');
|
$path = $request->request->get('file');
|
||||||
|
|
|
@ -61,7 +61,7 @@ class RedirectAdminController extends CrudController
|
||||||
return $this->doBatch($page, $query, $entityManager, $request, $session);
|
return $this->doBatch($page, $query, $entityManager, $request, $session);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/redirect/delete/{entity}', name: 'admin_redirect_delete', methods: ['DELETE'])]
|
#[Route(path: '/admin/redirect/delete/{entity}', name: 'admin_redirect_delete', methods: ['DELETE', 'POST'])]
|
||||||
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->doDelete($entity, $entityManager, $request);
|
return $this->doDelete($entity, $entityManager, $request);
|
||||||
|
@ -102,11 +102,11 @@ class RedirectAdminController extends CrudController
|
||||||
'attr' => ['class' => 'col-6'],
|
'attr' => ['class' => 'col-6'],
|
||||||
])
|
])
|
||||||
->setField('index', 'Enabled', Field\ButtonField::class, [
|
->setField('index', 'Enabled', Field\ButtonField::class, [
|
||||||
'property_builder' => function(EntityInterface $entity) {
|
'property_builder' => function (EntityInterface $entity) {
|
||||||
return $entity->getIsEnabled() ? 'Yes' : 'No';
|
return $entity->getIsEnabled() ? 'Yes' : 'No';
|
||||||
},
|
},
|
||||||
'attr' => ['class' => 'col-1'],
|
'attr' => ['class' => 'col-1'],
|
||||||
'button_attr_builder' => function(EntityInterface $entity) {
|
'button_attr_builder' => function (EntityInterface $entity) {
|
||||||
return ['class' => 'btn btn-sm btn-'.($entity->getIsEnabled() ? 'success' : 'primary')];
|
return ['class' => 'btn btn-sm btn-'.($entity->getIsEnabled() ? 'success' : 'primary')];
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
|
@ -31,11 +31,28 @@ class NavigationSettingAdminController extends AdminController
|
||||||
$eventDispatcher->dispatch($event, NavigationSettingEvent::FORM_INIT_EVENT);
|
$eventDispatcher->dispatch($event, NavigationSettingEvent::FORM_INIT_EVENT);
|
||||||
|
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
$redirectTo = $request->query->get('redirectTo');
|
||||||
|
$session = $request->getSession();
|
||||||
|
$lastRequestId = sprintf('setting_request_%s_%s', get_class($entity), $entity->getId());
|
||||||
|
$lastRequest = $session->get($lastRequestId);
|
||||||
|
|
||||||
|
if (null !== $lastRequest && !$request->isMethod('POST')) {
|
||||||
|
$fakeRequest = Request::create(
|
||||||
|
uri: $request->getUri(),
|
||||||
|
method: 'POST',
|
||||||
|
parameters: [$form->getName() => $lastRequest]
|
||||||
|
);
|
||||||
|
|
||||||
|
$form->handleRequest($fakeRequest);
|
||||||
|
$session->remove($lastRequestId);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->isMethod('POST')) {
|
if ($request->isMethod('POST')) {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
|
$entityManager->update($entity);
|
||||||
|
$session->remove($lastRequestId);
|
||||||
$entityManager->update($entity);
|
$entityManager->update($entity);
|
||||||
$this->addFlash('success', 'The data has been saved.');
|
$this->addFlash('success', 'The data has been saved.');
|
||||||
|
|
||||||
|
@ -44,17 +61,25 @@ class NavigationSettingAdminController extends AdminController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$session->set($lastRequestId, $request->request->get('form'));
|
||||||
$this->addFlash('warning', 'The form is not valid.');
|
$this->addFlash('warning', 'The form is not valid.');
|
||||||
|
|
||||||
|
return $this->redirect(sprintf(
|
||||||
|
'%s?data-modal=%s',
|
||||||
|
$redirectTo,
|
||||||
|
urlencode($request->getUri())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('@Core/setting/navigation_setting_admin/edit.html.twig', [
|
return $this->render('@Core/setting/navigation_setting_admin/edit.html.twig', [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'options' => $event->getData()['options'],
|
'options' => $event->getData()['options'],
|
||||||
|
'redirectTo' => $redirectTo,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/delete/{entity}', name: 'admin_navigation_setting_delete', methods: ['DELETE'])]
|
#[Route(path: '/delete/{entity}', name: 'admin_navigation_setting_delete', methods: ['DELETE', 'POST'])]
|
||||||
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
||||||
|
|
|
@ -12,14 +12,10 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
/**
|
#[Route(path: '/admin/setting')]
|
||||||
* @Route("/admin/setting")
|
|
||||||
*/
|
|
||||||
class SettingAdminController extends AdminController
|
class SettingAdminController extends AdminController
|
||||||
{
|
{
|
||||||
/**
|
#[Route(path: '/{page}', name: 'admin_setting_index', requirements: ['page' => '\d+'])]
|
||||||
* @Route("/{page}", name="admin_setting_index", requirements={"page": "\d+"})
|
|
||||||
*/
|
|
||||||
public function index(
|
public function index(
|
||||||
RepositoryQuery $query,
|
RepositoryQuery $query,
|
||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
|
@ -38,9 +34,7 @@ class SettingAdminController extends AdminController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Route(path: '/edit/{entity}', name: 'admin_setting_edit')]
|
||||||
* @Route("/edit/{entity}", name="admin_setting_edit")
|
|
||||||
*/
|
|
||||||
public function edit(
|
public function edit(
|
||||||
Entity $entity,
|
Entity $entity,
|
||||||
EntityManager $entityManager,
|
EntityManager $entityManager,
|
||||||
|
@ -57,30 +51,53 @@ class SettingAdminController extends AdminController
|
||||||
$eventDispatcher->dispatch($event, SettingEvent::FORM_INIT_EVENT);
|
$eventDispatcher->dispatch($event, SettingEvent::FORM_INIT_EVENT);
|
||||||
|
|
||||||
$form = $builder->getForm();
|
$form = $builder->getForm();
|
||||||
|
$redirectTo = $request->query->get('redirectTo');
|
||||||
|
$session = $request->getSession();
|
||||||
|
$lastRequestId = sprintf('setting_request_%s_%s', get_class($entity), $entity->getId());
|
||||||
|
$lastRequest = $session->get($lastRequestId);
|
||||||
|
|
||||||
|
if (null !== $lastRequest && !$request->isMethod('POST')) {
|
||||||
|
$fakeRequest = Request::create(
|
||||||
|
uri: $request->getUri(),
|
||||||
|
method: 'POST',
|
||||||
|
parameters: [$form->getName() => $lastRequest]
|
||||||
|
);
|
||||||
|
|
||||||
|
$form->handleRequest($fakeRequest);
|
||||||
|
$session->remove($lastRequestId);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->isMethod('POST')) {
|
if ($request->isMethod('POST')) {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
|
$entityManager->update($entity);
|
||||||
|
$session->remove($lastRequestId);
|
||||||
$entityManager->update($entity);
|
$entityManager->update($entity);
|
||||||
$this->addFlash('success', 'The data has been saved.');
|
$this->addFlash('success', 'The data has been saved.');
|
||||||
|
|
||||||
return $this->redirectToRoute('admin_setting_index');
|
return $this->redirectToRoute('admin_setting_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$session->set($lastRequestId, $request->request->get('form'));
|
||||||
$this->addFlash('warning', 'The form is not valid.');
|
$this->addFlash('warning', 'The form is not valid.');
|
||||||
|
|
||||||
|
return $this->redirect(sprintf(
|
||||||
|
'%s?data-modal=%s',
|
||||||
|
$redirectTo,
|
||||||
|
urlencode($request->getUri())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('@Core/setting/setting_admin/edit.html.twig', [
|
return $this->render('@Core/setting/setting_admin/edit.html.twig', [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'options' => $event->getData()['options'],
|
'options' => $event->getData()['options'],
|
||||||
|
'redirectTo' => $redirectTo,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Route(path: '/delete/{entity}', name: 'admin_setting_delete', methods: ['DELETE', 'POST'])]
|
||||||
* @Route("/delete/{entity}", name="admin_setting_delete", methods={"DELETE"})
|
|
||||||
*/
|
|
||||||
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ class MenuAdminController extends AdminController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/delete/{entity}', name: 'admin_site_menu_delete', methods: ['DELETE'])]
|
#[Route(path: '/delete/{entity}', name: 'admin_site_menu_delete', methods: ['DELETE', 'POST'])]
|
||||||
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
|
||||||
|
|
|
@ -67,12 +67,12 @@ class NavigationAdminController extends CrudController
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/site/navigation/sort/{page}', name: 'admin_site_navigation_sort', methods: ['POST'], requirements: ['page' => '\d+'])]
|
#[Route(path: '/admin/site/navigation/sort/{page}', name: 'admin_site_navigation_sort', methods: ['POST'], requirements: ['page' => '\d+'])]
|
||||||
public function sort(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1, ): Response
|
public function sort(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response
|
||||||
{
|
{
|
||||||
return $this->doSort($page, $query, $entityManager, $request, $session);
|
return $this->doSort($page, $query, $entityManager, $request, $session);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/site/navigation/delete/{entity}', name: 'admin_site_navigation_delete', methods: ['DELETE'])]
|
#[Route(path: '/admin/site/navigation/delete/{entity}', name: 'admin_site_navigation_delete', methods: ['DELETE', 'POST'])]
|
||||||
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->doDelete($entity, $entityManager, $request);
|
return $this->doDelete($entity, $entityManager, $request);
|
||||||
|
@ -104,9 +104,11 @@ class NavigationAdminController extends CrudController
|
||||||
->setView('form', '@Core/site/navigation_admin/_form.html.twig')
|
->setView('form', '@Core/site/navigation_admin/_form.html.twig')
|
||||||
|
|
||||||
->setIsSortableCollection('index', true)
|
->setIsSortableCollection('index', true)
|
||||||
|
->setDoubleClick('index', true)
|
||||||
|
|
||||||
->setField('index', 'Label', Field\TextField::class, [
|
->setField('index', 'Label', Field\TextField::class, [
|
||||||
'property' => 'label',
|
'property' => 'label',
|
||||||
|
'view' => '@Core/site/navigation_admin/field/label.html.twig',
|
||||||
'attr' => ['class' => 'miw-200'],
|
'attr' => ['class' => 'miw-200'],
|
||||||
])
|
])
|
||||||
->setField('index', 'Domain', Field\ButtonField::class, [
|
->setField('index', 'Domain', Field\ButtonField::class, [
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Core\Controller\Site;
|
namespace App\Core\Controller\Site;
|
||||||
|
|
||||||
use App\Core\Controller\Admin\AdminController;
|
|
||||||
use App\Core\Entity\Site\Node;
|
use App\Core\Entity\Site\Node;
|
||||||
use App\Core\Entity\Site\Node as Entity;
|
use App\Core\Entity\Site\Node as Entity;
|
||||||
use App\Core\Entity\Site\Page\Page;
|
use App\Core\Entity\Site\Page\Page;
|
||||||
|
@ -14,15 +13,15 @@ use App\Core\Form\Site\NodeType as EntityType;
|
||||||
use App\Core\Manager\EntityManager;
|
use App\Core\Manager\EntityManager;
|
||||||
use App\Core\Repository\Site\NodeRepository;
|
use App\Core\Repository\Site\NodeRepository;
|
||||||
use App\Core\Site\ControllerLocator;
|
use App\Core\Site\ControllerLocator;
|
||||||
use App\Core\Site\RoleLocator;
|
|
||||||
use App\Core\Site\PageLocator;
|
use App\Core\Site\PageLocator;
|
||||||
|
use App\Core\Site\RoleLocator;
|
||||||
use App\Core\Sitemap\SitemapBuilder;
|
use App\Core\Sitemap\SitemapBuilder;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
|
|
||||||
#[Route(path: '/admin/site/node')]
|
#[Route(path: '/admin/site/node')]
|
||||||
class NodeAdminController extends AbstractController
|
class NodeAdminController extends AbstractController
|
||||||
|
@ -145,7 +144,7 @@ class NodeAdminController extends AbstractController
|
||||||
|
|
||||||
$page = $entity->getPage();
|
$page = $entity->getPage();
|
||||||
|
|
||||||
if ($page !== null) {
|
if (null !== $page) {
|
||||||
$pageConfiguration = $pageLocator->getPages()[get_class($page)] ?? null;
|
$pageConfiguration = $pageLocator->getPages()[get_class($page)] ?? null;
|
||||||
} else {
|
} else {
|
||||||
$pageConfiguration = null;
|
$pageConfiguration = null;
|
||||||
|
@ -239,7 +238,7 @@ class NodeAdminController extends AbstractController
|
||||||
]).sprintf('#node-%d', $entity->getId()));
|
]).sprintf('#node-%d', $entity->getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/delete/{entity}', name: 'admin_site_node_delete', methods: ['DELETE'])]
|
#[Route(path: '/delete/{entity}', name: 'admin_site_node_delete', methods: ['DELETE', 'POST'])]
|
||||||
public function delete(
|
public function delete(
|
||||||
Entity $entity,
|
Entity $entity,
|
||||||
NodeRepository $nodeRepository,
|
NodeRepository $nodeRepository,
|
||||||
|
|
|
@ -5,19 +5,19 @@ namespace App\Core\Controller\Site;
|
||||||
use App\Core\Controller\Admin\Crud\CrudController;
|
use App\Core\Controller\Admin\Crud\CrudController;
|
||||||
use App\Core\Crud\CrudConfiguration;
|
use App\Core\Crud\CrudConfiguration;
|
||||||
use App\Core\Crud\Field;
|
use App\Core\Crud\Field;
|
||||||
|
use App\Core\Entity\EntityInterface;
|
||||||
use App\Core\Entity\Site\Page\Page as Entity;
|
use App\Core\Entity\Site\Page\Page as Entity;
|
||||||
|
use App\Core\Event\Page\PageEditEvent;
|
||||||
use App\Core\Form\Site\Page\Filter\PageFilterType as FilterType;
|
use App\Core\Form\Site\Page\Filter\PageFilterType as FilterType;
|
||||||
use App\Core\Form\Site\Page\PageType as Type;
|
use App\Core\Form\Site\Page\PageType as Type;
|
||||||
use App\Core\Manager\EntityManager;
|
use App\Core\Manager\EntityManager;
|
||||||
use App\Core\Repository\Site\Page\PageRepositoryQuery as RepositoryQuery;
|
use App\Core\Repository\Site\Page\PageRepositoryQuery as RepositoryQuery;
|
||||||
use App\Core\Site\PageLocator;
|
use App\Core\Site\PageLocator;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use App\Core\Event\Page\PageEditEvent;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use App\Core\Entity\EntityInterface;
|
|
||||||
|
|
||||||
class PageAdminController extends CrudController
|
class PageAdminController extends CrudController
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ class PageAdminController extends CrudController
|
||||||
return $this->doEdit($entity, $entityManager, $request);
|
return $this->doEdit($entity, $entityManager, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/site/page/delete/{entity}', name: 'admin_site_page_delete', methods: ['DELETE'])]
|
#[Route(path: '/admin/site/page/delete/{entity}', name: 'admin_site_page_delete', methods: ['DELETE', 'POST'])]
|
||||||
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->doDelete($entity, $entityManager, $request);
|
return $this->doDelete($entity, $entityManager, $request);
|
||||||
|
@ -95,6 +95,8 @@ class PageAdminController extends CrudController
|
||||||
->setAction('index', 'show', false)
|
->setAction('index', 'show', false)
|
||||||
->setAction('edit', 'show', false)
|
->setAction('edit', 'show', false)
|
||||||
|
|
||||||
|
->setDoubleClick('index', true)
|
||||||
|
|
||||||
->setField('index', 'Name', Field\TextField::class, [
|
->setField('index', 'Name', Field\TextField::class, [
|
||||||
'property' => 'name',
|
'property' => 'name',
|
||||||
'sort' => ['name', '.name'],
|
'sort' => ['name', '.name'],
|
||||||
|
@ -112,7 +114,7 @@ class PageAdminController extends CrudController
|
||||||
}],
|
}],
|
||||||
'attr' => ['class' => 'col-6'],
|
'attr' => ['class' => 'col-6'],
|
||||||
])
|
])
|
||||||
->setBatchAction('index', 'delete', 'Delete', function(EntityInterface $entity, EntityManager $manager) {
|
->setBatchAction('index', 'delete', 'Delete', function (EntityInterface $entity, EntityManager $manager) {
|
||||||
$manager->delete($entity);
|
$manager->delete($entity);
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
|
@ -8,55 +8,55 @@ use App\Core\Crud\Field;
|
||||||
use App\Core\Event\Account\PasswordRequestEvent;
|
use App\Core\Event\Account\PasswordRequestEvent;
|
||||||
use App\Core\Factory\UserFactory as Factory;
|
use App\Core\Factory\UserFactory as Factory;
|
||||||
use App\Core\Manager\EntityManager;
|
use App\Core\Manager\EntityManager;
|
||||||
|
use App\Core\Security\TokenGenerator;
|
||||||
use App\Entity\User as Entity;
|
use App\Entity\User as Entity;
|
||||||
use App\Form\UserType as Type;
|
use App\Form\UserType as Type;
|
||||||
use App\Repository\UserRepositoryQuery as RepositoryQuery;
|
use App\Repository\UserRepositoryQuery as RepositoryQuery;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use App\Core\Security\TokenGenerator;
|
|
||||||
|
|
||||||
class UserAdminController extends CrudController
|
class UserAdminController extends CrudController
|
||||||
{
|
{
|
||||||
#[Route(path: '/admin/user/{page}', name: 'admin_user_index', methods: ['GET'], requirements: ['page' => '\d+'])]
|
protected ?CrudConfiguration $configuration = null;
|
||||||
|
|
||||||
public function index(RepositoryQuery $query, Request $request, Session $session, int $page = 1): Response
|
public function index(RepositoryQuery $query, Request $request, Session $session, int $page = 1): Response
|
||||||
{
|
{
|
||||||
return $this->doIndex($page, $query, $request, $session);
|
return $this->doIndex($page, $query, $request, $session);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/user/new', name: 'admin_user_new', methods: ['GET', 'POST'])]
|
|
||||||
public function new(Factory $factory, EntityManager $entityManager, Request $request, TokenGenerator $tokenGenerator): Response
|
public function new(Factory $factory, EntityManager $entityManager, Request $request, TokenGenerator $tokenGenerator): Response
|
||||||
{
|
{
|
||||||
return $this->doNew($factory->create(null, $tokenGenerator->generateToken()), $entityManager, $request);
|
return $this->doNew($factory->create(null, $tokenGenerator->generateToken()), $entityManager, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/user/show/{entity}', name: 'admin_user_show', methods: ['GET'])]
|
|
||||||
public function show(Entity $entity): Response
|
public function show(Entity $entity): Response
|
||||||
{
|
{
|
||||||
return $this->doShow($entity);
|
return $this->doShow($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/user/filter', name: 'admin_user_filter', methods: ['GET'])]
|
|
||||||
public function filter(Session $session): Response
|
public function filter(Session $session): Response
|
||||||
{
|
{
|
||||||
return $this->doFilter($session);
|
return $this->doFilter($session);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/user/edit/{entity}', name: 'admin_user_edit', methods: ['GET', 'POST'])]
|
|
||||||
public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function edit(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->doEdit($entity, $entityManager, $request);
|
return $this->doEdit($entity, $entityManager, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/user/delete/{entity}', name: 'admin_user_delete', methods: ['DELETE'])]
|
public function inlineEdit(string $context, string $label, Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
|
{
|
||||||
|
return $this->doInlineEdit($context, $label, $entity, $entityManager, $request);
|
||||||
|
}
|
||||||
|
|
||||||
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
public function delete(Entity $entity, EntityManager $entityManager, Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->doDelete($entity, $entityManager, $request);
|
return $this->doDelete($entity, $entityManager, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/admin/user/resetting_request/{entity}', name: 'admin_user_resetting_request', methods: ['POST'])]
|
|
||||||
public function requestResetting(Entity $entity, EventDispatcherInterface $eventDispatcher, Request $request): Response
|
public function requestResetting(Entity $entity, EventDispatcherInterface $eventDispatcher, Request $request): Response
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('resetting_request'.$entity->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('resetting_request'.$entity->getId(), $request->request->get('_token'))) {
|
||||||
|
@ -81,6 +81,7 @@ class UserAdminController extends CrudController
|
||||||
->setPageRoute('index', 'admin_user_index')
|
->setPageRoute('index', 'admin_user_index')
|
||||||
->setPageRoute('new', 'admin_user_new')
|
->setPageRoute('new', 'admin_user_new')
|
||||||
->setPageRoute('edit', 'admin_user_edit')
|
->setPageRoute('edit', 'admin_user_edit')
|
||||||
|
->setPageRoute('inline_edit', 'admin_user_inline_edit')
|
||||||
->setPageRoute('show', 'admin_user_show')
|
->setPageRoute('show', 'admin_user_show')
|
||||||
->setPageRoute('delete', 'admin_user_delete')
|
->setPageRoute('delete', 'admin_user_delete')
|
||||||
->setPageRoute('filter', 'admin_user_filter')
|
->setPageRoute('filter', 'admin_user_filter')
|
||||||
|
@ -96,6 +97,7 @@ class UserAdminController extends CrudController
|
||||||
->setView('edit', '@Core/user/user_admin/edit.html.twig')
|
->setView('edit', '@Core/user/user_admin/edit.html.twig')
|
||||||
|
|
||||||
->setDefaultSort('index', 'username')
|
->setDefaultSort('index', 'username')
|
||||||
|
->setDoubleClick('index', true)
|
||||||
|
|
||||||
->setField('index', 'E-mail', Field\TextField::class, [
|
->setField('index', 'E-mail', Field\TextField::class, [
|
||||||
'property' => 'email',
|
'property' => 'email',
|
||||||
|
@ -106,6 +108,9 @@ class UserAdminController extends CrudController
|
||||||
'property' => 'displayName',
|
'property' => 'displayName',
|
||||||
'sort' => ['displayName', '.displayName'],
|
'sort' => ['displayName', '.displayName'],
|
||||||
'attr' => ['class' => 'miw-200'],
|
'attr' => ['class' => 'miw-200'],
|
||||||
|
'inline_form' => function (FormBuilderInterface $builder) {
|
||||||
|
$builder->add('displayName', null);
|
||||||
|
},
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ class CrudConfiguration
|
||||||
protected array $actionTitles = [];
|
protected array $actionTitles = [];
|
||||||
protected array $forms = [];
|
protected array $forms = [];
|
||||||
protected array $formOptions = [];
|
protected array $formOptions = [];
|
||||||
|
protected array $inlineForms = [];
|
||||||
protected array $views = [];
|
protected array $views = [];
|
||||||
protected array $viewDatas = [];
|
protected array $viewDatas = [];
|
||||||
protected array $fields = [];
|
protected array $fields = [];
|
||||||
|
@ -39,7 +40,7 @@ class CrudConfiguration
|
||||||
return self::$self;
|
return self::$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setPageTitle(string $page, string $title): self
|
public function setPageTitle(string $page, string $title): self
|
||||||
{
|
{
|
||||||
|
@ -53,7 +54,7 @@ class CrudConfiguration
|
||||||
return $this->pageTitles[$page] ?? $default;
|
return $this->pageTitles[$page] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setPageRoute(string $page, string $route): self
|
public function setPageRoute(string $page, string $route): self
|
||||||
{
|
{
|
||||||
|
@ -79,9 +80,9 @@ class CrudConfiguration
|
||||||
return $this->pageRouteParams[$page] ?? [];
|
return $this->pageRouteParams[$page] ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setForm(string $context, string $form, array $options = []): self
|
public function setForm(string $context, string $form): self
|
||||||
{
|
{
|
||||||
$this->forms[$context] = $form;
|
$this->forms[$context] = $form;
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ class CrudConfiguration
|
||||||
return $this->formOptions[$context] ?? [];
|
return $this->formOptions[$context] ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setAction(string $page, string $action, bool|callable $enabled): self
|
public function setAction(string $page, string $action, bool|callable $enabled): self
|
||||||
{
|
{
|
||||||
|
@ -134,8 +135,24 @@ class CrudConfiguration
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBatchAction(string $page, string $action, string $label, callable $callback): self
|
public function setGlobalBatchAction(
|
||||||
{
|
string $page,
|
||||||
|
string $action,
|
||||||
|
string $label,
|
||||||
|
callable $callback
|
||||||
|
): self {
|
||||||
|
$this->setBatchAction($page, $action, $label, $callback);
|
||||||
|
$this->batchActions[$page][$action]['isGlobal'] = true;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBatchAction(
|
||||||
|
string $page,
|
||||||
|
string $action,
|
||||||
|
string $label,
|
||||||
|
callable $callback
|
||||||
|
): self {
|
||||||
if (!isset($this->batchActions[$page])) {
|
if (!isset($this->batchActions[$page])) {
|
||||||
$this->batchActions[$page] = [];
|
$this->batchActions[$page] = [];
|
||||||
}
|
}
|
||||||
|
@ -143,6 +160,7 @@ class CrudConfiguration
|
||||||
$this->batchActions[$page][$action] = [
|
$this->batchActions[$page][$action] = [
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
'callback' => $callback,
|
'callback' => $callback,
|
||||||
|
'isGlobal' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -163,7 +181,7 @@ class CrudConfiguration
|
||||||
return !empty($this->batchActions[$page]);
|
return !empty($this->batchActions[$page]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setActionTitle(string $page, string $action, string $title): self
|
public function setActionTitle(string $page, string $action, string $title): self
|
||||||
{
|
{
|
||||||
|
@ -181,7 +199,7 @@ class CrudConfiguration
|
||||||
return $this->actionTitles[$page][$action] ?? $default;
|
return $this->actionTitles[$page][$action] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setView(string $context, string $view): self
|
public function setView(string $context, string $view): self
|
||||||
{
|
{
|
||||||
|
@ -229,7 +247,7 @@ class CrudConfiguration
|
||||||
return $this->viewDatas[$context][$name] ?? $defaultValue;
|
return $this->viewDatas[$context][$name] ?? $defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setField(string $context, string $label, string $field, array $options): self
|
public function setField(string $context, string $label, string $field, array $options): self
|
||||||
{
|
{
|
||||||
|
@ -250,9 +268,16 @@ class CrudConfiguration
|
||||||
return $this->fields[$context] ?? [];
|
return $this->fields[$context] ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
public function setFields(string $context, array $fields): self
|
||||||
|
{
|
||||||
|
$this->fields[$context] = $fields;
|
||||||
|
|
||||||
public function setMaxPerPage(string $page, int $max)
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --
|
||||||
|
|
||||||
|
public function setMaxPerPage(string $page, int $max): self
|
||||||
{
|
{
|
||||||
$this->maxPerPage[$page] = $max;
|
$this->maxPerPage[$page] = $max;
|
||||||
|
|
||||||
|
@ -264,7 +289,21 @@ class CrudConfiguration
|
||||||
return $this->maxPerPage[$page] ?? $default;
|
return $this->maxPerPage[$page] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
|
public function setDoubleClick(string $page, bool $enabled): self
|
||||||
|
{
|
||||||
|
$this->doubleClick[$page] = $enabled;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDoubleClick(string $page): bool
|
||||||
|
{
|
||||||
|
return $this->doubleClick[$page] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --
|
||||||
|
|
||||||
public function setI18n(array $locales, string $defaultLocale): self
|
public function setI18n(array $locales, string $defaultLocale): self
|
||||||
{
|
{
|
||||||
|
@ -289,7 +328,7 @@ class CrudConfiguration
|
||||||
return !empty($this->locales);
|
return !empty($this->locales);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- */
|
// --
|
||||||
|
|
||||||
public function setDefaultSort(string $context, string $label, string $direction = 'asc'): self
|
public function setDefaultSort(string $context, string $label, string $direction = 'asc'): self
|
||||||
{
|
{
|
||||||
|
|
32
src/core/Crud/Field/BooleanField.php
Normal file
32
src/core/Crud/Field/BooleanField.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Crud\Field;
|
||||||
|
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class BooleanField.
|
||||||
|
*
|
||||||
|
* @author Simon Vieille <simon@deblan.fr>
|
||||||
|
*/
|
||||||
|
class BooleanField extends Field
|
||||||
|
{
|
||||||
|
public function configureOptions(OptionsResolver $resolver): OptionsResolver
|
||||||
|
{
|
||||||
|
parent::configureOptions($resolver);
|
||||||
|
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'view' => '@Core/admin/crud/field/boolean.html.twig',
|
||||||
|
'display' => 'toggle',
|
||||||
|
'checkbox_class_when_true' => 'fa-check-square',
|
||||||
|
'checkbox_class_when_false' => 'fa-square',
|
||||||
|
'toggle_class_when_true' => 'bg-success',
|
||||||
|
'toggle_class_when_false' => 'bg-secondary',
|
||||||
|
'default_value' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$resolver->setAllowedTypes('display', 'string');
|
||||||
|
|
||||||
|
return $resolver;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,24 +28,31 @@ abstract class Field
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'property' => null,
|
'property' => null,
|
||||||
'property_builder' => null,
|
'property_builder' => null,
|
||||||
|
'default_value' => null,
|
||||||
'view' => null,
|
'view' => null,
|
||||||
|
'action' => null,
|
||||||
'raw' => false,
|
'raw' => false,
|
||||||
'sort' => null,
|
'sort' => null,
|
||||||
'href' => null,
|
'href' => null,
|
||||||
'href_attr' => [],
|
'href_attr' => [],
|
||||||
'attr' => [],
|
'attr' => [],
|
||||||
|
'inline_form' => null,
|
||||||
|
'inline_form_validation' => null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$resolver->setRequired('view');
|
$resolver->setRequired('view');
|
||||||
$resolver->setAllowedTypes('property', ['null', 'string']);
|
$resolver->setAllowedTypes('property', ['null', 'string']);
|
||||||
$resolver->setAllowedTypes('view', 'string');
|
$resolver->setAllowedTypes('view', 'string');
|
||||||
|
$resolver->setAllowedTypes('action', ['null', 'string']);
|
||||||
$resolver->setAllowedTypes('attr', 'array');
|
$resolver->setAllowedTypes('attr', 'array');
|
||||||
$resolver->setAllowedTypes('href', ['null', 'string', 'callable']);
|
$resolver->setAllowedTypes('href', ['null', 'string', 'callable']);
|
||||||
$resolver->setAllowedTypes('href_attr', 'array', 'callable');
|
$resolver->setAllowedTypes('inline_form', ['null', 'callable']);
|
||||||
|
$resolver->setAllowedTypes('inline_form_validation', ['null', 'callable']);
|
||||||
|
$resolver->setAllowedTypes('href_attr', ['array', 'callable']);
|
||||||
$resolver->setAllowedTypes('raw', 'boolean');
|
$resolver->setAllowedTypes('raw', 'boolean');
|
||||||
$resolver->setAllowedTypes('property_builder', ['null', 'callable']);
|
$resolver->setAllowedTypes('property_builder', ['null', 'callable']);
|
||||||
$resolver->setAllowedValues('sort', function($value) {
|
$resolver->setAllowedValues('sort', function ($value) {
|
||||||
if ($value === null) {
|
if (null === $value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
src/core/DependencyInjection/Compiler/BuilderBlockPass.php
Normal file
25
src/core/DependencyInjection/Compiler/BuilderBlockPass.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\DependencyInjection\Compiler;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use App\Core\BuilderBlock\BuilderBlockContainer;
|
||||||
|
|
||||||
|
class BuilderBlockPass implements CompilerPassInterface
|
||||||
|
{
|
||||||
|
public function process(ContainerBuilder $container): void
|
||||||
|
{
|
||||||
|
if (!$container->has(BuilderBlockContainer::class)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$definition = $container->findDefinition(BuilderBlockContainer::class);
|
||||||
|
$taggedServices = $container->findTaggedServiceIds('builder_block.widget');
|
||||||
|
|
||||||
|
foreach ($taggedServices as $id => $tags) {
|
||||||
|
$definition->addMethodCall('addWidget', [new Reference($id)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ class Configuration implements ConfigurationInterface
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
'image/gif',
|
'image/gif',
|
||||||
'image/svg+xml',
|
'image/svg+xml',
|
||||||
|
'image/webp',
|
||||||
'video/mp4',
|
'video/mp4',
|
||||||
'audio/mpeg3',
|
'audio/mpeg3',
|
||||||
'audio/x-mpeg-3',
|
'audio/x-mpeg-3',
|
||||||
|
@ -50,12 +51,10 @@ class Configuration implements ConfigurationInterface
|
||||||
->scalarNode('name')
|
->scalarNode('name')
|
||||||
->defaultValue('Murph')
|
->defaultValue('Murph')
|
||||||
->isRequired()
|
->isRequired()
|
||||||
->cannotBeEmpty()
|
|
||||||
->end()
|
->end()
|
||||||
->scalarNode('logo')
|
->scalarNode('logo')
|
||||||
->defaultValue('build/images/core/logo.svg')
|
->defaultValue('build/images/core/logo.svg')
|
||||||
->isRequired()
|
->isRequired()
|
||||||
->cannotBeEmpty()
|
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('controllers')
|
->arrayNode('controllers')
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
|
@ -140,6 +139,7 @@ class Configuration implements ConfigurationInterface
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end();
|
->end();
|
||||||
|
;
|
||||||
|
|
||||||
return $treeBuilder;
|
return $treeBuilder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Core\DependencyInjection;
|
namespace App\Core\DependencyInjection;
|
||||||
|
|
||||||
|
use App\Core\DependencyInjection\Compiler\BuilderBlockPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
namespace App\Core\Entity\Analytic;
|
namespace App\Core\Entity\Analytic;
|
||||||
|
|
||||||
use App\Core\Entity\Site\Node;
|
|
||||||
use App\Repository\Entity\Analytic\NodeViewRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use App\Core\Entity\EntityInterface;
|
use App\Core\Entity\EntityInterface;
|
||||||
|
use App\Core\Entity\Site\Node;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Table(name: 'analytic_referer')]
|
#[ORM\Table(name: 'analytic_referer')]
|
||||||
#[ORM\Entity(repositoryClass: ViewRepository::class)]
|
#[ORM\Entity(repositoryClass: ViewRepository::class)]
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
namespace App\Core\Entity\Analytic;
|
namespace App\Core\Entity\Analytic;
|
||||||
|
|
||||||
use App\Core\Entity\Site\Node;
|
|
||||||
use App\Repository\Entity\Analytic\NodeViewRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use App\Core\Entity\EntityInterface;
|
use App\Core\Entity\EntityInterface;
|
||||||
|
use App\Core\Entity\Site\Node;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Table(name: 'analytic_view')]
|
#[ORM\Table(name: 'analytic_view')]
|
||||||
#[ORM\Entity(repositoryClass: ViewRepository::class)]
|
#[ORM\Entity(repositoryClass: ViewRepository::class)]
|
||||||
|
|
|
@ -42,6 +42,9 @@ class Navigation implements EntityInterface
|
||||||
#[ORM\Column(type: 'string', length: 10)]
|
#[ORM\Column(type: 'string', length: 10)]
|
||||||
protected $locale = 'en';
|
protected $locale = 'en';
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string', length: 7, nullable: true)]
|
||||||
|
protected $color;
|
||||||
|
|
||||||
#[ORM\Column(type: 'integer', nullable: true)]
|
#[ORM\Column(type: 'integer', nullable: true)]
|
||||||
protected $sortOrder;
|
protected $sortOrder;
|
||||||
|
|
||||||
|
@ -64,7 +67,7 @@ class Navigation implements EntityInterface
|
||||||
return $this->label;
|
return $this->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLabel(string $label): self
|
public function setLabel(?string $label): self
|
||||||
{
|
{
|
||||||
$this->label = $label;
|
$this->label = $label;
|
||||||
|
|
||||||
|
@ -237,4 +240,16 @@ class Navigation implements EntityInterface
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setColor(string $color): self
|
||||||
|
{
|
||||||
|
$this->color = $color;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColor(): ?string
|
||||||
|
{
|
||||||
|
return $this->color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
20
src/core/Entity/Site/Page/BuilderBlock.php
Normal file
20
src/core/Entity/Site/Page/BuilderBlock.php
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Entity\Site\Page;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
class BuilderBlock extends JsonBlock
|
||||||
|
{
|
||||||
|
public function getValue()
|
||||||
|
{
|
||||||
|
$value = parent::getValue();
|
||||||
|
|
||||||
|
if (is_string($value)) {
|
||||||
|
return json_decode($value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,15 +5,6 @@ namespace App\Core\Entity\Site\Page;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
class ChoiceBlock extends Block
|
class ChoiceBlock extends JsonBlock
|
||||||
{
|
{
|
||||||
public function getValue()
|
|
||||||
{
|
|
||||||
return json_decode(parent::getValue(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setValue($value): self
|
|
||||||
{
|
|
||||||
return parent::setValue(json_encode($value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
19
src/core/Entity/Site/Page/JsonBlock.php
Normal file
19
src/core/Entity/Site/Page/JsonBlock.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Entity\Site\Page;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity]
|
||||||
|
class JsonBlock extends Block
|
||||||
|
{
|
||||||
|
public function getValue()
|
||||||
|
{
|
||||||
|
return json_decode(parent::getValue(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValue($value): self
|
||||||
|
{
|
||||||
|
return parent::setValue(json_encode($value));
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,13 +5,12 @@ namespace App\Core\Entity\Site\Page;
|
||||||
use App\Core\Doctrine\Timestampable;
|
use App\Core\Doctrine\Timestampable;
|
||||||
use App\Core\Entity\EntityInterface;
|
use App\Core\Entity\EntityInterface;
|
||||||
use App\Core\Entity\Site\Node;
|
use App\Core\Entity\Site\Node;
|
||||||
|
use App\Core\File\FileAttribute;
|
||||||
use App\Core\Repository\Site\Page\PageRepository;
|
use App\Core\Repository\Site\Page\PageRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\HttpFoundation\File\File;
|
|
||||||
use App\Core\File\FileAttribute;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: PageRepository::class)]
|
#[ORM\Entity(repositoryClass: PageRepository::class)]
|
||||||
#[ORM\DiscriminatorColumn(name: 'class_key', type: 'string')]
|
#[ORM\DiscriminatorColumn(name: 'class_key', type: 'string')]
|
||||||
|
@ -89,7 +88,7 @@ class Page implements EntityInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection|Block[]
|
* @return Block[]|Collection
|
||||||
*/
|
*/
|
||||||
public function getBlocks(): Collection
|
public function getBlocks(): Collection
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,11 +15,8 @@ class AbTestEvent extends Event
|
||||||
public const INIT_EVENT = 'ab_test.init';
|
public const INIT_EVENT = 'ab_test.init';
|
||||||
public const RUN_EVENT = 'ab_test.run';
|
public const RUN_EVENT = 'ab_test.run';
|
||||||
|
|
||||||
protected AbTest $test;
|
public function __construct(protected AbTest $test)
|
||||||
|
|
||||||
public function __construct(AbTest $test)
|
|
||||||
{
|
{
|
||||||
$this->test = $test;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTest(): AbTest
|
public function getTest(): AbTest
|
||||||
|
|
|
@ -12,13 +12,10 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||||
*/
|
*/
|
||||||
class PasswordRequestEvent extends Event
|
class PasswordRequestEvent extends Event
|
||||||
{
|
{
|
||||||
const EVENT = 'account_event.password_request';
|
public const EVENT = 'account_event.password_request';
|
||||||
|
|
||||||
protected User $user;
|
public function __construct(protected User $user)
|
||||||
|
|
||||||
public function __construct(User $user)
|
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser(): User
|
public function getUser(): User
|
||||||
|
|
|
@ -12,18 +12,15 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||||
*/
|
*/
|
||||||
class EntityManagerEvent extends Event
|
class EntityManagerEvent extends Event
|
||||||
{
|
{
|
||||||
const CREATE_EVENT = 'entity_manager_event.create';
|
public const CREATE_EVENT = 'entity_manager_event.create';
|
||||||
const UPDATE_EVENT = 'entity_manager_event.update';
|
public const UPDATE_EVENT = 'entity_manager_event.update';
|
||||||
const DELETE_EVENT = 'entity_manager_event.delete';
|
public const DELETE_EVENT = 'entity_manager_event.delete';
|
||||||
const PRE_CREATE_EVENT = 'entity_manager_event.pre_create';
|
public const PRE_CREATE_EVENT = 'entity_manager_event.pre_create';
|
||||||
const PRE_UPDATE_EVENT = 'entity_manager_event.pre_update';
|
public const PRE_UPDATE_EVENT = 'entity_manager_event.pre_update';
|
||||||
const PRE_DELETE_EVENT = 'entity_manager_event.pre_delete';
|
public const PRE_DELETE_EVENT = 'entity_manager_event.pre_delete';
|
||||||
|
|
||||||
protected EntityInterface $entity;
|
public function __construct(protected EntityInterface $entity)
|
||||||
|
|
||||||
public function __construct(EntityInterface $entity)
|
|
||||||
{
|
{
|
||||||
$this->entity = $entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntity(): EntityInterface
|
public function getEntity(): EntityInterface
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Core\Event\Page;
|
namespace App\Core\Event\Page;
|
||||||
|
|
||||||
use Symfony\Contracts\EventDispatcher\Event;
|
|
||||||
use App\Core\Entity\Site\Page\Page;
|
use App\Core\Entity\Site\Page\Page;
|
||||||
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class PageEditEvent.
|
* class PageEditEvent.
|
||||||
|
@ -12,14 +12,12 @@ use App\Core\Entity\Site\Page\Page;
|
||||||
*/
|
*/
|
||||||
class PageEditEvent extends Event
|
class PageEditEvent extends Event
|
||||||
{
|
{
|
||||||
const FORM_INIT_EVENT = 'page_edit_event.form_init';
|
public const FORM_INIT_EVENT = 'page_edit_event.form_init';
|
||||||
|
|
||||||
protected Page $page;
|
|
||||||
protected array $pageBuilderOptions = [];
|
protected array $pageBuilderOptions = [];
|
||||||
|
|
||||||
public function __construct(Page $page)
|
public function __construct(protected Page $page)
|
||||||
{
|
{
|
||||||
$this->page = $page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPage()
|
public function getPage()
|
||||||
|
|
|
@ -11,14 +11,11 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||||
*/
|
*/
|
||||||
class NavigationSettingEvent extends Event
|
class NavigationSettingEvent extends Event
|
||||||
{
|
{
|
||||||
const INIT_EVENT = 'navigation_setting_event.init';
|
public const INIT_EVENT = 'navigation_setting_event.init';
|
||||||
const FORM_INIT_EVENT = 'navigation_setting_event.form_init';
|
public const FORM_INIT_EVENT = 'navigation_setting_event.form_init';
|
||||||
|
|
||||||
protected $data;
|
public function __construct(protected $data = null)
|
||||||
|
|
||||||
public function __construct($data = null)
|
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getData()
|
public function getData()
|
||||||
|
|
|
@ -11,14 +11,11 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||||
*/
|
*/
|
||||||
class SettingEvent extends Event
|
class SettingEvent extends Event
|
||||||
{
|
{
|
||||||
const INIT_EVENT = 'setting_event.init';
|
public const INIT_EVENT = 'setting_event.init';
|
||||||
const FORM_INIT_EVENT = 'setting_event.form_init';
|
public const FORM_INIT_EVENT = 'setting_event.form_init';
|
||||||
|
|
||||||
protected $data;
|
public function __construct(protected $data = null)
|
||||||
|
|
||||||
public function __construct($data = null)
|
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getData()
|
public function getData()
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||||
*/
|
*/
|
||||||
class TaskInitEvent extends Event
|
class TaskInitEvent extends Event
|
||||||
{
|
{
|
||||||
const INIT_EVENT = 'task_event.init';
|
public const INIT_EVENT = 'task_event.init';
|
||||||
|
|
||||||
protected array $tasks = [];
|
protected array $tasks = [];
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,13 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||||
*/
|
*/
|
||||||
class TaskRunRequestedEvent extends Event
|
class TaskRunRequestedEvent extends Event
|
||||||
{
|
{
|
||||||
const RUN_REQUEST_EVENT = 'task_event.run_request';
|
public const RUN_REQUEST_EVENT = 'task_event.run_request';
|
||||||
|
|
||||||
protected string $task;
|
public function __construct(
|
||||||
protected InputBag $parameters;
|
protected string $task,
|
||||||
protected BufferedOutput $output;
|
protected InputBag $parameters,
|
||||||
|
protected BufferedOutput $output
|
||||||
public function __construct(string $task, InputBag $parameters, BufferedOutput $output)
|
) {
|
||||||
{
|
|
||||||
$this->task = $task;
|
|
||||||
$this->parameters = $parameters;
|
|
||||||
$this->output = $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTask(): string
|
public function getTask(): string
|
||||||
|
|
|
@ -6,7 +6,6 @@ use App\Core\Ab\AbContainer;
|
||||||
use App\Core\Ab\AbTest;
|
use App\Core\Ab\AbTest;
|
||||||
use App\Core\Entity\Site\Node;
|
use App\Core\Entity\Site\Node;
|
||||||
use App\Core\Event\Ab\AbTestEvent;
|
use App\Core\Event\Ab\AbTestEvent;
|
||||||
use App\Core\Repository\Site\NodeRepository;
|
|
||||||
use App\Core\Site\SiteRequest;
|
use App\Core\Site\SiteRequest;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Cookie;
|
use Symfony\Component\HttpFoundation\Cookie;
|
||||||
|
@ -21,19 +20,13 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
*/
|
*/
|
||||||
class AbListener
|
class AbListener
|
||||||
{
|
{
|
||||||
protected EventDispatcherInterface $eventDispatcher;
|
|
||||||
protected AbContainer $container;
|
|
||||||
protected SiteRequest $siteRequest;
|
|
||||||
protected ?Node $node;
|
protected ?Node $node;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AbContainer $container,
|
protected AbContainer $container,
|
||||||
EventDispatcherInterface $eventDispatcher,
|
protected EventDispatcherInterface $eventDispatcher,
|
||||||
SiteRequest $siteRequest
|
protected SiteRequest $siteRequest
|
||||||
) {
|
) {
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
|
||||||
$this->container = $container;
|
|
||||||
$this->siteRequest = $siteRequest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(RequestEvent $event)
|
public function onKernelRequest(RequestEvent $event)
|
||||||
|
@ -70,6 +63,16 @@ class AbListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
|
{
|
||||||
|
$cookies = $event->getRequest()->attributes->get('ab_test_cookies', []);
|
||||||
|
|
||||||
|
foreach ($cookies as $name => $value) {
|
||||||
|
$cookie = Cookie::create($name, $value['value'], time() + $value['duration']);
|
||||||
|
$event->getResponse()->headers->setCookie($cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function getCookieName(): string
|
protected function getCookieName(): string
|
||||||
{
|
{
|
||||||
return 'ab_test_'.$this->getAbTestCode();
|
return 'ab_test_'.$this->getAbTestCode();
|
||||||
|
@ -96,14 +99,4 @@ class AbListener
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelResponse(ResponseEvent $event)
|
|
||||||
{
|
|
||||||
$cookies = $event->getRequest()->attributes->get('ab_test_cookies', []);
|
|
||||||
|
|
||||||
foreach ($cookies as $name => $value) {
|
|
||||||
$cookie = Cookie::create($name, $value['value'], time() + $value['duration']);
|
|
||||||
$event->getResponse()->headers->setCookie($cookie);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,30 +23,18 @@ use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||||
*/
|
*/
|
||||||
class AnalyticListener
|
class AnalyticListener
|
||||||
{
|
{
|
||||||
protected NodeRepository $nodeRepository;
|
|
||||||
protected ViewRepositoryQuery $viewRepositoryQuery;
|
|
||||||
protected ViewFactory $viewFactory;
|
|
||||||
protected RefererRepositoryQuery $refererRepositoryQuery;
|
|
||||||
protected RefererFactory $refererFactory;
|
|
||||||
protected EntityManager $manager;
|
|
||||||
protected DeviceDetector $deviceDetector;
|
protected DeviceDetector $deviceDetector;
|
||||||
protected Request $request;
|
protected Request $request;
|
||||||
protected Node $node;
|
protected Node $node;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NodeRepository $nodeRepository,
|
protected NodeRepository $nodeRepository,
|
||||||
ViewRepositoryQuery $viewRepositoryQuery,
|
protected ViewRepositoryQuery $viewRepositoryQuery,
|
||||||
ViewFactory $viewFactory,
|
protected ViewFactory $viewFactory,
|
||||||
RefererRepositoryQuery $refererRepositoryQuery,
|
protected RefererRepositoryQuery $refererRepositoryQuery,
|
||||||
RefererFactory $refererFactory,
|
protected RefererFactory $refererFactory,
|
||||||
EntityManager $manager
|
protected EntityManager $manager
|
||||||
) {
|
) {
|
||||||
$this->nodeRepository = $nodeRepository;
|
|
||||||
$this->viewRepositoryQuery = $viewRepositoryQuery;
|
|
||||||
$this->viewFactory = $viewFactory;
|
|
||||||
$this->refererRepositoryQuery = $refererRepositoryQuery;
|
|
||||||
$this->refererFactory = $refererFactory;
|
|
||||||
$this->manager = $manager;
|
|
||||||
$this->createDeviceDetector();
|
$this->createDeviceDetector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
namespace App\Core\EventListener;
|
namespace App\Core\EventListener;
|
||||||
|
|
||||||
use App\Core\Repository\RedirectRepositoryQuery;
|
use App\Core\Repository\RedirectRepositoryQuery;
|
||||||
|
use App\Core\Router\RedirectBuilder;
|
||||||
use App\Core\Router\RedirectMatcher;
|
use App\Core\Router\RedirectMatcher;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
||||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use App\Core\Router\RedirectBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class RedirectListener.
|
* class RedirectListener.
|
||||||
|
@ -16,15 +15,11 @@ use App\Core\Router\RedirectBuilder;
|
||||||
*/
|
*/
|
||||||
class RedirectListener
|
class RedirectListener
|
||||||
{
|
{
|
||||||
protected RedirectMatcher $matcher;
|
public function __construct(
|
||||||
protected RedirectBuilder $builder;
|
protected RedirectMatcher $matcher,
|
||||||
protected RedirectRepositoryQuery $repository;
|
protected RedirectBuilder $builder,
|
||||||
|
protected RedirectRepositoryQuery $repository
|
||||||
public function __construct(RedirectMatcher $matcher, RedirectBuilder $builder, RedirectRepositoryQuery $repository)
|
) {
|
||||||
{
|
|
||||||
$this->matcher = $matcher;
|
|
||||||
$this->builder = $builder;
|
|
||||||
$this->repository = $repository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelException(ExceptionEvent $event)
|
public function onKernelException(ExceptionEvent $event)
|
||||||
|
@ -37,7 +32,7 @@ class RedirectListener
|
||||||
|
|
||||||
$redirects = $this->repository
|
$redirects = $this->repository
|
||||||
->orderBy('.sortOrder')
|
->orderBy('.sortOrder')
|
||||||
->where('.isEnabled=1')
|
->where('.isEnabled=true')
|
||||||
->find()
|
->find()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -17,24 +17,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
*/
|
*/
|
||||||
class PasswordRequestEventSubscriber implements EventSubscriberInterface
|
class PasswordRequestEventSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
protected MailNotifier $notifier;
|
|
||||||
protected UrlGeneratorInterface $urlGenerator;
|
|
||||||
protected EntityManager $entityManager;
|
|
||||||
protected TokenGeneratorInterface $tokenGenerator;
|
|
||||||
protected TranslatorInterface $translator;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
MailNotifier $notifier,
|
protected MailNotifier $notifier,
|
||||||
UrlGeneratorInterface $urlGenerator,
|
protected UrlGeneratorInterface $urlGenerator,
|
||||||
EntityManager $entityManager,
|
protected EntityManager $entityManager,
|
||||||
TokenGeneratorInterface $tokenGenerator,
|
protected TokenGeneratorInterface $tokenGenerator,
|
||||||
TranslatorInterface $translator
|
protected TranslatorInterface $translator
|
||||||
) {
|
) {
|
||||||
$this->notifier = $notifier;
|
|
||||||
$this->urlGenerator = $urlGenerator;
|
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->tokenGenerator = $tokenGenerator;
|
|
||||||
$this->translator = $translator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
|
|
|
@ -16,12 +16,12 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
*/
|
*/
|
||||||
class RequestSecurityEventSubscriber implements EventSubscriberInterface
|
class RequestSecurityEventSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
protected NodeRepository $nodeRepository;
|
|
||||||
protected AuthorizationChecker $authorizationChecker;
|
protected AuthorizationChecker $authorizationChecker;
|
||||||
|
|
||||||
public function __construct(NodeRepository $nodeRepository, ContainerInterface $container)
|
public function __construct(
|
||||||
{
|
protected NodeRepository $nodeRepository,
|
||||||
$this->nodeRepository = $nodeRepository;
|
ContainerInterface $container
|
||||||
|
) {
|
||||||
$this->authorizationChecker = $container->get('security.authorization_checker');
|
$this->authorizationChecker = $container->get('security.authorization_checker');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,15 @@ namespace App\Core\EventSubscriber\Site;
|
||||||
|
|
||||||
use App\Core\Site\SiteRequest;
|
use App\Core\Site\SiteRequest;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
|
||||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||||
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
use function Symfony\Component\String\u;
|
use function Symfony\Component\String\u;
|
||||||
|
|
||||||
class ForcedDomainEventSubscriber implements EventSubscriberInterface
|
class ForcedDomainEventSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
protected SiteRequest $siteRequest;
|
public function __construct(protected SiteRequest $siteRequest)
|
||||||
|
|
||||||
public function __construct(SiteRequest $siteRequest)
|
|
||||||
{
|
{
|
||||||
$this->siteRequest = $siteRequest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelResponse(ResponseEvent $event)
|
public function onKernelResponse(ResponseEvent $event)
|
||||||
|
@ -38,7 +35,8 @@ class ForcedDomainEventSubscriber implements EventSubscriberInterface
|
||||||
->replace(
|
->replace(
|
||||||
'://'.$this->siteRequest->getDomain(),
|
'://'.$this->siteRequest->getDomain(),
|
||||||
'://'.$navigation->getDomain()
|
'://'.$navigation->getDomain()
|
||||||
);
|
)
|
||||||
|
;
|
||||||
|
|
||||||
$event->getResponse()->headers->set('Location', $uri);
|
$event->getResponse()->headers->set('Location', $uri);
|
||||||
$event->getResponse()->setStatusCode(Response::HTTP_MOVED_PERMANENTLY);
|
$event->getResponse()->setStatusCode(Response::HTTP_MOVED_PERMANENTLY);
|
||||||
|
|
|
@ -20,27 +20,14 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
*/
|
*/
|
||||||
class MenuEventSubscriber extends EntityManagerEventSubscriber
|
class MenuEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
protected NodeFactory $nodeFactory;
|
|
||||||
protected NodeRepository $nodeRepository;
|
|
||||||
protected EntityManager $entityManager;
|
|
||||||
protected CodeSlugify $slugify;
|
|
||||||
protected SymfonyCacheManager $cacheManager;
|
|
||||||
protected TranslatorInterface $translation;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NodeFactory $nodeFactory,
|
protected NodeFactory $nodeFactory,
|
||||||
NodeRepository $nodeRepository,
|
protected NodeRepository $nodeRepository,
|
||||||
EntityManager $entityManager,
|
protected EntityManager $entityManager,
|
||||||
CodeSlugify $slugify,
|
protected CodeSlugify $slugify,
|
||||||
SymfonyCacheManager $cacheManager,
|
protected SymfonyCacheManager $cacheManager,
|
||||||
TranslatorInterface $translator
|
protected TranslatorInterface $translator
|
||||||
) {
|
) {
|
||||||
$this->nodeFactory = $nodeFactory;
|
|
||||||
$this->nodeRepository = $nodeRepository;
|
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->slugify = $slugify;
|
|
||||||
$this->cacheManager = $cacheManager;
|
|
||||||
$this->translator = $translator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(EntityInterface $entity): bool
|
public function supports(EntityInterface $entity): bool
|
||||||
|
|
|
@ -17,11 +17,9 @@ use App\Core\Slugify\CodeSlugify;
|
||||||
class NavigationEventSubscriber extends EntityManagerEventSubscriber
|
class NavigationEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManager $entityManager,
|
protected EntityManager $entityManager,
|
||||||
CodeSlugify $slugify
|
protected CodeSlugify $slugify
|
||||||
) {
|
) {
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->slugify = $slugify;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(EntityInterface $entity): bool
|
public function supports(EntityInterface $entity): bool
|
||||||
|
|
|
@ -12,7 +12,6 @@ use App\Core\Repository\Site\NodeRepository;
|
||||||
use App\Core\Slugify\CodeSlugify;
|
use App\Core\Slugify\CodeSlugify;
|
||||||
use App\Core\Slugify\RouteParameterSlugify;
|
use App\Core\Slugify\RouteParameterSlugify;
|
||||||
use App\Core\Slugify\Slugify;
|
use App\Core\Slugify\Slugify;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
|
||||||
use function Symfony\Component\String\u;
|
use function Symfony\Component\String\u;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,27 +21,14 @@ use function Symfony\Component\String\u;
|
||||||
*/
|
*/
|
||||||
class NodeEventSubscriber extends EntityManagerEventSubscriber
|
class NodeEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
protected NodeFactory $nodeFactory;
|
|
||||||
protected EntityManager $entityManager;
|
|
||||||
protected KernelInterface $kernel;
|
|
||||||
protected Slugify $slugify;
|
|
||||||
protected CodeSlugify $codeSlugify;
|
|
||||||
protected RouteParameterSlugify $routeParameterSlugify;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NodeFactory $nodeFactory,
|
protected NodeFactory $nodeFactory,
|
||||||
NodeRepository $nodeRepository,
|
protected NodeRepository $nodeRepository,
|
||||||
EntityManager $entityManager,
|
protected EntityManager $entityManager,
|
||||||
Slugify $slugify,
|
protected Slugify $slugify,
|
||||||
CodeSlugify $codeSlugify,
|
protected CodeSlugify $codeSlugify,
|
||||||
RouteParameterSlugify $routeParameterSlugify
|
protected RouteParameterSlugify $routeParameterSlugify
|
||||||
) {
|
) {
|
||||||
$this->nodeFactory = $nodeFactory;
|
|
||||||
$this->nodeRepository = $nodeRepository;
|
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->slugify = $slugify;
|
|
||||||
$this->codeSlugify = $codeSlugify;
|
|
||||||
$this->routeParameterSlugify = $routeParameterSlugify;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(EntityInterface $entity): bool
|
public function supports(EntityInterface $entity): bool
|
||||||
|
@ -63,7 +49,7 @@ class NodeEventSubscriber extends EntityManagerEventSubscriber
|
||||||
|
|
||||||
$node = $event->getEntity();
|
$node = $event->getEntity();
|
||||||
|
|
||||||
$node->setCode($this->codeSlugify->slugify($node->getCode()));
|
$node->setCode($this->codeSlugify->slugify($node->getCode() ?? ''));
|
||||||
|
|
||||||
if ($node->getDisableUrl()) {
|
if ($node->getDisableUrl()) {
|
||||||
$node->setUrl(null);
|
$node->setUrl(null);
|
||||||
|
|
|
@ -17,11 +17,8 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
*/
|
*/
|
||||||
class BlockEventSubscriber extends EntityManagerEventSubscriber
|
class BlockEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
protected FileUploadHandler $fileUpload;
|
public function __construct(protected FileUploadHandler $fileUpload)
|
||||||
|
|
||||||
public function __construct(FileUploadHandler $fileUpload)
|
|
||||||
{
|
{
|
||||||
$this->fileUpload = $fileUpload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(EntityInterface $entity): bool
|
public function supports(EntityInterface $entity): bool
|
||||||
|
|
|
@ -16,11 +16,8 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
*/
|
*/
|
||||||
class PageEventSubscriber extends EntityManagerEventSubscriber
|
class PageEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
protected FileUploadHandler $fileUpload;
|
public function __construct(protected FileUploadHandler $fileUpload)
|
||||||
|
|
||||||
public function __construct(FileUploadHandler $fileUpload)
|
|
||||||
{
|
{
|
||||||
$this->fileUpload = $fileUpload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(EntityInterface $entity): bool
|
public function supports(EntityInterface $entity): bool
|
||||||
|
|
|
@ -18,13 +18,10 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
*/
|
*/
|
||||||
class SiteEventSubscriber extends EntityManagerEventSubscriber
|
class SiteEventSubscriber extends EntityManagerEventSubscriber
|
||||||
{
|
{
|
||||||
protected KernelInterface $kernel;
|
public function __construct(
|
||||||
protected SymfonyCacheManager $cacheManager;
|
protected KernelInterface $kernel,
|
||||||
|
protected SymfonyCacheManager $cacheManager
|
||||||
public function __construct(KernelInterface $kernel, SymfonyCacheManager $cacheManager)
|
) {
|
||||||
{
|
|
||||||
$this->kernel = $kernel;
|
|
||||||
$this->cacheManager = $cacheManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(EntityInterface $entity): bool
|
public function supports(EntityInterface $entity): bool
|
||||||
|
|
|
@ -13,11 +13,8 @@ use App\Core\Event\Task\TaskRunRequestedEvent;
|
||||||
*/
|
*/
|
||||||
class CacheCleanTaskEventSubscriber extends TaskEventSubscriber
|
class CacheCleanTaskEventSubscriber extends TaskEventSubscriber
|
||||||
{
|
{
|
||||||
protected SymfonyCacheManager $cacheManager;
|
public function __construct(protected SymfonyCacheManager $cacheManager)
|
||||||
|
|
||||||
public function __construct(SymfonyCacheManager $cacheManager)
|
|
||||||
{
|
{
|
||||||
$this->cacheManager = $cacheManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onInit(TaskInitEvent $event)
|
public function onInit(TaskInitEvent $event)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Core\Factory;
|
namespace App\Core\Factory;
|
||||||
|
|
||||||
use App\Core\Factory\FactoryInterface;
|
|
||||||
use App\Core\Entity\Redirect as Entity;
|
use App\Core\Entity\Redirect as Entity;
|
||||||
|
|
||||||
class RedirectFactory implements FactoryInterface
|
class RedirectFactory implements FactoryInterface
|
||||||
|
|
|
@ -23,22 +23,15 @@ class FsFileManager
|
||||||
protected string $path;
|
protected string $path;
|
||||||
protected string $pathUri;
|
protected string $pathUri;
|
||||||
protected array $pathLocked;
|
protected array $pathLocked;
|
||||||
protected FileUploadHandler $uploadHandler;
|
|
||||||
protected FileInformationFactory $fileInformationFactory;
|
|
||||||
protected FileInformationRepositoryQuery $fileInformationRepositoryQuery;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ParameterBagInterface $params,
|
ParameterBagInterface $params,
|
||||||
FileUploadHandler $uploadHandler,
|
protected FileUploadHandler $uploadHandler,
|
||||||
FileInformationFactory $fileInformationFactory,
|
protected FileInformationFactory $fileInformationFactory,
|
||||||
FileInformationRepositoryQuery $fileInformationRepositoryQuery
|
protected FileInformationRepositoryQuery $fileInformationRepositoryQuery
|
||||||
) {
|
) {
|
||||||
$config = $params->get('core')['file_manager'];
|
$config = $params->get('core')['file_manager'];
|
||||||
|
|
||||||
$this->uploadHandler = $uploadHandler;
|
|
||||||
$this->fileInformationFactory = $fileInformationFactory;
|
|
||||||
$this->fileInformationRepositoryQuery = $fileInformationRepositoryQuery;
|
|
||||||
|
|
||||||
$this->mimes = $config['mimes'];
|
$this->mimes = $config['mimes'];
|
||||||
$this->path = $config['path'];
|
$this->path = $config['path'];
|
||||||
$this->pathUri = $this->normalizePath($config['path_uri']);
|
$this->pathUri = $this->normalizePath($config['path_uri']);
|
||||||
|
@ -91,12 +84,16 @@ class FsFileManager
|
||||||
$this->applySort($finder, $options['sort'] ?? 'name', $options['sort_direction'] ?? 'asc');
|
$this->applySort($finder, $options['sort'] ?? 'name', $options['sort_direction'] ?? 'asc');
|
||||||
|
|
||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
|
$splInfo = $this->getSplInfo($directory.'/'.$file->getBasename());
|
||||||
|
|
||||||
$data['files'][] = [
|
$data['files'][] = [
|
||||||
'basename' => $file->getBasename(),
|
'basename' => $file->getBasename(),
|
||||||
'path' => $directory,
|
'path' => $directory,
|
||||||
'webPath' => $this->pathUri.'/'.$directory.'/'.$file->getBasename(),
|
'webPath' => $this->pathUri.'/'.$directory.'/'.$file->getBasename(),
|
||||||
'locked' => $this->isLocked($directory.'/'.$file->getBasename()),
|
'locked' => $this->isLocked($directory.'/'.$file->getBasename()),
|
||||||
'mime' => mime_content_type($file->getRealPath()),
|
'mime' => mime_content_type($file->getRealPath()),
|
||||||
|
'size' => $splInfo ? $splInfo->getSize() : null,
|
||||||
|
'updated_at' => $splInfo ? date('Y-m-d H:i', $splInfo->getMTime()) : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,14 +294,16 @@ class FsFileManager
|
||||||
|
|
||||||
protected function applySort(Finder $finder, string $sort, string $direction)
|
protected function applySort(Finder $finder, string $sort, string $direction)
|
||||||
{
|
{
|
||||||
if ('name' === $sort) {
|
$sorts = [
|
||||||
$finder->sortByName();
|
'name' => 'sortByName',
|
||||||
} elseif ('modification_date' === $sort) {
|
'type' => 'sortByType',
|
||||||
$finder->sortByModifiedTime();
|
'updated_at' => 'sortByModifiedTime',
|
||||||
}
|
];
|
||||||
|
|
||||||
if ('desc' === $direction) {
|
if ('desc' === $direction) {
|
||||||
$finder->reverseSorting();
|
$finder->{$sorts[$sort]}()->reverseSorting();
|
||||||
|
} else {
|
||||||
|
$finder->{$sorts[$sort]}();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
||||||
|
|
||||||
class FilePickerType extends AbstractType
|
class FilePickerType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,15 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
*/
|
*/
|
||||||
class FileUploadHandler
|
class FileUploadHandler
|
||||||
{
|
{
|
||||||
|
protected $filenameGenerator;
|
||||||
|
|
||||||
|
public function setFilenameGenerator(callable $filenameGenerator): self
|
||||||
|
{
|
||||||
|
$this->filenameGenerator = $filenameGenerator;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function handleForm(?UploadedFile $uploadedFile, string $path, ?callable $afterUploadCallback = null, bool $keepOriginalFilename = false): void
|
public function handleForm(?UploadedFile $uploadedFile, string $path, ?callable $afterUploadCallback = null, bool $keepOriginalFilename = false): void
|
||||||
{
|
{
|
||||||
if (null === $uploadedFile) {
|
if (null === $uploadedFile) {
|
||||||
|
@ -21,9 +30,11 @@ class FileUploadHandler
|
||||||
|
|
||||||
if ($keepOriginalFilename) {
|
if ($keepOriginalFilename) {
|
||||||
$filename = $originalFilename.'.'.$uploadedFile->guessExtension();
|
$filename = $originalFilename.'.'.$uploadedFile->guessExtension();
|
||||||
} else {
|
} elseif (!is_callable($this->filenameGenerator)) {
|
||||||
$safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename);
|
$safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename);
|
||||||
$filename = date('Ymd-his').$safeFilename.'.'.$uploadedFile->guessExtension();
|
$filename = date('Ymd-his').$safeFilename.'.'.$uploadedFile->guessExtension();
|
||||||
|
} else {
|
||||||
|
$filename = call_user_func($this->filenameGenerator, $uploadedFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
$uploadedFile->move($path, $filename);
|
$uploadedFile->move($path, $filename);
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
|
|
||||||
namespace App\Core\Form\Filter;
|
namespace App\Core\Form\Filter;
|
||||||
|
|
||||||
use App\Core\Entity\Redirect;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
|
||||||
|
|
||||||
class RedirectFilterType extends AbstractType
|
class RedirectFilterType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,12 +4,12 @@ namespace App\Core\Form;
|
||||||
|
|
||||||
use App\Core\Entity\Redirect;
|
use App\Core\Entity\Redirect;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
||||||
|
|
||||||
class RedirectType extends AbstractType
|
class RedirectType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
class MenuType extends AbstractType
|
class MenuType extends AbstractType
|
||||||
|
@ -23,6 +24,7 @@ class MenuType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -37,6 +39,7 @@ class MenuType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
class NavigationAdditionalDomainType extends AbstractType
|
class NavigationAdditionalDomainType extends AbstractType
|
||||||
|
@ -24,6 +25,7 @@ class NavigationAdditionalDomainType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App\Core\Entity\Site\Navigation;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ColorType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
@ -26,6 +27,7 @@ class NavigationType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -38,6 +40,21 @@ class NavigationType extends AbstractType
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'attr' => [
|
'attr' => [
|
||||||
],
|
],
|
||||||
|
'constraints' => [
|
||||||
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$builder->add(
|
||||||
|
'color',
|
||||||
|
ColorType::class,
|
||||||
|
[
|
||||||
|
'label' => 'Color',
|
||||||
|
'required' => true,
|
||||||
|
'attr' => [
|
||||||
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
],
|
],
|
||||||
|
@ -54,6 +71,7 @@ class NavigationType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -94,7 +112,7 @@ class NavigationType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
new Length(['min' => 2, 'max' => 10]),
|
new Length(min: 2, max: 10),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
class NodeType extends AbstractType
|
class NodeType extends AbstractType
|
||||||
|
@ -29,6 +30,7 @@ class NodeType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -43,6 +45,7 @@ class NodeType extends AbstractType
|
||||||
'attr' => [
|
'attr' => [
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -82,6 +85,7 @@ class NodeType extends AbstractType
|
||||||
'attr' => [
|
'attr' => [
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -116,6 +120,9 @@ class NodeType extends AbstractType
|
||||||
|
|
||||||
return $choices;
|
return $choices;
|
||||||
}),
|
}),
|
||||||
|
'constraints' => [
|
||||||
|
new Length(max: 255),
|
||||||
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
32
src/core/Form/Site/Page/BuilderBlockType.php
Normal file
32
src/core/Form/Site/Page/BuilderBlockType.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Form\Site\Page;
|
||||||
|
|
||||||
|
use App\Core\Entity\Site\Page\BuilderBlock;
|
||||||
|
use App\Core\Form\Type\BuilderType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class BuilderBlockType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
|
{
|
||||||
|
$builder->add(
|
||||||
|
'value',
|
||||||
|
BuilderType::class,
|
||||||
|
array_merge([
|
||||||
|
'required' => false,
|
||||||
|
'label' => false,
|
||||||
|
], $options['options']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => BuilderBlock::class,
|
||||||
|
'options' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
namespace App\Core\Form\Site\Page;
|
namespace App\Core\Form\Site\Page;
|
||||||
|
|
||||||
|
use App\Core\Entity\Site\Page\Block;
|
||||||
use App\Core\Form\FileManager\FilePickerType;
|
use App\Core\Form\FileManager\FilePickerType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use App\Core\Entity\Site\Page\Block;
|
|
||||||
|
|
||||||
class FilePickerBlockType extends AbstractType
|
class FilePickerBlockType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,10 +6,10 @@ use App\Core\Entity\Site\Navigation;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
|
|
||||||
class PageFilterType extends AbstractType
|
class PageFilterType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Validator\Constraints\Image;
|
use Symfony\Component\Validator\Constraints\Image;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
|
||||||
class PageType extends AbstractType
|
class PageType extends AbstractType
|
||||||
|
@ -26,6 +27,7 @@ class PageType extends AbstractType
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
new NotBlank(),
|
new NotBlank(),
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -39,6 +41,7 @@ class PageType extends AbstractType
|
||||||
'attr' => [
|
'attr' => [
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -52,6 +55,7 @@ class PageType extends AbstractType
|
||||||
'attr' => [
|
'attr' => [
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -65,6 +69,7 @@ class PageType extends AbstractType
|
||||||
'attr' => [
|
'attr' => [
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -78,6 +83,7 @@ class PageType extends AbstractType
|
||||||
'attr' => [
|
'attr' => [
|
||||||
],
|
],
|
||||||
'constraints' => [
|
'constraints' => [
|
||||||
|
new Length(max: 255),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
38
src/core/Form/Type/BuilderType.php
Normal file
38
src/core/Form/Type/BuilderType.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType as BaseCollectionType;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
|
||||||
|
class BuilderType extends AbstractType
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||||
|
{
|
||||||
|
parent::buildView($view, $form, $options);
|
||||||
|
|
||||||
|
$view->vars = array_replace($view->vars, [
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
parent::configureOptions($resolver);
|
||||||
|
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'compound' => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBlockPrefix()
|
||||||
|
{
|
||||||
|
return 'builder';
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,10 @@ class CollectionType extends BaseCollectionType
|
||||||
'collection_name' => $options['collection_name'],
|
'collection_name' => $options['collection_name'],
|
||||||
'label_add' => $options['label_add'],
|
'label_add' => $options['label_add'],
|
||||||
'label_delete' => $options['label_delete'],
|
'label_delete' => $options['label_delete'],
|
||||||
|
'allow_add' => $options['allow_add'],
|
||||||
|
'allow_delete' => $options['allow_delete'],
|
||||||
|
'template_before_item' => $options['template_before_item'],
|
||||||
|
'template_after_item' => $options['template_after_item'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +35,8 @@ class CollectionType extends BaseCollectionType
|
||||||
'collection_name' => '',
|
'collection_name' => '',
|
||||||
'label_add' => 'Add',
|
'label_add' => 'Add',
|
||||||
'label_delete' => 'Delete',
|
'label_delete' => 'Delete',
|
||||||
|
'template_before_item' => null,
|
||||||
|
'template_after_item' => null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
97
src/core/Maker/MakeBuilderBlock.php
Normal file
97
src/core/Maker/MakeBuilderBlock.php
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Maker;
|
||||||
|
|
||||||
|
use Doctrine\Common\Annotations\Annotation;
|
||||||
|
use Symfony\Bundle\MakerBundle\ConsoleStyle;
|
||||||
|
use Symfony\Bundle\MakerBundle\DependencyBuilder;
|
||||||
|
use Symfony\Bundle\MakerBundle\Generator;
|
||||||
|
use Symfony\Bundle\MakerBundle\InputConfiguration;
|
||||||
|
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
|
||||||
|
use Symfony\Bundle\MakerBundle\Str;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Question\Question;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
||||||
|
class MakeBuilderBlock extends AbstractMaker
|
||||||
|
{
|
||||||
|
public static function getCommandName(): string
|
||||||
|
{
|
||||||
|
return 'make:builder-block';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCommandDescription(): string
|
||||||
|
{
|
||||||
|
return 'Creates a new builder block class';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureCommand(Command $command, InputConfiguration $inputConf)
|
||||||
|
{
|
||||||
|
$command
|
||||||
|
->addArgument(
|
||||||
|
'builder-block-class',
|
||||||
|
InputArgument::OPTIONAL,
|
||||||
|
'Choose a name for your block class (e.g. <fg=yellow>ExampleBlock</>)'
|
||||||
|
)
|
||||||
|
->setHelp('')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
|
||||||
|
{
|
||||||
|
$blockClassNameDetails = $generator->createClassNameDetails(
|
||||||
|
$input->getArgument('builder-block-class'),
|
||||||
|
'BuilderBlock\\',
|
||||||
|
'Block'
|
||||||
|
);
|
||||||
|
|
||||||
|
$templatePath = sprintf(
|
||||||
|
'builder_block/%s.html.twig',
|
||||||
|
Str::asSnakeCase(preg_replace('/Block$/', '', $blockClassNameDetails->getShortName()))
|
||||||
|
);
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
'entity' => $blockClassNameDetails->getFullName(),
|
||||||
|
'template' => $templatePath,
|
||||||
|
'label' => Str::asHumanWords($blockClassNameDetails->getShortName())
|
||||||
|
];
|
||||||
|
|
||||||
|
$blockPath = $generator->generateController(
|
||||||
|
$blockClassNameDetails->getFullName(),
|
||||||
|
__DIR__.'/../Resources/maker/builder/Block.tpl.php',
|
||||||
|
$options
|
||||||
|
);
|
||||||
|
|
||||||
|
$generator->writeChanges();
|
||||||
|
$realTemplatePath = 'templates/'.$templatePath;
|
||||||
|
|
||||||
|
$filesystem = new Filesystem();
|
||||||
|
|
||||||
|
if (!$filesystem->exists($templatePath)) {
|
||||||
|
$filesystem->mkdir(dirname($realTemplatePath));
|
||||||
|
$filesystem->dumpFile($realTemplatePath, $this->getTemplate());
|
||||||
|
|
||||||
|
$io->comment(sprintf('<fg=blue>created</>: %s', $realTemplatePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->writeSuccessMessage($io);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTemplate(): string
|
||||||
|
{
|
||||||
|
return <<< EOF
|
||||||
|
<div id="{{ id }}">
|
||||||
|
{% for item in children %}
|
||||||
|
{{ item|block_to_html(context) }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureDependencies(DependencyBuilder $dependencies)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use function Symfony\Component\String\u;
|
use function Symfony\Component\String\u;
|
||||||
|
|
||||||
class MakeCrudController extends AbstractMaker
|
class MakeCrudController extends AbstractMaker
|
||||||
|
@ -103,6 +104,17 @@ class MakeCrudController extends AbstractMaker
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$views = ['_form.html.twig', '_show.html.twig'];
|
||||||
|
$directory = sprintf('templates/admin/%s_admin/', $options['route']);
|
||||||
|
$filesystem = new Filesystem();
|
||||||
|
$filesystem->mkdir($directory);
|
||||||
|
foreach ($views as $view) {
|
||||||
|
$filesystem->dumpFile(
|
||||||
|
$directory.$view,
|
||||||
|
sprintf("{{ include('@Core/admin/crud/%s') }}\n", $view)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$generator->writeChanges();
|
$generator->writeChanges();
|
||||||
|
|
||||||
$this->writeSuccessMessage($io);
|
$this->writeSuccessMessage($io);
|
||||||
|
|
|
@ -11,7 +11,6 @@ use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use function Symfony\Component\String\u;
|
|
||||||
|
|
||||||
class MakeFactory extends AbstractMaker
|
class MakeFactory extends AbstractMaker
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,11 +8,11 @@ use Symfony\Bundle\MakerBundle\DependencyBuilder;
|
||||||
use Symfony\Bundle\MakerBundle\Generator;
|
use Symfony\Bundle\MakerBundle\Generator;
|
||||||
use Symfony\Bundle\MakerBundle\InputConfiguration;
|
use Symfony\Bundle\MakerBundle\InputConfiguration;
|
||||||
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
|
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
|
||||||
|
use Symfony\Bundle\MakerBundle\Str;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Question\Question;
|
use Symfony\Component\Console\Question\Question;
|
||||||
use Symfony\Bundle\MakerBundle\Str;
|
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
||||||
class MakePage extends AbstractMaker
|
class MakePage extends AbstractMaker
|
||||||
|
@ -92,7 +92,8 @@ class MakePage extends AbstractMaker
|
||||||
|
|
||||||
$this->writeSuccessMessage($io);
|
$this->writeSuccessMessage($io);
|
||||||
$io->text('Register the page in <comment>config/packages/app.yaml</comment>: ');
|
$io->text('Register the page in <comment>config/packages/app.yaml</comment>: ');
|
||||||
$io->text(<<< EOF
|
$io->text(
|
||||||
|
<<< EOF
|
||||||
|
|
||||||
core:
|
core:
|
||||||
site:
|
site:
|
||||||
|
@ -100,10 +101,18 @@ core:
|
||||||
{$pageClassNameDetails->getFullName()}:
|
{$pageClassNameDetails->getFullName()}:
|
||||||
name: {$pageClassNameDetails->getShortName()}
|
name: {$pageClassNameDetails->getShortName()}
|
||||||
templates:
|
templates:
|
||||||
- {name: "Default", file: "${templatePath}"}
|
- {name: "Default", file: "{$templatePath}"}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureDependencies(DependencyBuilder $dependencies)
|
||||||
|
{
|
||||||
|
$dependencies->addClassDependency(
|
||||||
|
Annotation::class,
|
||||||
|
'doctrine/annotations'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function askForNextBlock(ConsoleStyle $io, array $blocks, bool $isFirstField)
|
private function askForNextBlock(ConsoleStyle $io, array $blocks, bool $isFirstField)
|
||||||
|
@ -138,8 +147,9 @@ EOF
|
||||||
$types = [
|
$types = [
|
||||||
'text' => null,
|
'text' => null,
|
||||||
'textarea' => null,
|
'textarea' => null,
|
||||||
'choice' => null,
|
'choice' => 'BlockEntity\\ChoiceBlock::class',
|
||||||
'collection' => 'BlockEntity\\CollectionBlock::class',
|
'collection' => 'BlockEntity\\CollectionBlock::class',
|
||||||
|
'builder' => 'BlockEntity\\BuilderBlock::class',
|
||||||
'editor_js_textarea' => null,
|
'editor_js_textarea' => null,
|
||||||
'file' => 'BlockEntity\\FileBlock::class',
|
'file' => 'BlockEntity\\FileBlock::class',
|
||||||
'file_picker' => null,
|
'file_picker' => null,
|
||||||
|
@ -183,12 +193,4 @@ EOF
|
||||||
$io->writeln(sprintf(' * <comment>%s</comment>', $type));
|
$io->writeln(sprintf(' * <comment>%s</comment>', $type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureDependencies(DependencyBuilder $dependencies)
|
|
||||||
{
|
|
||||||
$dependencies->addClassDependency(
|
|
||||||
Annotation::class,
|
|
||||||
'doctrine/annotations'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace App\Core\Manager;
|
||||||
|
|
||||||
use App\Core\Entity\EntityInterface;
|
use App\Core\Entity\EntityInterface;
|
||||||
use App\Core\Event\EntityManager\EntityManagerEvent;
|
use App\Core\Event\EntityManager\EntityManagerEvent;
|
||||||
use Doctrine\ORM\EntityManager as DoctrineEntityManager;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
|
@ -15,23 +14,19 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
*/
|
*/
|
||||||
class EntityManager
|
class EntityManager
|
||||||
{
|
{
|
||||||
protected EventDispatcherInterface $eventDispatcher;
|
public function __construct(
|
||||||
|
protected EventDispatcherInterface $eventDispatcher,
|
||||||
protected DoctrineEntityManager $entityManager;
|
protected EntityManagerInterface $entityManager
|
||||||
|
) {
|
||||||
public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $entityManager)
|
|
||||||
{
|
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(EntityInterface $entity, bool $dispatchEvent = true): self
|
public function create(EntityInterface $entity, bool $dispatchEvent = true, bool $flush = true): self
|
||||||
{
|
{
|
||||||
if ($dispatchEvent) {
|
if ($dispatchEvent) {
|
||||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_CREATE_EVENT);
|
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_CREATE_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->persist($entity);
|
$this->persist($entity, $flush);
|
||||||
|
|
||||||
if ($dispatchEvent) {
|
if ($dispatchEvent) {
|
||||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::CREATE_EVENT);
|
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::CREATE_EVENT);
|
||||||
|
@ -40,13 +35,13 @@ class EntityManager
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(EntityInterface $entity, bool $dispatchEvent = true): self
|
public function update(EntityInterface $entity, bool $dispatchEvent = true, bool $flush = true): self
|
||||||
{
|
{
|
||||||
if ($dispatchEvent) {
|
if ($dispatchEvent) {
|
||||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_UPDATE_EVENT);
|
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_UPDATE_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->persist($entity);
|
$this->persist($entity, $flush);
|
||||||
|
|
||||||
if ($dispatchEvent) {
|
if ($dispatchEvent) {
|
||||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::UPDATE_EVENT);
|
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::UPDATE_EVENT);
|
||||||
|
@ -55,14 +50,17 @@ class EntityManager
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(EntityInterface $entity, bool $dispatchEvent = true): self
|
public function delete(EntityInterface $entity, bool $dispatchEvent = true, bool $flush = true): self
|
||||||
{
|
{
|
||||||
if ($dispatchEvent) {
|
if ($dispatchEvent) {
|
||||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_DELETE_EVENT);
|
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::PRE_DELETE_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->entityManager->remove($entity);
|
$this->entityManager->remove($entity);
|
||||||
$this->flush();
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->flush();
|
||||||
|
}
|
||||||
|
|
||||||
if ($dispatchEvent) {
|
if ($dispatchEvent) {
|
||||||
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::DELETE_EVENT);
|
$this->eventDispatcher->dispatch(new EntityManagerEvent($entity), EntityManagerEvent::DELETE_EVENT);
|
||||||
|
@ -90,9 +88,12 @@ class EntityManager
|
||||||
return $this->entityManager;
|
return $this->entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function persist(EntityInterface $entity)
|
protected function persist(EntityInterface $entity, bool $flush = true)
|
||||||
{
|
{
|
||||||
$this->entityManager->persist($entity);
|
$this->entityManager->persist($entity);
|
||||||
$this->flush();
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,13 @@ use App\Core\Entity\EntityInterface;
|
||||||
*/
|
*/
|
||||||
class TranslatableEntityManager extends EntityManager
|
class TranslatableEntityManager extends EntityManager
|
||||||
{
|
{
|
||||||
protected function persist(EntityInterface $entity)
|
protected function persist(EntityInterface $entity, bool $flush = true)
|
||||||
{
|
{
|
||||||
$this->entityManager->persist($entity);
|
$this->entityManager->persist($entity, $flush);
|
||||||
$entity->mergeNewTranslations();
|
$entity->mergeNewTranslations();
|
||||||
$this->flush();
|
|
||||||
|
if ($flush) {
|
||||||
|
$this->flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Core;
|
namespace App\Core;
|
||||||
|
|
||||||
if (!defined('MURPH_VERSION')) {
|
if (!defined('MURPH_VERSION')) {
|
||||||
define('MURPH_VERSION', 'v1.17.1');
|
define('MURPH_VERSION', 'v1.25.1');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
namespace App\Core\Notification;
|
namespace App\Core\Notification;
|
||||||
|
|
||||||
|
use App\Entity\User;
|
||||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||||
use Symfony\Component\Mailer\MailerInterface;
|
use Symfony\Component\Mailer\MailerInterface;
|
||||||
use Twig\Environment as TwigEnvironment;
|
use Twig\Environment as TwigEnvironment;
|
||||||
use App\Entity\User;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class MailNotifier.
|
* class MailNotifier.
|
||||||
|
@ -14,7 +14,6 @@ use App\Entity\User;
|
||||||
*/
|
*/
|
||||||
class MailNotifier
|
class MailNotifier
|
||||||
{
|
{
|
||||||
protected MailerInterface $mailer;
|
|
||||||
protected array $attachments = [];
|
protected array $attachments = [];
|
||||||
protected array $recipients = [];
|
protected array $recipients = [];
|
||||||
protected array $bccRecipients = [];
|
protected array $bccRecipients = [];
|
||||||
|
@ -22,10 +21,8 @@ class MailNotifier
|
||||||
protected ?string $from = null;
|
protected ?string $from = null;
|
||||||
protected ?string $replyTo = null;
|
protected ?string $replyTo = null;
|
||||||
|
|
||||||
public function __construct(TwigEnvironment $twig, MailerInterface $mailer)
|
public function __construct(protected MailerInterface $mailer)
|
||||||
{
|
{
|
||||||
$this->mailer = $mailer;
|
|
||||||
$this->twig = $twig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMailer(Swift_Mailer $mailer): self
|
public function setMailer(Swift_Mailer $mailer): self
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method Referer|null find($id, $lockMode = null, $lockVersion = null)
|
* @method null|Referer find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method Referer|null findOneBy(array $criteria, array $orderBy = null)
|
* @method null|Referer findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method Referer[] findAll()
|
* @method Referer[] findAll()
|
||||||
* @method Referer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method Referer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
namespace App\Core\Repository\Analytic;
|
namespace App\Core\Repository\Analytic;
|
||||||
|
|
||||||
use App\Core\Repository\Analytic\RefererRepository as Repository;
|
use App\Core\Repository\Analytic\RefererRepository as Repository;
|
||||||
|
use App\Core\Repository\RepositoryQuery;
|
||||||
use Knp\Component\Pager\PaginatorInterface;
|
use Knp\Component\Pager\PaginatorInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use App\Core\Repository\RepositoryQuery;
|
|
||||||
|
|
||||||
class RefererRepositoryQuery extends RepositoryQuery
|
class RefererRepositoryQuery extends RepositoryQuery
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method View|null find($id, $lockMode = null, $lockVersion = null)
|
* @method null|View find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method View|null findOneBy(array $criteria, array $orderBy = null)
|
* @method null|View findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method View[] findAll()
|
* @method View[] findAll()
|
||||||
* @method View[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method View[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
namespace App\Core\Repository\Analytic;
|
namespace App\Core\Repository\Analytic;
|
||||||
|
|
||||||
use App\Core\Repository\Analytic\ViewRepository as Repository;
|
use App\Core\Repository\Analytic\ViewRepository as Repository;
|
||||||
|
use App\Core\Repository\RepositoryQuery;
|
||||||
use Knp\Component\Pager\PaginatorInterface;
|
use Knp\Component\Pager\PaginatorInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use App\Core\Repository\RepositoryQuery;
|
|
||||||
|
|
||||||
class ViewRepositoryQuery extends RepositoryQuery
|
class ViewRepositoryQuery extends RepositoryQuery
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method FileInformation|null find($id, $lockMode = null, $lockVersion = null)
|
* @method null|FileInformation find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method FileInformation|null findOneBy(array $criteria, array $orderBy = null)
|
* @method null|FileInformation findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method FileInformation[] findAll()
|
* @method FileInformation[] findAll()
|
||||||
* @method FileInformation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method FileInformation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method NavigationSetting|null find($id, $lockMode = null, $lockVersion = null)
|
* @method null|NavigationSetting find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method NavigationSetting|null findOneBy(array $criteria, array $orderBy = null)
|
* @method null|NavigationSetting findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method NavigationSetting[] findAll()
|
* @method NavigationSetting[] findAll()
|
||||||
* @method NavigationSetting[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method NavigationSetting[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method Redirect|null find($id, $lockMode = null, $lockVersion = null)
|
* @method null|Redirect find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method Redirect|null findOneBy(array $criteria, array $orderBy = null)
|
* @method null|Redirect findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method Redirect[] findAll()
|
* @method Redirect[] findAll()
|
||||||
* @method Redirect[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method Redirect[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
namespace App\Core\Repository;
|
namespace App\Core\Repository;
|
||||||
|
|
||||||
use App\Core\Repository\RepositoryQuery;
|
|
||||||
use Knp\Component\Pager\PaginatorInterface;
|
|
||||||
use App\Core\Repository\RedirectRepository as Repository;
|
use App\Core\Repository\RedirectRepository as Repository;
|
||||||
|
use Knp\Component\Pager\PaginatorInterface;
|
||||||
|
|
||||||
class RedirectRepositoryQuery extends RepositoryQuery
|
class RedirectRepositoryQuery extends RepositoryQuery
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,6 +98,26 @@ abstract class RepositoryQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function count()
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->select(sprintf('COUNT(%s.id) as total', $this->id))
|
||||||
|
->query
|
||||||
|
->getQuery()
|
||||||
|
->setMaxResults(1)
|
||||||
|
->getOneOrNullResult()['total']
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addForcedFilterHandler(string $name): self
|
||||||
|
{
|
||||||
|
if (!in_array($name, $this->forcedFilterHandlers)) {
|
||||||
|
$this->forcedFilterHandlers[] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function populateDqlId(&$data)
|
protected function populateDqlId(&$data)
|
||||||
{
|
{
|
||||||
if (is_string($data)) {
|
if (is_string($data)) {
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method Setting|null find($id, $lockMode = null, $lockVersion = null)
|
* @method null|Setting find($id, $lockMode = null, $lockVersion = null)
|
||||||
* @method Setting|null findOneBy(array $criteria, array $orderBy = null)
|
* @method null|Setting findOneBy(array $criteria, array $orderBy = null)
|
||||||
* @method Setting[] findAll()
|
* @method Setting[] findAll()
|
||||||
* @method Setting[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
* @method Setting[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,9 +32,9 @@ class NodeRepository extends NestedTreeRepository
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->getQuery()
|
return null !== $query->getQuery()
|
||||||
->setMaxResults(1)
|
->setMaxResults(1)
|
||||||
->getOneOrNullResult() !== null
|
->getOneOrNullResult()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue