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
8 changes: 8 additions & 0 deletions .github/workflows/compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
- name: Validate composer.json
run: composer validate --strict

# Contao 4.13 pulls in spomky-labs/otphp ^10.0 transitively, and every
# available 10.x release carries a security advisory. Composer refuses to
# resolve advisory-affected packages by default, which breaks this
# dry-run resolvability check for a transitive constraint we don't control.
# Disable the advisory block for this ephemeral CI checkout only.
- name: Allow advisory-affected transitive dependencies
run: composer config --no-plugins policy.advisories.block false

- name: Check dependency resolution
run: >-
composer update --dry-run --no-progress --prefer-dist
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"symfony/serializer": "^5.4 || ^6.0 || ^7.0",
"symfony/string": "^5.2 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"twig/twig": "^3.0"
"twig/twig": "^3.13"
},
"require-dev": {
"contao/test-case": "^4.0 || ^5.0",
Expand Down
2 changes: 2 additions & 0 deletions contao/templates/content_element/flare_listview.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{# @var \HeimrichHannot\FlareBundle\Engine\Engine flare #}
{% extends '@Contao/flare/_flare_base.html.twig' %}

{% set flare_css_classes = [flare_css_classes ?? '', 'flare-listview', 'content-flare-listview'] %}

{# @var \HeimrichHannot\FlareBundle\Engine\View\InteractiveView flare_list #}
{% set flare_list = flare.createView %}

Expand Down
2 changes: 2 additions & 0 deletions contao/templates/content_element/flare_reader.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{# @var \Contao\Model model #}
{% extends '@Contao/flare/_flare_base.html.twig' %}

{% set flare_css_classes = [flare_css_classes ?? '', 'flare-reader', 'content-flare-reader'] %}

{% block content %}

<div style="color: #800; background: #fdd; padding: 1rem;">
Expand Down
9 changes: 8 additions & 1 deletion contao/templates/flare/_flare_base.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{% set html_class = ('flare-listview content-flare-listview block ' ~ element_css_classes|default(class|default('')) ~ ' ' ~ flare_css_classes|default('')) %}
{% types {
element_css_classes?: 'string',
class?: 'string',
flare_css_classes?: 'string|string[]',
html_class: 'string',
html_id?: 'string',
} %}
{% set html_class = flare_str.htmlJoinClasses('block', element_css_classes ?? class ?? '', flare_css_classes ?? '') %}
{% set html_id = element_html_id|default(null) %}
<div class="{{ html_class|trim }}"{% if html_id is not null %} id="{{ html_id }}"{% elseif cssID|default %}{{ cssID|raw }}{% endif %}>
{% block wrapper %}
Expand Down
37 changes: 36 additions & 1 deletion src/Util/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static function wrap(mixed $value): string

public static function random(int $length = 10, ?string $chars = null): string
{
$chars ??= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$chars ??= self::CHARS_ALPHANUMERIC;
$max = \mb_strlen($chars, '8bit') - 1;
$rand = '';

Expand Down Expand Up @@ -294,4 +294,39 @@ public static function coalesce(string|callable|null ...$args): ?string

return null;
}

public static function htmlListClasses(string|array|null ...$classes): array
{
if (!$classes) {
return [];
}

$normalClasses = [];
$flatClasses = Arr::flatten($classes);

foreach ($flatClasses as $class)
{
if ($class instanceof \Closure) {
$class = $class();
}

if (!$class) {
continue;
}

if (!\is_scalar($class) && !$class instanceof \Stringable) {
continue;
}

$split = \explode(' ', (string) $class);
\array_push($normalClasses, ...$split);
}

return \array_values(\array_unique(\array_filter($normalClasses)));
}

public static function htmlJoinClasses(string|array|null ...$classes): string
{
return \implode(' ', self::htmlListClasses(...$classes));
}
}
Loading