Skip to content

Commit

Permalink
Merge branch hotfix/v2.3.19
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Jul 12, 2024
1 parent 59b1f66 commit d8bac91
Show file tree
Hide file tree
Showing 156 changed files with 981 additions and 1,376 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/dev.php
/install.php
/clear_cache.php
/pimple.json
/assets
project_env.sh

Expand Down
5 changes: 0 additions & 5 deletions .travis/backoffice_assets.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .travis/composer_install.sh

This file was deleted.

5 changes: 0 additions & 5 deletions .travis/php_lint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2023 Ambroise Maupate, Julien Blanchet
Copyright © 2024 Ambroise Maupate, Julien Blanchet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
58 changes: 29 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,48 @@
"role": "Frontend developer"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"ext-zip": "*",
"doctrine/orm": "~2.17.0",
"doctrine/orm": "~2.19.0",
"guzzlehttp/guzzle": "^7.2.0",
"jms/serializer": "^3.9.0",
"league/flysystem": "^3.0",
"pimple/pimple": "^3.3.1",
"ramsey/uuid": "^4.7",
"roadiz/compat-bundle": "2.2.*",
"roadiz/core-bundle": "2.2.*",
"roadiz/doc-generator": "2.2.*",
"roadiz/documents": "2.2.*",
"roadiz/dts-generator": "2.2.*",
"roadiz/markdown": "2.2.*",
"roadiz/models": "2.2.*",
"roadiz/compat-bundle": "2.3.*",
"roadiz/core-bundle": "2.3.*",
"roadiz/doc-generator": "2.3.*",
"roadiz/documents": "2.3.*",
"roadiz/dts-generator": "2.3.*",
"roadiz/markdown": "2.3.*",
"roadiz/models": "2.3.*",
"roadiz/nodetype-contracts": "~1.1.2",
"roadiz/openid": "2.2.*",
"roadiz/rozier-bundle": "2.2.*",
"symfony/asset": "5.4.*",
"symfony/filesystem": "5.4.*",
"symfony/form": "5.4.*",
"symfony/http-foundation": "5.4.*",
"symfony/http-kernel": "5.4.*",
"symfony/routing": "5.4.*",
"symfony/security-core": "5.4.*",
"symfony/security-csrf": "5.4.*",
"symfony/security-http": "5.4.*",
"symfony/translation": "5.4.*",
"symfony/validator": "5.4.*",
"symfony/workflow": "5.4.*",
"symfony/yaml": "5.4.*",
"roadiz/openid": "2.3.*",
"roadiz/rozier-bundle": "2.3.*",
"symfony/asset": "6.4.*",
"symfony/filesystem": "6.4.*",
"symfony/form": "6.4.*",
"symfony/http-foundation": "6.4.*",
"symfony/http-kernel": "6.4.*",
"symfony/routing": "6.4.*",
"symfony/security-core": "6.4.*",
"symfony/security-csrf": "6.4.*",
"symfony/security-http": "6.4.*",
"symfony/translation": "6.4.*",
"symfony/validator": "6.4.*",
"symfony/workflow": "6.4.*",
"symfony/yaml": "6.4.*",
"twig/twig": "^3.1"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.4",
"phpstan/phpstan": "^1.5.3",
"phpstan/phpstan-doctrine": "^1.3",
"roadiz/entity-generator": "2.2.*",
"roadiz/random": "2.2.*",
"roadiz/jwt": "2.2.*",
"roadiz/entity-generator": "2.3.*",
"roadiz/random": "2.3.*",
"roadiz/jwt": "2.3.*",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
Expand All @@ -95,8 +95,8 @@
},
"extra": {
"branch-alias": {
"dev-main": "2.2.x-dev",
"dev-develop": "2.3.x-dev"
"dev-main": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
}
}
}
7 changes: 4 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 6
level: 7
paths:
- src
excludePaths:
Expand All @@ -9,6 +9,8 @@ parameters:
doctrine:
repositoryClass: RZ\Roadiz\Core\Repositories\EntityRepository
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Call to an undefined method RZ\\Roadiz\\CoreBundle\\Repository#'
- '#Call to an undefined method RZ\\Roadiz\\UserBundle\\Repository#'
- '#Call to an undefined method Doctrine\\Persistence\\ObjectRepository#'
Expand All @@ -32,8 +34,7 @@ parameters:
- '#does not accept Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'

reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false

includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
Expand Down
3 changes: 1 addition & 2 deletions src/AjaxControllers/AjaxAttributeValuesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Themes\Rozier\AjaxControllers;

use RZ\Roadiz\CoreBundle\Entity\AttributeValue;
use RZ\Roadiz\CoreBundle\Entity\Node;
use RZ\Roadiz\CoreBundle\Security\Authorization\Voter\NodeVoter;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -69,7 +68,7 @@ protected function updatePosition(array $parameters, AttributeValue $attributeVa
$attributable = $attributeValue->getAttributable();
$details = [
'%name%' => $attributeValue->getAttribute()->getLabelOrCode(),
'%nodeName%' => $attributable instanceof Node ? $attributable->getNodeName() : '',
'%nodeName%' => $attributable->getNodeName(),
];

if (!empty($parameters['afterAttributeValueId']) && is_numeric($parameters['afterAttributeValueId'])) {
Expand Down
24 changes: 17 additions & 7 deletions src/AjaxControllers/AjaxEntitiesExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Yaml\Yaml;
use Themes\Rozier\Explorer\ConfigurableExplorerItem;
Expand Down Expand Up @@ -46,7 +46,7 @@ protected function getFieldConfiguration(NodeTypeField $nodeTypeField): array
$nodeTypeField->getType() !== AbstractField::MANY_TO_MANY_T &&
$nodeTypeField->getType() !== AbstractField::MANY_TO_ONE_T
) {
throw new InvalidParameterException('nodeTypeField is not a valid entity join.');
throw new BadRequestHttpException('nodeTypeField is not a valid entity join.');
}

$configs = [
Expand All @@ -63,11 +63,16 @@ public function indexAction(Request $request): JsonResponse
$this->denyAccessUnlessGranted('ROLE_BACKEND_USER');

if (!$request->query->has('nodeTypeFieldId')) {
throw new InvalidParameterException('nodeTypeFieldId parameter is missing.');
throw new BadRequestHttpException('nodeTypeFieldId parameter is missing.');
}

/** @var NodeTypeField $nodeTypeField */
/** @var NodeTypeField|null $nodeTypeField */
$nodeTypeField = $this->em()->find(NodeTypeField::class, $request->query->get('nodeTypeFieldId'));

if (null === $nodeTypeField) {
throw new BadRequestHttpException('nodeTypeField does not exist.');
}

$configuration = $this->getFieldConfiguration($nodeTypeField);
/** @var class-string<PersistableInterface> $className */
$className = $configuration['classname'];
Expand Down Expand Up @@ -112,20 +117,25 @@ public function indexAction(Request $request): JsonResponse
public function listAction(Request $request): JsonResponse
{
if (!$request->query->has('nodeTypeFieldId')) {
throw new InvalidParameterException('nodeTypeFieldId parameter is missing.');
throw new BadRequestHttpException('nodeTypeFieldId parameter is missing.');
}

if (!$request->query->has('ids')) {
throw new InvalidParameterException('Ids should be provided within an array');
throw new BadRequestHttpException('Ids should be provided within an array');
}

$this->denyAccessUnlessGranted('ROLE_BACKEND_USER');

/** @var EntityManager $em */
$em = $this->em();

/** @var NodeTypeField $nodeTypeField */
/** @var NodeTypeField|null $nodeTypeField */
$nodeTypeField = $this->em()->find(NodeTypeField::class, $request->query->get('nodeTypeFieldId'));

if (null === $nodeTypeField) {
throw new BadRequestHttpException('nodeTypeField does not exist.');
}

$configuration = $this->getFieldConfiguration($nodeTypeField);
/** @var class-string<PersistableInterface> $className */
$className = $configuration['classname'];
Expand Down
34 changes: 20 additions & 14 deletions src/AjaxControllers/AjaxNodesExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
use RZ\Roadiz\CoreBundle\EntityApi\NodeTypeApi;
use RZ\Roadiz\CoreBundle\SearchEngine\ClientRegistry;
use RZ\Roadiz\CoreBundle\SearchEngine\NodeSourceSearchHandlerInterface;
use RZ\Roadiz\CoreBundle\SearchEngine\SolrSearchResultItem;
use RZ\Roadiz\CoreBundle\Security\Authorization\Voter\NodeVoter;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security;
use Themes\Rozier\Models\NodeModel;
use Themes\Rozier\Models\NodeSourceModel;

Expand Down Expand Up @@ -184,7 +185,6 @@ protected function getSolrSearchResults(
$arrayFilter,
$this->getItemPerPage(),
true,
2,
(int) $currentPage
);
$pageCount = ceil($results->getResultCount() / $this->getItemPerPage());
Expand Down Expand Up @@ -250,32 +250,38 @@ public function listAction(Request $request): JsonResponse
/**
* Normalize response Node list result.
*
* @param iterable<Node|NodesSources> $nodes
* @param iterable<Node|NodesSources|SolrSearchResultItem> $nodes
* @return array
*/
private function normalizeNodes(iterable $nodes): array
{
$nodesArray = [];

foreach ($nodes as $node) {
if (null !== $node) {
if ($node instanceof NodesSources) {
if (!key_exists($node->getNode()->getId(), $nodesArray)) {
$nodeModel = new NodeSourceModel($node, $this->urlGenerator, $this->security);
$nodesArray[$node->getNode()->getId()] = $nodeModel->toArray();
}
} else {
if (!key_exists($node->getId(), $nodesArray)) {
$nodeModel = new NodeModel($node, $this->urlGenerator, $this->security);
$nodesArray[$node->getId()] = $nodeModel->toArray();
}
if ($node instanceof SolrSearchResultItem) {
$item = $node->getItem();
if ($item instanceof NodesSources || $item instanceof Node) {
$this->normalizeItem($item, $nodesArray);
}
} else {
$this->normalizeItem($node, $nodesArray);
}
}

return array_values($nodesArray);
}

private function normalizeItem(NodesSources|Node $item, array &$nodesArray): void
{
if ($item instanceof NodesSources && !key_exists($item->getNode()->getId(), $nodesArray)) {
$nodeSourceModel = new NodeSourceModel($item, $this->urlGenerator, $this->security);
$nodesArray[$item->getNode()->getId()] = $nodeSourceModel->toArray();
} elseif ($item instanceof Node && !key_exists($item->getId(), $nodesArray)) {
$nodeModel = new NodeModel($item, $this->urlGenerator, $this->security);
$nodesArray[$item->getId()] = $nodeModel->toArray();
}
}

/**
* @param array $data
* @return JsonResponse
Expand Down
2 changes: 1 addition & 1 deletion src/AjaxControllers/AjaxSearchNodesSourcesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security;

class AjaxSearchNodesSourcesController extends AbstractAjaxController
{
Expand Down
Loading

0 comments on commit d8bac91

Please sign in to comment.