Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Command to generate XSD Schemas for ViewHelpers #876

Merged
merged 9 commits into from
Jun 13, 2024

Conversation

s2b
Copy link
Contributor

@s2b s2b commented Jun 12, 2024

This feature is a re-implementation of the XSD schema generator, which was previously
available as a separate package 1. These schema files provide auto-complete in IDEs
(like PHPStorm) for all available ViewHelpers in a composer project.

The bin/fluid CLI command now supports the additional command schema, which scans
the whole composer projects for valid ViewHelper classes. The class in question needs
to meet the following requirements, which enforces already-existing conventions:

  • file name must end with ViewHelper.php
  • file path must contain a directory ViewHelpers, which serves as a divider between
    a Fluid namespace and its ViewHelpers
  • class must implement ViewHelperInterface
  • class name must end with ViewHelper
  • class must not be abstract

These conditions are checked by ViewHelperMetadataFactory, which then creates the
corresponding ViewHelperMetadata value object. The SchemaGenerator then receives
a list of ViewHelperMetadata objects as well as an XML namespace (like
http://typo3.org/ns/TYPO3Fluid/Fluid/ViewHelpers) and generates an xsd schema file
that describes the ViewHelper and its arguments. The ConsoleRunner collects these files, creates unique file names and writes them as schema_*.xsd files to the destination
folder, specified with --destination.

IDEs either pick up those files automatically or need to be configured manually to
do so.

Footnotes

  1. https://github.com/TYPO3/Fluid.SchemaGenerator/

@s2b s2b force-pushed the feature/schemaGenerator branch 4 times, most recently from 13073c3 to f23b8d5 Compare June 12, 2024 13:46
@s2b s2b force-pushed the feature/schemaGenerator branch from f23b8d5 to 9288a5e Compare June 12, 2024 16:26
@s2b s2b marked this pull request as ready for review June 13, 2024 10:57
Copy link

@RozbehSharahi RozbehSharahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not through with the code-review yet. Nevertheless here already some comments. Hope it helps.

tests/Unit/Schema/ViewHelperMetadataFactoryTest.php Outdated Show resolved Hide resolved
src/Schema/SchemaGenerator.php Show resolved Hide resolved
src/Schema/SchemaGenerator.php Show resolved Hide resolved
src/Schema/SchemaGenerator.php Show resolved Hide resolved
src/Schema/SchemaGenerator.php Outdated Show resolved Hide resolved
src/Tools/ConsoleRunner.php Outdated Show resolved Hide resolved
@s2b s2b merged commit 3372d22 into main Jun 13, 2024
8 checks passed
@s2b s2b deleted the feature/schemaGenerator branch June 13, 2024 15:11
@RozbehSharahi
Copy link

🥳

@simonschaufi
Copy link
Contributor

simonschaufi commented Sep 11, 2024

I'm unhappy with the implementation as it lacks the namespace parameter which exited before 😢

Before I had individual calls to generate the schema files for each extension individually of my project which doesn't work now anymore.

It also crashes for 3rd party extensions: #1005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants