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

feat: Add twill:make:singleton command #1178

Merged
merged 10 commits into from
Oct 29, 2021
Merged

feat: Add twill:make:singleton command #1178

merged 10 commits into from
Oct 29, 2021

Conversation

pboivin
Copy link
Contributor

@pboivin pboivin commented Oct 1, 2021

Description

This PR adds a new Artisan command to generate singleton modules.

Singletons are a type of module that are designed to only have a single record in the database. Unlike regular modules, they do not have an index page in the CMS. Typically, the menu entry for a singleton will lead directly to the form of its first and only record.

Singletons a great for one-off pages that require unique fields and/or custom logic (e.g. Home, About, Contact, etc.). An example from demo.twill.io :

demo

Like twill:make:capsule, this new command is an extension of twill:make:module. Outside of the base command, some other modifications were made to support this feature:

  • added a SingletonModuleController base class
  • added a Route::singleton() macro
  • added support for a singleton parameter for twill-navigation.php items
  • added Seeder class stub for singleton modules
  • added a few helper methods to handle stub file processing (this will be further improved in a future PR)

Some integration tests were also added along the way.

The command in action:

make-singleton

Related Issues

ifox
ifox previously approved these changes Oct 25, 2021
Copy link
Member

@ifox ifox left a comment

Choose a reason for hiding this comment

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

This is amazing @pboivin! Very nice holistic solution for Twill singletons.

Minor nitpick: can the contactpage singleton in tests be renamed to contactPage?

@pboivin pboivin merged commit ad780dc into area17:2.x Oct 29, 2021
@pboivin pboivin deleted the feat/make-singleton-command branch October 29, 2021 20:37
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