Skip to content

Conversation

dario-dib
Copy link

The class scanner used a simple /class\s+(\w+)/ regex on raw file contents. When the word "class" appeared in comments or strings (e.g. "grid class you have generated"), the regex captured "you" as a class name, leading to errors such as: "App\Entity\you"

This fixes the issue encountered when following the Sylius Stack documentation (Basic Operations cookbook): https://stack.sylius.com/cookbook/admin_panel/basic_operations

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

The class scanner used a simple `/class\s+(\w+)/` regex on raw file
contents. When the word "class" appeared in comments or strings (e.g.
"grid class you have generated"), the regex captured "you" as a class
name, leading to errors such as: "App\Entity\you"

This fixes the issue encountered when following the Sylius Stack documentation (Basic Operations cookbook): https://stack.sylius.com/cookbook/admin_panel/basic_operations
@loic425
Copy link
Member

loic425 commented Sep 24, 2025

Could you at least add a resource with that class in a comment to test it solves the issue?

@dario-dib
Copy link
Author

Hi, yes you can for example use this from the SYlius Stack docs.

Without the fix it will give the error: Class "App\Entity\you" does not exist

With the fix, the issue is gone.

namespace App\Entity;

use App\Grid\BookGrid;
use Sylius\Resource\Metadata\AsResource;
use Sylius\Resource\Metadata\Index;
use Sylius\Resource\Model\ResourceInterface;

#[AsResource(
section: 'admin', // This will influence the route name
routePrefix: '/admin',
templatesDir: '@SyliusAdminUi/crud', // This directory contains the generic template for your list
operations: [
new Index( // This operation will add "index" operation for the books list
grid: BookGrid::class, // Use the grid class you have generated in previous step
),
],
)]
class Book implements ResourceInterface
{
//...
}

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.

2 participants