Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
phpstan:
php -d "memory_limit=-1" vendor/bin/phpstan analyse -c phpstan.neon
docker compose run --no-deps --rm --entrypoint= app php -d "memory_limit=-1" vendor/bin/phpstan analyse -c phpstan.neon

test:
vendor/bin/requirements-checker
vendor/bin/monorepo-builder validate
docker compose run --no-deps --rm --entrypoint= app vendor/bin/requirements-checker
docker compose run --no-deps --rm --entrypoint= app vendor/bin/monorepo-builder validate
make phpstan
XDEBUG_MODE=coverage vendor/bin/phpunit -v
php -d "memory_limit=-1" vendor/bin/php-cs-fixer fix --ansi -vvv
php -d "memory_limit=-1" bin/console lint:twig ./lib/Documents/src/Resources/views
php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizCoreBundle/templates
php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizFontBundle/templates
php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizRozierBundle/templates
php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizTwoFactorBundle/templates
php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizUserBundle/templates
php -d "memory_limit=-1" bin/console lint:twig ./lib/Rozier/src/Resources/views
docker compose run --no-deps --rm --entrypoint= app php -d "memory_limit=-1" bin/console lint:twig ./lib/Documents/src/Resources/views
docker compose run --no-deps --rm --entrypoint= app php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizCoreBundle/templates
docker compose run --no-deps --rm --entrypoint= app php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizRozierBundle/templates
docker compose run --no-deps --rm --entrypoint= app php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizTwoFactorBundle/templates
docker compose run --no-deps --rm --entrypoint= app php -d "memory_limit=-1" bin/console lint:twig ./lib/RoadizUserBundle/templates
docker compose run --no-deps --rm --entrypoint= app php -d "memory_limit=-1" bin/console lint:twig ./lib/Rozier/src/Resources/views
make phpunit

phpunit:
APP_ENV=test docker compose exec app php vendor/bin/phpunit -v
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-zip": "*",
"api-platform/core": "~3.3.11",
"api-platform/core": "~3.4.17",
"codercat/jwk-to-pem": "^1.0",
"composer/package-versions-deprecated": "1.11.99.3",
"doctrine/annotations": "^2.0",
Expand Down
3 changes: 3 additions & 0 deletions config/packages/roadiz_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ roadiz_core:

solr:
timeout: 3
search:
fuzzy_proximity: 2
fuzzy_min_term_length: 3
endpoints:
docker:
host: '%env(string:SOLR_HOST)%'
Expand Down
2 changes: 1 addition & 1 deletion lib/Documents/src/Console/DocumentSizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

private function updateDocumentSize(DocumentInterface $document): void
{
if (!($document instanceof SizeableInterface)) {
if (!$document instanceof SizeableInterface) {
return;
}
$mountPath = $document->getMountPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ public function getSearchFeed(string $searchTerm, ?string $author = null, int $m
}

return $this->downloadFeedFromAPI($url);
} else {
throw new APINeedsAuthentificationException('YoutubeEmbedFinder needs a Google server key, create a “google_server_id” setting.', 1);
}
throw new APINeedsAuthentificationException('YoutubeEmbedFinder needs a Google server key, create a “google_server_id” setting.', 1);
}

/**
Expand Down
44 changes: 17 additions & 27 deletions lib/Documents/src/Models/DocumentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public function getShortType(): string
{
if (null !== $this->getMimeType() && isset(static::$mimeToIcon[$this->getMimeType()])) {
return static::$mimeToIcon[$this->getMimeType()];
} else {
return 'unknown';
}

return 'unknown';
}

/**
Expand Down Expand Up @@ -233,38 +233,32 @@ public function isWebp(): bool
return 'image/webp' === $this->getMimeType();
}

#[
Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']),
Serializer\SerializedName('relativePath'),
]
#[Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']),
Serializer\SerializedName('relativePath'),]
public function getRelativePath(): ?string
{
if ($this->isLocal()) {
return $this->getFolder().'/'.$this->getFilename();
} else {
return null;
}

return null;
}

#[
Serializer\Groups(['document_mount']),
Serializer\SerializedName('mountPath'),
]
#[Serializer\Groups(['document_mount']),
Serializer\SerializedName('mountPath'),]
public function getMountPath(): ?string
{
if (null === $relativePath = $this->getRelativePath()) {
return null;
}
if ($this->isPrivate()) {
return 'private://'.$relativePath;
} else {
return 'public://'.$relativePath;
}

return 'public://'.$relativePath;
}

#[
Serializer\Ignore
]
#[Serializer\Ignore]
public function getMountFolderPath(): ?string
{
$folder = $this->getFolder();
Expand All @@ -273,9 +267,9 @@ public function getMountFolderPath(): ?string
}
if ($this->isPrivate()) {
return 'private://'.$folder;
} else {
return 'public://'.$folder;
}

return 'public://'.$folder;
}

/**
Expand All @@ -292,23 +286,19 @@ protected function initDocumentTrait(): void
$this->setFolder(DocumentFolderGenerator::generateFolderName());
}

#[
Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']),
#[Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']),
Serializer\SerializedName('processable'),
ApiProperty(
description: 'Document can be processed as an image for resampling and other image operations.',
writable: false,
)
]
)]
public function isProcessable(): bool
{
return $this->isImage() && in_array($this->getMimeType(), static::$processableMimeTypes, true);
}

#[
Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']),
Serializer\SerializedName('alt'),
]
#[Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']),
Serializer\SerializedName('alt'),]
public function getAlternativeText(): ?string
{
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/Documents/src/Renderer/ChainRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(array $renderers)
* @var RendererInterface $renderer
*/
foreach ($renderers as $renderer) {
if (!($renderer instanceof RendererInterface)) {
if (!$renderer instanceof RendererInterface) {
throw new \InvalidArgumentException('Document Renderer must implement RendererInterface');
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Documents/src/Renderer/EmbedRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public function supports(DocumentInterface $document, array $options): bool
&& true === $options['embed']
) {
return true;
} else {
return false;
}

return false;
}

public function render(DocumentInterface $document, array $options): string
Expand Down
4 changes: 2 additions & 2 deletions lib/Documents/src/SvgSizeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
/**
* @return array|null [$x, $y, $width, $height]
*/
protected function getViewBoxAttributes(): ?array
private function getViewBoxAttributes(): ?array
{
try {
$viewBox = $this->getSvgNodeAttributes()->getNamedItem('viewBox');
Expand All @@ -36,7 +36,7 @@ protected function getViewBoxAttributes(): ?array
return null;
}

protected function getIntegerAttribute(string $name): ?int
private function getIntegerAttribute(string $name): ?int
{
try {
$attribute = $this->getSvgNodeAttributes()->getNamedItem($name);
Expand Down
34 changes: 17 additions & 17 deletions lib/Documents/src/TwigExtension/DocumentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function getEmbedFinder(?DocumentInterface $document = null): ?EmbedFinde
if (null === $document) {
if ($this->throwExceptions) {
throw new RuntimeError('Document can’t be null to get its EmbedFinder.');
} else {
return null;
}

return null;
}

try {
Expand All @@ -84,9 +84,9 @@ public function getEmbedFinder(?DocumentInterface $document = null): ?EmbedFinde
} catch (InvalidEmbedId $embedException) {
if ($this->throwExceptions) {
throw new RuntimeError($embedException->getMessage());
} else {
return null;
}

return null;
}

return null;
Expand All @@ -100,9 +100,9 @@ public function display(?DocumentInterface $document = null, ?array $options = [
if (null === $document) {
if ($this->throwExceptions) {
throw new RuntimeError('Document can’t be null to be displayed.');
} else {
return '';
}

return '';
}
if (null === $options) {
$options = [];
Expand All @@ -112,9 +112,9 @@ public function display(?DocumentInterface $document = null, ?array $options = [
} catch (InvalidEmbedId $embedException) {
if ($this->throwExceptions) {
throw new RuntimeError($embedException->getMessage());
} else {
return '<p>'.$embedException->getMessage().'</p>';
}

return '<p>'.$embedException->getMessage().'</p>';
} catch (InvalidArgumentException $e) {
throw new RuntimeError($e->getMessage(), -1, null, $e);
}
Expand All @@ -134,9 +134,9 @@ public function getImageOrientation(?SizeableInterface $document = null): ?strin
if (null === $document) {
if ($this->throwExceptions) {
throw new RuntimeError('Document can’t be null to get its orientation.');
} else {
return null;
}

return null;
}
$size = $this->getImageSize($document);

Expand All @@ -153,12 +153,12 @@ public function getImageSize(?SizeableInterface $document = null): array
if (null === $document) {
if ($this->throwExceptions) {
throw new RuntimeError('Document can’t be null to get its size.');
} else {
return [
'width' => 0,
'height' => 0,
];
}

return [
'width' => 0,
'height' => 0,
];
}

return [
Expand All @@ -175,9 +175,9 @@ public function getImageRatio(?SizeableInterface $document = null): float
if (null === $document) {
if ($this->throwExceptions) {
throw new RuntimeError('Document can’t be null to get its ratio.');
} else {
return 0.0;
}

return 0.0;
}

if (null !== $document && null !== $ratio = $document->getImageRatio()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function getUrl(bool $absolute = false): string
$publicUrl = $this->documentsStorage->publicUrl($mountPath);
if ($absolute && \str_starts_with($publicUrl, '/')) {
return $this->urlHelper->getAbsoluteUrl($publicUrl);
} else {
return $publicUrl;
}

return $publicUrl;
}

return $this->getProcessedDocumentUrlByArray($absolute);
Expand Down
12 changes: 6 additions & 6 deletions lib/Documents/src/Viewers/SvgDocumentViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public function getContent(): string
{
if (false === $this->asObject) {
return $this->getInlineSvg();
} else {
return $this->getObjectSvg();
}

return $this->getObjectSvg();
}

protected function getAllowedAttributes(): array
private function getAllowedAttributes(): array
{
$attributes = [];
foreach ($this->attributes as $key => $value) {
Expand All @@ -63,7 +63,7 @@ protected function getAllowedAttributes(): array
/**
* @throws FilesystemException
*/
protected function getInlineSvg(): string
private function getInlineSvg(): string
{
$mountPath = $this->document->getMountPath();

Expand Down Expand Up @@ -95,7 +95,7 @@ protected function getInlineSvg(): string
/**
* @throws \Exception
*/
protected function injectAttributes(string $svg): string
private function injectAttributes(string $svg): string
{
$attributes = $this->getAllowedAttributes();
if (count($attributes) > 0) {
Expand Down Expand Up @@ -133,7 +133,7 @@ protected function injectAttributes(string $svg): string
/**
* @deprecated use SvgRenderer to render HTML object
*/
protected function getObjectSvg(): string
private function getObjectSvg(): string
{
$mountPath = $this->document->getMountPath();

Expand Down
Loading