Skip to content

Commit

Permalink
chore: Bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Oct 11, 2024
1 parent 1416315 commit c3006de
Show file tree
Hide file tree
Showing 183 changed files with 1,539 additions and 1,066 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/dev.php
/install.php
/clear_cache.php
/pimple.json
/assets
project_env.sh

Expand Down
5 changes: 5 additions & 0 deletions .travis/backoffice_assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -x
cd src || exit 1;
yarn install --pure-lockfile
yarn run install
yarn run build
4 changes: 4 additions & 0 deletions .travis/composer_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh -x
phpenv config-rm xdebug.ini;
curl -s http://getcomposer.org/installer | php;
php composer.phar install --dev --no-interaction;
5 changes: 5 additions & 0 deletions .travis/php_lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -x
vendor/bin/phpcs --report=full --report-file=./report.txt -p ./ || exit 1;
vendor/bin/phpstan analyse -c phpstan.neon || exit 1;
#vendor/bin/console lint:twig || exit 1;
#vendor/bin/console lint:twig src/Resources/views || exit 1;
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 © 2024 Ambroise Maupate, Julien Blanchet
Copyright © 2023 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.19.0",
"doctrine/orm": "~2.17.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.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/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/nodetype-contracts": "~1.1.2",
"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.*",
"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.*",
"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.3.*",
"roadiz/random": "2.3.*",
"roadiz/jwt": "2.3.*",
"roadiz/entity-generator": "2.2.*",
"roadiz/random": "2.2.*",
"roadiz/jwt": "2.2.*",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
Expand All @@ -95,8 +95,8 @@
},
"extra": {
"branch-alias": {
"dev-main": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
"dev-main": "2.2.x-dev",
"dev-develop": "2.3.x-dev"
}
}
}
7 changes: 3 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 6
paths:
- src
excludePaths:
Expand All @@ -9,8 +9,6 @@ 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 @@ -34,7 +32,8 @@ parameters:
- '#does not accept Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'

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

includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
Expand Down
3 changes: 2 additions & 1 deletion src/AjaxControllers/AjaxAttributeValuesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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 @@ -68,7 +69,7 @@ protected function updatePosition(array $parameters, AttributeValue $attributeVa
$attributable = $attributeValue->getAttributable();
$details = [
'%name%' => $attributeValue->getAttribute()->getLabelOrCode(),
'%nodeName%' => $attributable->getNodeName(),
'%nodeName%' => $attributable instanceof Node ? $attributable->getNodeName() : '',
];

if (!empty($parameters['afterAttributeValueId']) && is_numeric($parameters['afterAttributeValueId'])) {
Expand Down
26 changes: 8 additions & 18 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\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Exception\InvalidParameterException;
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 BadRequestHttpException('nodeTypeField is not a valid entity join.');
throw new InvalidParameterException('nodeTypeField is not a valid entity join.');
}

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

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

/** @var NodeTypeField|null $nodeTypeField */
/** @var NodeTypeField $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 @@ -117,25 +112,20 @@ public function indexAction(Request $request): JsonResponse
public function listAction(Request $request): JsonResponse
{
if (!$request->query->has('nodeTypeFieldId')) {
throw new BadRequestHttpException('nodeTypeFieldId parameter is missing.');
throw new InvalidParameterException('nodeTypeFieldId parameter is missing.');
}

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

$this->denyAccessUnlessGranted('ROLE_BACKEND_USER');

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

/** @var NodeTypeField|null $nodeTypeField */
/** @var NodeTypeField $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 @@ -173,7 +163,7 @@ public function listAction(Request $request): JsonResponse
* @param array $configuration
* @return array<array>
*/
private function normalizeEntities(iterable $entities, array $configuration): array
private function normalizeEntities(iterable $entities, array &$configuration): array
{
$entitiesArray = [];

Expand Down
34 changes: 14 additions & 20 deletions src/AjaxControllers/AjaxNodesExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
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\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\Security;
use Themes\Rozier\Models\NodeModel;
use Themes\Rozier\Models\NodeSourceModel;

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

foreach ($nodes as $node) {
if ($node instanceof SolrSearchResultItem) {
$item = $node->getItem();
if ($item instanceof NodesSources || $item instanceof Node) {
$this->normalizeItem($item, $nodesArray);
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();
}
}
} 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\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\Security;

class AjaxSearchNodesSourcesController extends AbstractAjaxController
{
Expand Down
Loading

0 comments on commit c3006de

Please sign in to comment.