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

Bake should support core plugins better #991

Open
markstory opened this issue Jun 7, 2024 · 4 comments
Open

Bake should support core plugins better #991

markstory opened this issue Jun 7, 2024 · 4 comments

Comments

@markstory
Copy link
Member

Description

Bake could be expanded to include behavior for other core plugins. We could enable this behavior in a generic way so that users could use it in any custom templates they may have.

Controller base - actions with plugin logic

When you're using the authorization plugin, all of your controller actions will require a call to authorize(). That is a perfect task for bake to take care of. For example, controller actions could have a block like:

{% if Bake.hasPlugin('Authorization') %}
    $this->Authorize->authorize(${{ singularVar }});
{% endif %}

This would allow plugins to have deeper integration with bake and get people further faster.

We can also use this to generate a simple login form, and beforeFilter method on a UsersController if the Authentication plugin is present. While I would like to be able to modify the Application methods as well, we would need bake to be able to parse and manipulate files. This feels similar to what rector does, but I'm not sure rector was intended to be used this way.

Model bake - Add plugin behaviors

We could also explore giving plugins ways to hook into table generation. For example plugins could receive the table, inspect schema and add additional behaviors. An example usecase would be a Sluggable behavior being added to models with slug in their schema.

@markstory markstory added this to the 3.x (CakePHP 5) milestone Jun 7, 2024
@ADmad
Copy link
Member

ADmad commented Jun 7, 2024

When you're using the authorization plugin, all of your controller actions will require a call to authorize()

I updated my bake templates to do just that recently :)

We could also explore giving plugins ways to hook into table generation.

That would be great, then I wouldn't have to override methods of the ModelCommand as I do now.

Copy link

github-actions bot commented Oct 6, 2024

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days

@github-actions github-actions bot added the stale label Oct 6, 2024
@ADmad ADmad removed the stale label Oct 6, 2024
@ADmad
Copy link
Member

ADmad commented Oct 6, 2024

I don't think generating the <plugin>/tests/bootstrap.php and <plugin>/tests/schema.sql files makes sense either for in-app plugins.

@dereuromark
Copy link
Member

With #1007 merged, what else might still be needed?

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

No branches or pull requests

3 participants