Skip to content

Commit

Permalink
Merge branch hotfix/v2.3.18
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Jul 5, 2024
1 parent af2a1e0 commit b706ee1
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.0', '8.1']
php-version: ['8.1', '8.2', '8.3']
steps:
- uses: shivammathur/setup-php@v2
with:
Expand Down
14 changes: 0 additions & 14 deletions .travis.yml

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
Copyright © 2024 Ambroise Maupate

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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Roadiz Font bundle
**Manage and expose web fonts with Roadiz CMS**

![Run test status](https://github.com/roadiz/font-bundle/actions/workflows/run-test.yml/badge.svg?branch=develop)

Expand Down
62 changes: 33 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "roadiz/font-bundle",
"description": "Manage and expose web fonts with Roadiz CMS",
"license": "MIT",
"keywords": [
"cms",
"backoffice",
"roadiz",
"rezo zero"
],
"authors": [
Expand All @@ -15,32 +17,34 @@
}
],
"type": "symfony-bundle",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.0",
"php": ">=8.1",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.8.1",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "<2.17",
"doctrine/orm": "~2.19.0",
"jms/serializer": "^3.9.0",
"league/flysystem": "^3.0",
"roadiz/models": "2.1.*",
"roadiz/rozier": "2.1.*",
"roadiz/models": "2.3.*",
"roadiz/rozier": "2.3.*",
"sensio/framework-extra-bundle": "^6.1",
"symfony/asset": "5.4.*",
"symfony/cache": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/expression-language": "5.4.*",
"symfony/form": "5.4.*",
"symfony/framework-bundle": "5.4.*",
"symfony/http-client": "5.4.*",
"symfony/intl": "5.4.*",
"symfony/runtime": "5.4.*",
"symfony/string": "5.4.*",
"symfony/translation": "5.4.*",
"symfony/twig-bundle": "5.4.*",
"symfony/validator": "5.4.*",
"symfony/yaml": "5.4.*",
"twig/extra-bundle": "^2.12|^3.0",
"symfony/asset": "6.4.*",
"symfony/cache": "6.4.*",
"symfony/dotenv": "6.4.*",
"symfony/expression-language": "6.4.*",
"symfony/form": "6.4.*",
"symfony/framework-bundle": "6.4.*",
"symfony/http-client": "6.4.*",
"symfony/intl": "6.4.*",
"symfony/runtime": "6.4.*",
"symfony/string": "6.4.*",
"symfony/translation": "6.4.*",
"symfony/twig-bundle": "6.4.*",
"symfony/validator": "6.4.*",
"symfony/yaml": "6.4.*",
"twig/extra-bundle": "^3.0",
"twig/intl-extra": "*",
"twig/string-extra": "*",
"twig/twig": "^3.1"
Expand All @@ -51,14 +55,14 @@
"phpstan/phpstan-doctrine": "^1.3",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5",
"symfony/browser-kit": "5.4.*",
"symfony/phpunit-bridge": "5.4.*",
"symfony/stopwatch": "5.4.*",
"roadiz/core-bundle": "2.1.*",
"roadiz/compat-bundle": "2.1.*",
"roadiz/rozier-bundle": "2.1.*",
"roadiz/documents": "2.1.*",
"roadiz/entity-generator": "2.1.*"
"symfony/browser-kit": "6.4.*",
"symfony/phpunit-bridge": "^7.0",
"symfony/stopwatch": "6.4.*",
"roadiz/core-bundle": "2.3.*",
"roadiz/compat-bundle": "2.3.*",
"roadiz/rozier-bundle": "2.3.*",
"roadiz/documents": "2.3.*",
"roadiz/entity-generator": "2.3.*"
},
"config": {
"optimize-autoloader": true,
Expand All @@ -85,8 +89,8 @@
},
"extra": {
"branch-alias": {
"dev-main": "2.1.x-dev",
"dev-develop": "2.2.x-dev"
"dev-main": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
}
}
}
36 changes: 36 additions & 0 deletions migrations/Version20230607134442.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\FontBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230607134442 extends AbstractMigration
{
public function getDescription(): string
{
return 'Set font filenames to 100 chars max.';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE fonts CHANGE eot_filename eot_filename VARCHAR(100) DEFAULT NULL, CHANGE woff_filename woff_filename VARCHAR(100) DEFAULT NULL, CHANGE woff2_filename woff2_filename VARCHAR(100) DEFAULT NULL, CHANGE otf_filename otf_filename VARCHAR(100) DEFAULT NULL, CHANGE svg_filename svg_filename VARCHAR(100) DEFAULT NULL, CHANGE name name VARCHAR(100) NOT NULL, CHANGE hash hash VARCHAR(128) NOT NULL, CHANGE folder folder VARCHAR(100) NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE fonts CHANGE eot_filename eot_filename VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE woff_filename woff_filename VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE woff2_filename woff2_filename VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE otf_filename otf_filename VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE svg_filename svg_filename VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE name name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE hash hash VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE folder folder VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
}

public function isTransactional(): bool
{
return false;
}
}
33 changes: 33 additions & 0 deletions migrations/Version20230828092912.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\FontBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230828092912 extends AbstractMigration
{
public function getDescription(): string
{
return 'Fixed Font inherited indexes.';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE INDEX font_created_at ON fonts (created_at)');
$this->addSql('CREATE INDEX font_updated_at ON fonts (updated_at)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX font_created_at ON fonts');
$this->addSql('DROP INDEX font_updated_at ON fonts');
}
}
8 changes: 5 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
parameters:
level: 5
level: 7
paths:
- src
excludePaths:
- */node_modules/*
- */bower_components/*
- */static/*
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 @@ -26,9 +28,9 @@ parameters:
- '#Doctrine\\ORM\\Mapping\\GeneratedValue constructor expects#'
- '#type mapping mismatch: property can contain Doctrine\\Common\\Collections\\Collection<int, [^\>]+> but database expects Doctrine\\Common\\Collections\\Collection&iterable<[^\>]+>#'
- '#should return Doctrine\\Common\\Collections\\Collection<int, [^\>]+Interface> but returns Doctrine\\Common\\Collections\\Collection<int, [^\>]+>#'
- '#but returns Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'
- '#does not accept Doctrine\\Common\\Collections\\ReadableCollection<int, [^\>]+>#'

reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
3 changes: 3 additions & 0 deletions src/Controller/Admin/FontsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public function downloadAction(Request $request, int $id): BinaryFileResponse
if ($font !== null) {
// Prepare File
$file = tempnam(sys_get_temp_dir(), "font_" . $font->getId());
if (false === $file) {
throw new \RuntimeException('Cannot create temporary file.');
}
$zip = new \ZipArchive();
$zip->open($file, \ZipArchive::CREATE);

Expand Down
15 changes: 7 additions & 8 deletions src/Controller/FontFaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function fontFileAction(Request $request, string $filename, int $variant,
if (null !== $font) {
[$fontData, $mime] = $this->getFontData($font, $extension);

if (null !== $fontData) {
if (\is_string($fontData)) {
$response = new Response(
'',
Response::HTTP_NOT_MODIFIED,
Expand All @@ -104,7 +104,7 @@ public function fontFileAction(Request $request, string $filename, int $variant,
if (!$response->isNotModified($request)) {
$response->setContent($fontData);
$response->setStatusCode(Response::HTTP_OK);
$response->setEtag(md5($response->getContent()));
$response->setEtag(md5($fontData));
}

return $response;
Expand Down Expand Up @@ -164,13 +164,12 @@ public function fontFacesAction(Request $request): Response
'variantHash' => $variantHash,
];
}
$response->setContent(
$this->templating->render(
'@RoadizFont/fonts/fontfamily.css.twig',
$assignation
)
$content = $this->templating->render(
'@RoadizFont/fonts/fontfamily.css.twig',
$assignation
);
$response->setEtag(md5($response->getContent()));
$response->setContent($content);
$response->setEtag(md5($content));
$response->setStatusCode(Response::HTTP_OK);

return $response;
Expand Down
25 changes: 17 additions & 8 deletions src/Entity/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
ORM\Entity(repositoryClass: FontRepository::class),
ORM\Table(name: "fonts"),
ORM\UniqueConstraint(columns: ["name", "variant"]),
ORM\Index(columns: ["created_at"], name: "font_created_at"),
ORM\Index(columns: ["updated_at"], name: "font_updated_at"),
UniqueEntity(fields: ["name", "variant"])
]
class Font extends AbstractDateTimed
Expand Down Expand Up @@ -86,31 +88,38 @@ class Font extends AbstractDateTimed
protected ?UploadedFile $otfFile = null;
protected ?UploadedFile $svgFile = null;

#[ORM\Column(name: 'eot_filename', type: 'string', nullable: true)]
#[ORM\Column(name: 'eot_filename', type: 'string', length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $eotFilename = null;

#[ORM\Column(name: 'woff_filename', type: 'string', nullable: true)]
#[ORM\Column(name: 'woff_filename', type: 'string', length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $woffFilename = null;

#[ORM\Column(name: 'woff2_filename', type: 'string', nullable: true)]
#[ORM\Column(name: 'woff2_filename', type: 'string', length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $woff2Filename = null;

#[ORM\Column(name: 'otf_filename', type: 'string', nullable: true)]
#[ORM\Column(name: 'otf_filename', type: 'string', length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $otfFilename = null;

#[ORM\Column(name: 'svg_filename', type: 'string', nullable: true)]
#[ORM\Column(name: 'svg_filename', type: 'string', length: 100, nullable: true)]
#[Assert\Length(max: 100)]
private ?string $svgFilename = null;

#[ORM\Column(type: 'string', unique: false, nullable: false)]
#[ORM\Column(type: 'string', length: 100, unique: false, nullable: false)]
#[Assert\NotNull]
#[Assert\NotBlank]
#[Assert\Length(max: 100)]
private string $name = '';

#[ORM\Column(type: 'string', unique: false, nullable: false)]
#[ORM\Column(type: 'string', length: 128, unique: false, nullable: false)]
#[Assert\Length(max: 128)]
private string $hash = '';

#[ORM\Column(type: 'string', nullable: false)]
#[ORM\Column(type: 'string', length: 100, nullable: false)]
#[Assert\Length(max: 100)]
private string $folder = '';

#[ORM\Column(type: 'text', nullable: true)]
Expand Down
3 changes: 2 additions & 1 deletion src/Repository/FontRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function getLatestUpdateDate(): ?\DateTimeInterface
{
$query = $this->_em->createQuery('
SELECT MAX(f.updatedAt) FROM RZ\Roadiz\FontBundle\Entity\Font f');
$updatedAt = $query->getSingleScalarResult();

return new \DateTimeImmutable($query->getSingleScalarResult());
return \is_string($updatedAt) ? new \DateTimeImmutable($updatedAt) : null;
}
}
2 changes: 1 addition & 1 deletion templates/admin/add.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<fieldset data-uk-margin>
{% apply spaceless %}
<button data-action-save="#edit-font-form"
class="uk-button uk-button-primary rz-action-save" type="submit">
class="uk-button uk-button-success rz-action-save" type="submit">
<span class="icon-container"><i class="uk-icon-rz-save"></i></span>
<span class="label"><span class="label-text">{% block content_form_submit_label %}
{%- trans -%}save{%- endtrans -%}
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<div class="content-table-cont metadata-list">
<table class="uk-table content-table">
<tr>
<td>{% trans %}created.at{% endtrans %}</td>
<th>{% trans %}created.at{% endtrans %}</th>
<td>{{ item.createdAt|format_datetime('long', locale=app.request.locale) }}</td>
</tr>
<tr>
<td>{% trans %}updated.at{% endtrans %}</td>
<th>{% trans %}updated.at{% endtrans %}</th>
<td>{{ item.updatedAt|format_datetime('long', locale=app.request.locale) }}</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
data-uk-tooltip="{animation:true}">
<i class="uk-icon-rz-download"></i>
</a>
<a class="uk-button uk-button-content uk-button-small uk-button-table-delete"
<a class="uk-button uk-button-content uk-button-small uk-button-danger"
href="{{ path('fontsDeletePage', { id: item.id }) }}"
title="{% trans %}delete{% endtrans %}"
data-uk-tooltip="{animation:true}">
Expand Down

0 comments on commit b706ee1

Please sign in to comment.