From 6f9d3b8fd818e1b0ad143c13252da60fcca7ea66 Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Thu, 17 Apr 2025 14:54:20 +0200
Subject: [PATCH 01/12] Add enum templates
---
.../template/components/enum-case.html.twig | 9 +++
.../template/components/enum-title.html.twig | 21 ++++++
.../.phpdoc/template/enum.html.twig | 65 +++++++++++++++++++
3 files changed, 95 insertions(+)
create mode 100644 tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig
create mode 100644 tools/php_api_ref/.phpdoc/template/components/enum-title.html.twig
create mode 100644 tools/php_api_ref/.phpdoc/template/enum.html.twig
diff --git a/tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig b/tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig
new file mode 100644
index 0000000000..979809cf5d
--- /dev/null
+++ b/tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig
@@ -0,0 +1,9 @@
+
+ {% embed 'components/content-header.html.twig' with { node: case, anchor: 'enumcase_' ~ case.name, anchor_link: link(case), header_tag: 'h3' } %}
+ {% endembed %}
+ {% include 'components/summary.html.twig' with { node: case } %}
+ {% include 'components/deprecation.html.twig' with { node: case } %}
+ {% include 'components/description.html.twig' with { node: case } %}
+ {% include 'components/description.html.twig' with { node: case.var[0] } %}
+ {% include 'components/tags.html.twig' with { node: case } %}
+
diff --git a/tools/php_api_ref/.phpdoc/template/components/enum-title.html.twig b/tools/php_api_ref/.phpdoc/template/components/enum-title.html.twig
new file mode 100644
index 0000000000..041eca1a54
--- /dev/null
+++ b/tools/php_api_ref/.phpdoc/template/components/enum-title.html.twig
@@ -0,0 +1,21 @@
+{% set breadcrumbs = usesNamespaces ? breadcrumbs(node) : packages(node) %}
+{% set fqcn = breadcrumbs|map(breadcrumb => breadcrumb.name)|join('\\') ~ '\\' ~ node.name %}
+
+{% embed 'components/content-header.html.twig' with {
+ anchor: node.name,
+ anchor_link: '#' ~ node.name,
+ fqcn,
+ add_edition: true,
+} %}
+ {% block name %}
+ {{ node.name }}
+ {% endblock %}
+ {% block subheader %}
+
+ {% endblock %}
+{% endembed %}
diff --git a/tools/php_api_ref/.phpdoc/template/enum.html.twig b/tools/php_api_ref/.phpdoc/template/enum.html.twig
new file mode 100644
index 0000000000..500c848d7b
--- /dev/null
+++ b/tools/php_api_ref/.phpdoc/template/enum.html.twig
@@ -0,0 +1,65 @@
+{% extends 'base.html.twig' %}
+
+{% block title %}{{ node.name }} | {{ parent() }}{% endblock %}
+{% block meta %}
+
+ {{ parent() }}
+{% endblock %}
+
+{% block content %}
+ {% include 'components/breadcrumbs.html.twig' %}
+ {% include 'components/enum-title.html.twig' %}
+ {% include 'components/element-header.html.twig' %}
+ {{ include('components/enum-cases.html.twig') }}
+ {{ include('components/methods.html.twig') }}
+{% endblock %}
+
+{% block on_this_page %}
+ {% set cases = cases(node) %}
+ {% set methods = methods(node) %}
+
+ {% if cases is not empty or methods is not empty %}
+
+ {% endif %}
+
+
+ {% if cases is not empty %}
+ -
+
+ Cases
+
+
+
+ {% endif %}
+ {% if methods is not empty %}
+ -
+
+ Methods
+
+
+
+ {% endif %}
+
+{% endblock %}
From cb3c12e543212dd111bfba1795dbba6b23f0bfe6 Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Thu, 17 Apr 2025 14:56:21 +0200
Subject: [PATCH 02/12] Fix enum CSS
---
tools/php_api_ref/.phpdoc/template/css/base.css.twig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/php_api_ref/.phpdoc/template/css/base.css.twig b/tools/php_api_ref/.phpdoc/template/css/base.css.twig
index 7fa4ff9992..e026e9b8e1 100644
--- a/tools/php_api_ref/.phpdoc/template/css/base.css.twig
+++ b/tools/php_api_ref/.phpdoc/template/css/base.css.twig
@@ -585,6 +585,6 @@ ul.breadcrumbs li.breadcrumb-item-current span {
}
-.phpdocumentor-admonition article {
+.phpdocumentor-admonition article, .phpdocumentor-cases article {
padding-bottom: 0;
}
From c9ed1ecff08c7e0d43c4a2b229dfea74051e98e5 Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Thu, 17 Apr 2025 14:56:37 +0200
Subject: [PATCH 03/12] Add Attributes
---
tools/php_api_ref/.phpdoc/template/components/constant.html.twig | 1 +
.../php_api_ref/.phpdoc/template/components/enum-case.html.twig | 1 +
tools/php_api_ref/.phpdoc/template/components/method.html.twig | 1 +
tools/php_api_ref/.phpdoc/template/components/property.html.twig | 1 +
4 files changed, 4 insertions(+)
diff --git a/tools/php_api_ref/.phpdoc/template/components/constant.html.twig b/tools/php_api_ref/.phpdoc/template/components/constant.html.twig
index 725fd67a9b..f170ffaae0 100644
--- a/tools/php_api_ref/.phpdoc/template/components/constant.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/constant.html.twig
@@ -9,3 +9,4 @@
{% include 'components/description.html.twig' with { node: constant } %}
{% include 'components/description.html.twig' with { node: constant.var[0] } %}
{% include 'components/tags.html.twig' with {node: constant } %}
+{% include 'components/attributes.html.twig' with { node: constant } %}
diff --git a/tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig b/tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig
index 979809cf5d..6126f942c3 100644
--- a/tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/enum-case.html.twig
@@ -6,4 +6,5 @@
{% include 'components/description.html.twig' with { node: case } %}
{% include 'components/description.html.twig' with { node: case.var[0] } %}
{% include 'components/tags.html.twig' with { node: case } %}
+ {% include 'components/attributes.html.twig' with { node: case } %}
diff --git a/tools/php_api_ref/.phpdoc/template/components/method.html.twig b/tools/php_api_ref/.phpdoc/template/components/method.html.twig
index 0bc1a436ed..683b853e81 100644
--- a/tools/php_api_ref/.phpdoc/template/components/method.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/method.html.twig
@@ -15,3 +15,4 @@
{% include 'components/method-arguments.html.twig' with { node: method } %}
{% include 'components/method-response.html.twig' with { node: method } %}
{% include 'components/tags.html.twig' with { node: method } %}
+{% include 'components/attributes.html.twig' with { node: method } %}
diff --git a/tools/php_api_ref/.phpdoc/template/components/property.html.twig b/tools/php_api_ref/.phpdoc/template/components/property.html.twig
index d723b3e054..1688a76573 100644
--- a/tools/php_api_ref/.phpdoc/template/components/property.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/property.html.twig
@@ -13,3 +13,4 @@
{% include 'components/description.html.twig' with { node: property } %}
{% include 'components/description.html.twig' with { node: property.var[0] } %}
{% include 'components/tags.html.twig' with {node: property } %}
+{% include 'components/attributes.html.twig' with { node: property } %}
From 8384fe0417d7ed20aa58ca50d3b3d937c6661a15 Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Thu, 17 Apr 2025 18:47:24 +0200
Subject: [PATCH 04/12] PHP API Ref: Ease Symfony version maintenance
---
tools/php_api_ref/.phpdoc/template/base.html.twig | 2 +-
tools/php_api_ref/phpdoc.sh | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/php_api_ref/.phpdoc/template/base.html.twig b/tools/php_api_ref/.phpdoc/template/base.html.twig
index a53b7096d4..14af42c425 100644
--- a/tools/php_api_ref/.phpdoc/template/base.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/base.html.twig
@@ -1,6 +1,6 @@
{% extends 'layout.html.twig' %}
-{% set symfony_version = '5.4' %}
+{% set symfony_version = 'SF_VERSION' %}
{% block javascripts %}
{{ parent() }}
diff --git a/tools/php_api_ref/phpdoc.sh b/tools/php_api_ref/phpdoc.sh
index 34b5f20f65..ffd2c795dc 100755
--- a/tools/php_api_ref/phpdoc.sh
+++ b/tools/php_api_ref/phpdoc.sh
@@ -9,6 +9,7 @@ DXP_EDITION='commerce'; # Edition from and for which the Reference is built
DXP_VERSION='4.6.*'; # Version from and for which the Reference is built
DXP_ADD_ONS=(connector-ai connector-openai automated-translation product-catalog-date-time-attribute); # Packages not included in $DXP_EDITION but added to the Reference, listed without their vendor "ibexa"
DXP_EDITIONS=(oss headless experience commerce); # Available editions ordered by ascending capabilities
+SF_VERSION='5.4'; # Symfony version used by Ibexa DXP
PHPDOC_VERSION='3.7.1'; # Version of phpDocumentor used to build the Reference
PHPDOC_CONF="$(pwd)/tools/php_api_ref/phpdoc.dist.xml"; # Absolute path to phpDocumentor configuration file
#PHPDOC_CONF="$(pwd)/tools/php_api_ref/phpdoc.dev.xml"; # Absolute path to phpDocumentor configuration file
@@ -154,6 +155,9 @@ mv ./.phpdoc/template/fonts ./php_api_reference/;
mv ./.phpdoc/template/images ./php_api_reference/;
mv ./.phpdoc/template/js/*.js ./php_api_reference/js/;
+echo 'Set Symfony version…';
+sed "s/symfony_version = '.*'/symfony_version = '$SF_VERSION'/" $PHPDOC_DIR/template/base.html.twig > ./.phpdoc/template/base.html.twig;
+
echo 'Run phpDocumentor…';
curl -LO "https://github.com/phpDocumentor/phpDocumentor/releases/download/v$PHPDOC_VERSION/phpDocumentor.phar";
PHPDOC_BIN='phpDocumentor.phar';
From 6f9927f3cde5e3679af7ec39c1d5d89adacc794a Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Sat, 19 Apr 2025 02:04:47 +0200
Subject: [PATCH 05/12] Add enum to left side menu
---
.../template/components/menu-entry.html.twig | 2 +-
.../.phpdoc/template/components/menu.html.twig | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/tools/php_api_ref/.phpdoc/template/components/menu-entry.html.twig b/tools/php_api_ref/.phpdoc/template/components/menu-entry.html.twig
index 71cee668c1..bedd3e8bfe 100644
--- a/tools/php_api_ref/.phpdoc/template/components/menu-entry.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/menu-entry.html.twig
@@ -1,4 +1,4 @@
-{% set is_nested = entry.children.count or entry.interfaces[0] is defined or entry.classes[0] is defined or entry.traits[0] is defined %}
+{% set is_nested = entry.children.count or entry.interfaces[0] is defined or entry.classes[0] is defined or entry.traits[0] is defined or entry.enums[0] is defined %}
{% set url = entry|route("url")|raw %}
{% set type = type|default('') %}
diff --git a/tools/php_api_ref/.phpdoc/template/components/menu.html.twig b/tools/php_api_ref/.phpdoc/template/components/menu.html.twig
index d3801a9523..4c86bee8a1 100644
--- a/tools/php_api_ref/.phpdoc/template/components/menu.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/menu.html.twig
@@ -35,10 +35,10 @@
{% endif %}
- {% if entry.interfaces[0] is defined or entry.classes[0] is defined or entry.traits[0] is defined %}
+ {% if entry.interfaces[0] is defined or entry.classes[0] is defined or entry.traits[0] is defined or entry.enums[0] is defined %}
{% if depth > 1 %}
{% endif %}
@@ -78,6 +78,19 @@
icon: 'file.svg',
} %}
+ {% set index = index + 1 %}
+ {% endfor %}
+ {% endif %}
+ {% if entry.enums[0] is defined %}
+ {% for element in entry.enums|sort_asc %}
+ {% include 'components/menu-entry.html.twig' with {
+ title: element.name|shortFQSEN,
+ nav_id: nav_id ~ '-' ~ index,
+ entry: element,
+ expanded: false,
+ icon: 'file.svg',
+ } %}
+
{% set index = index + 1 %}
{% endfor %}
{% endif %}
From e64a5e7f63078a36c2ec233128ca6528410a3cbf Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Sat, 19 Apr 2025 02:06:46 +0200
Subject: [PATCH 06/12] phpdoc.sh: Detail progress feedback
---
tools/php_api_ref/phpdoc.sh | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/php_api_ref/phpdoc.sh b/tools/php_api_ref/phpdoc.sh
index ffd2c795dc..faa8c83b77 100755
--- a/tools/php_api_ref/phpdoc.sh
+++ b/tools/php_api_ref/phpdoc.sh
@@ -90,10 +90,6 @@ fi
if [ 0 -eq $DXP_ALREADY_EXISTS ]; then
echo -n 'Building package→edition map… ';
- map=$PHPDOC_DIR/template/package-edition-map.twig;
- if [[ -f $map ]]; then
- rm $map;
- fi;
PACKAGE_MAP=''
NAMESPACE_MAP=''
for edition in ${DXP_EDITIONS[@]}; do
@@ -111,14 +107,22 @@ if [ 0 -eq $DXP_ALREADY_EXISTS ]; then
break;
fi;
done;
+ echo 'OK';
+ echo -n 'Building namespace→edition map… ';
for package in "${DXP_ADD_ONS[@]}"; do
NAMESPACES=$(composer show "ibexa/$package" --available --format=json | \
jq -r --arg PACKAGE "ibexa/$package" '"'\''\(.autoload | ."psr-4" | try to_entries[] catch empty | .key[:-1] | sub("\\\\";"\\\\\\";"g"))'\'': '\''\($PACKAGE)'\'',"')
NAMESPACE_MAP="$NAMESPACE_MAP\n$NAMESPACES"
PACKAGE_MAP="$PACKAGE_MAP\n'ibexa/$package': 'optional',"
done;
+ echo 'OK';
+ echo -n "Store package→edition and namespace→edition maps into $map… ";
+ map=$PHPDOC_DIR/template/package-edition-map.twig;
+ if [[ -f $map ]]; then
+ rm $map;
+ fi;
PACKAGE_MAP="{% set package_edition_map = {\n$PACKAGE_MAP\n} %}"
NAMESPACE_MAP="{% set namespace_package_map = {\n$NAMESPACE_MAP\n} %}"
{
From fb875dcef8f0e96a74bc9804b24c50dddc60a45f Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Sat, 19 Apr 2025 15:01:23 +0200
Subject: [PATCH 07/12] Add enum to namespace toc
---
.../.phpdoc/template/components/table-of-contents.html.twig | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig b/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig
index 327294456e..3a1b4056c9 100644
--- a/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig
@@ -52,10 +52,13 @@
{% if node.traits[0] is defined %}
{% set joined_data = joined_data|merge(node.traits) %}
{% endif %}
+{% if node.enums[0] is defined %}
+ {% set joined_data = joined_data|merge(node.enums) %}
+{% endif %}
{% if joined_data is not empty %}
- Interfaces, classes, and traits
+ Interfaces, classes, traits, and enums
{%- include 'components/anchor.html.twig' with { anchor_link: link(node) ~ '#interfaces' } -%}
From 209820a894d89199510439f5a6c007253edca806 Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Sat, 19 Apr 2025 16:07:20 +0200
Subject: [PATCH 08/12] Sort namespace toc
---
.../.phpdoc/template/components/table-of-contents.html.twig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig b/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig
index 3a1b4056c9..44a51c7391 100644
--- a/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/components/table-of-contents.html.twig
@@ -62,7 +62,7 @@
{%- include 'components/anchor.html.twig' with { anchor_link: link(node) ~ '#interfaces' } -%}
- {% for entry in joined_data %}
+ {% for entry in joined_data|sort((entry1, entry2) => entry1.name <=> entry2.name) %}
-
From e31ac347d6458d3d0a85b3c47ed4c786dacd6a2d Mon Sep 17 00:00:00 2001
From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com>
Date: Mon, 21 Apr 2025 14:32:09 +0200
Subject: [PATCH 09/12] enum.html.twig: Fix anchor, format
---
tools/php_api_ref/.phpdoc/template/enum.html.twig | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/php_api_ref/.phpdoc/template/enum.html.twig b/tools/php_api_ref/.phpdoc/template/enum.html.twig
index 500c848d7b..4909b852dd 100644
--- a/tools/php_api_ref/.phpdoc/template/enum.html.twig
+++ b/tools/php_api_ref/.phpdoc/template/enum.html.twig
@@ -10,8 +10,8 @@
{% include 'components/breadcrumbs.html.twig' %}
{% include 'components/enum-title.html.twig' %}
{% include 'components/element-header.html.twig' %}
- {{ include('components/enum-cases.html.twig') }}
- {{ include('components/methods.html.twig') }}
+ {% include 'components/enum-cases.html.twig' %}
+ {% include 'components/methods.html.twig' %}
{% endblock %}
{% block on_this_page %}
@@ -27,7 +27,7 @@
{% if cases is not empty %}
-
-
+
Cases