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

Option to customize route prefix name like 'myapp' #1334

Open
alexseif opened this issue Jul 11, 2023 · 0 comments
Open

Option to customize route prefix name like 'myapp' #1334

alexseif opened this issue Jul 11, 2023 · 0 comments

Comments

@alexseif
Copy link

Hello All,
This is a well thought of bundle, and I would hate to add complexity to it.
We have the option to change the namespace through creating a file

# config/packages/dev/maker.yaml
# create this file if you need to configure anything
maker:
    # tell MakerBundle that all of your classes live in an
    # Acme namespace, instead of the default App
    # (e.g. Acme\Entity\Article, Acme\Command\MyCommand, etc)
    root_namespace: 'Acme'

I was wondering if we can do the same for route_name prefix.
Let's say I'm building and all route names comeback with app_, but as the complexity of your app grows you might want to have different route_name prefix instead of longer route names. eg. instead of app_admin_index you would want admin_index.

So I was wondering if we can introduce some sort of option through the command or the yaml file to do so.

Currently I just override the make:controller bundle. But I think we can simple change Str

public static function asRouteName(string $value): string

    public static function asRouteName(string $value): string
    {
        $routeName = self::asTwigVariable($value);

        return str_starts_with($routeName, 'app_') ? $routeName : 'app_'.$routeName;
    }

To have app_ guessed from parameters with a default of 'app_'

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

No branches or pull requests

1 participant