Skip to content

Commit

Permalink
Merge branch 'hotfix/v2.1.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Jun 20, 2023
2 parents 4e0f81b + 1814a33 commit 0bfc469
Show file tree
Hide file tree
Showing 28 changed files with 256 additions and 197 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [v2.1.17](https://github.com/roadiz/core-bundle-dev-app/compare/v2.1.16...v2.1.17) (2023-06-20)


### Features

* Added Roadiz custom data-collector for web-profiler ([d0e01fa](https://github.com/roadiz/core-bundle-dev-app/commit/d0e01fa885b462a8dc46fb7ef04892c840452a7e))


### Bug Fixes

* **UI:** Changed user and menu panels size for LG breakpoint. Clear `cache.global_clearer` in CacheController and SchemaUpdater. ([c20463e](https://github.com/roadiz/core-bundle-dev-app/commit/c20463eb2e14b8c1977a6eabe12a9380a816f37b))
* `UpdateNodeTypeSchemaMessage` should be handled synced to avoid Doctrine exception on refresh ([84a611b](https://github.com/roadiz/core-bundle-dev-app/commit/84a611b17837c58d219c6f822c132b034b4420af))

## [v2.1.16](https://github.com/roadiz/core-bundle-dev-app/compare/v2.1.15...v2.1.16) (2023-06-01)


Expand Down
17 changes: 15 additions & 2 deletions lib/RoadizCoreBundle/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
parameters:
roadiz_core.cms_version: '2.1.17'
roadiz_core.cms_version_prefix: 'main'
env(APP_NAMESPACE): "roadiz"
env(APP_VERSION): "0.1.0"
env(APP_USE_ACCEPT_LANGUAGE_HEADER): 'false'
Expand All @@ -22,9 +24,9 @@ services:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
$cmsVersion: '2.1.16'
$cmsVersion: '%roadiz_core.cms_version%'
$appVersion: '%roadiz_core.app_version%'
$cmsVersionPrefix: 'main'
$cmsVersionPrefix: '%roadiz_core.cms_version_prefix%'
$staticDomain: '%roadiz_core.static_domain_name%'
$hideRoadizVersion: '%roadiz_core.hide_roadiz_version%'
$inheritanceType: '%roadiz_core.inheritance_type%'
Expand Down Expand Up @@ -140,6 +142,16 @@ services:
decorates: 'api_platform.serializer.normalizer.item'
decoration_priority: 21

RZ\Roadiz\CoreBundle\DataCollector\RequestDataCollector:
autoconfigure: false
arguments: [ '%roadiz_core.cms_version%', '%roadiz_core.cms_version_prefix%']
tags:
- name: data_collector
template: '@RoadizCore/DataCollector/request.html.twig'
# must match the value returned by the getName() method
id: 'roadiz.data_collector.request'
priority: 400

# Document
RZ\Roadiz\CoreBundle\Serializer\Normalizer\DocumentNormalizer:
# By default, .inner is passed as argument
Expand Down Expand Up @@ -325,6 +337,7 @@ services:
- { name: doctrine.event_subscriber }

RZ\Roadiz\CoreBundle\Doctrine\SchemaUpdater:
arguments: ['@cache.global_clearer']
tags:
- { name: monolog.logger, channel: doctrine }

Expand Down
71 changes: 71 additions & 0 deletions lib/RoadizCoreBundle/src/DataCollector/RequestDataCollector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\CoreBundle\DataCollector;

use PackageVersions\Versions;
use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

final class RequestDataCollector extends AbstractDataCollector
{
private ?string $cmsVersion = null;
private ?string $cmsVersionPrefix = null;

public function __construct(string $cmsVersion, string $cmsVersionPrefix)
{
$this->cmsVersion = $cmsVersion;
$this->cmsVersionPrefix = $cmsVersionPrefix;
}

/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Throwable $exception = null): void
{
$this->data = [];
}

public function getVersion(): ?string
{
$fallback = implode(' - ', array_filter([$this->cmsVersionPrefix, $this->cmsVersion]));
if (!class_exists(Versions::class)) {
return $fallback;
}

$version = Versions::getVersion('roadiz/core-bundle');
preg_match('/^v(.*?)@/', $version, $output);

return $output[1] ?? strtok($version, '@') ?: $fallback;
}

public static function getTemplate(): ?string
{
return '@RoadizCore/DataCollector/request.html.twig';
}

public function getMethod()
{
return $this->data['method'];
}

public function getAcceptableContentTypes()
{
return $this->data['acceptable_content_types'];
}

/**
* {@inheritdoc}
*/
public function getName(): string
{
return 'roadiz.data_collector.request';
}

public function reset(): void
{
$this->data = [];
}
}
5 changes: 5 additions & 0 deletions lib/RoadizCoreBundle/src/Doctrine/SchemaUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,32 @@

use Psr\Log\LoggerInterface;
use RZ\Roadiz\CoreBundle\Cache\Clearer\OPCacheClearer;
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
use Symfony\Component\Process\Process;

final class SchemaUpdater
{
private LoggerInterface $logger;
private OPCacheClearer $opCacheClearer;
private string $projectDir;
private CacheClearerInterface $cacheClearer;

public function __construct(
CacheClearerInterface $cacheClearer,
OPCacheClearer $opCacheClearer,
LoggerInterface $logger,
string $projectDir
) {
$this->logger = $logger;
$this->opCacheClearer = $opCacheClearer;
$this->projectDir = $projectDir;
$this->cacheClearer = $cacheClearer;
}

public function clearMetadata(): void
{
$this->opCacheClearer->clear();
$this->cacheClearer->clear('');

$process = $this->runCommand(
'doctrine:cache:clear-metadata',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

namespace RZ\Roadiz\CoreBundle\Message;

final class UpdateNodeTypeSchemaMessage implements AsyncMessage
/*
* UpdateNodeTypeSchemaMessage must be handled synchronous
*/
final class UpdateNodeTypeSchemaMessage
{
private int $nodeTypeId;

Expand Down
18 changes: 18 additions & 0 deletions lib/RoadizCoreBundle/templates/DataCollector/request.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
{% set icon %}
{{ include('@RoadizCore/DataCollector/roadiz-icon.svg') }}
{% endset %}

{% set text %}
<div class="sf-toolbar-info-piece">
<b>Roadiz CMS</b>
{% if collector.version %}
<span>{{ collector.version }}</span>
{% endif %}
</div>
{% endset %}

{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': false }) }}
{% endblock %}
23 changes: 23 additions & 0 deletions lib/RoadizCoreBundle/templates/DataCollector/roadiz-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions lib/RoadizRozierBundle/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ services:

RZ\Roadiz\RozierBundle\Controller\PingController:
arguments: ['@?profiler']

Themes\Rozier\Controllers\CacheController:
arguments: ['@cache.global_clearer']
53 changes: 8 additions & 45 deletions lib/Rozier/src/Controllers/CacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,35 @@
use Psr\Log\LoggerInterface;
use RZ\Roadiz\CoreBundle\Event\Cache\CachePurgeRequestEvent;
use RZ\Roadiz\Documents\Events\CachePurgeAssetsRequestEvent;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
use Themes\Rozier\RozierApp;

/**
* @package Themes\Rozier\Controllers
*/
class CacheController extends RozierApp
final class CacheController extends RozierApp
{
private LoggerInterface $logger;
private CacheClearerInterface $cacheClearer;

/**
* @param LoggerInterface $logger
*/
public function __construct(
CacheClearerInterface $cacheClearer,
LoggerInterface $logger
) {
$this->logger = $logger;
$this->cacheClearer = $cacheClearer;
}

public function deleteDoctrineCache(Request $request): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_DOCTRINE_CACHE_DELETE');

$form = $this->buildDeleteDoctrineForm();
$form = $this->createFormBuilder()->getForm();
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$event = new CachePurgeRequestEvent();
$this->dispatchEvent($event);
$this->cacheClearer->clear('');

$msg = $this->getTranslator()->trans('cache.deleted');
$this->publishConfirmMessage($request, $msg);
Expand All @@ -57,34 +55,9 @@ public function deleteDoctrineCache(Request $request): Response

$this->assignation['form'] = $form->createView();

$this->assignation['cachesInfo'] = [
'resultCache' => $this->em()->getConfiguration()->getResultCacheImpl(),
'hydratationCache' => $this->em()->getConfiguration()->getHydrationCacheImpl(),
'queryCache' => $this->em()->getConfiguration()->getQueryCacheImpl(),
'metadataCache' => $this->em()->getConfiguration()->getMetadataCacheImpl(),
];

foreach ($this->assignation['cachesInfo'] as $key => $value) {
if (null !== $value) {
$this->assignation['cachesInfo'][$key] = get_class($value);
} else {
$this->assignation['cachesInfo'][$key] = false;
}
}

return $this->render('@RoadizRozier/cache/deleteDoctrine.html.twig', $this->assignation);
}

/**
* @return FormInterface
*/
private function buildDeleteDoctrineForm(): FormInterface
{
$builder = $this->createFormBuilder();

return $builder->getForm();
}

/**
* @param Request $request
*
Expand All @@ -95,7 +68,7 @@ public function deleteAssetsCache(Request $request): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_DOCTRINE_CACHE_DELETE');

$form = $this->buildDeleteAssetsForm();
$form = $this->createFormBuilder()->getForm();
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
Expand All @@ -113,14 +86,4 @@ public function deleteAssetsCache(Request $request): Response

return $this->render('@RoadizRozier/cache/deleteAssets.html.twig', $this->assignation);
}

/**
* @return FormInterface
*/
private function buildDeleteAssetsForm(): FormInterface
{
$builder = $this->createFormBuilder();

return $builder->getForm();
}
}
16 changes: 4 additions & 12 deletions lib/Rozier/src/Controllers/NodeTypes/NodeTypesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ public function __construct(MessageBusInterface $messageBus)
$this->messageBus = $messageBus;
}

/**
* List every node-types.
*
* @param Request $request
*
* @return Response
*/
public function indexAction(Request $request)
public function indexAction(Request $request): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODETYPES');
/*
Expand Down Expand Up @@ -72,7 +65,7 @@ public function indexAction(Request $request)
*
* @return Response
*/
public function editAction(Request $request, int $nodeTypeId)
public function editAction(Request $request, int $nodeTypeId): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODETYPES');

Expand Down Expand Up @@ -116,10 +109,9 @@ public function editAction(Request $request, int $nodeTypeId)
*
* @return Response
*/
public function addAction(Request $request)
public function addAction(Request $request): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODETYPES');

$nodeType = new NodeType();

$form = $this->createForm(NodeTypeType::class, $nodeType);
Expand Down Expand Up @@ -155,7 +147,7 @@ public function addAction(Request $request)
*
* @return Response
*/
public function deleteAction(Request $request, int $nodeTypeId)
public function deleteAction(Request $request, int $nodeTypeId): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODETYPES_DELETE');

Expand Down
2 changes: 1 addition & 1 deletion lib/Rozier/src/Resources/app/less/base/elements.less
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
}

.touch-scroll(){
-webkit-overflow-scrolling: touch;
--webkit-overflow-scrolling: touch;
}

.clearfloat() {
Expand Down
Loading

0 comments on commit 0bfc469

Please sign in to comment.