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

Allow naming plugin classes matching the plugin name. #16374

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

ADmad
Copy link
Member

@ADmad ADmad commented Mar 11, 2022

This avoids having numerous classes named "Plugin" in your app. You can now name the class the same as the plugin name with a "Plugin" suffix. For e.g. ADmad\I18n\I18nPlugin instead of ADmad\I18n\Plugin.

This avoids having numerous classes named "Plugin" in your app.
@ADmad ADmad added this to the 4.4.0 milestone Mar 11, 2022
@@ -17,6 +17,6 @@

use Cake\Core\BasePlugin;

class Plugin extends BasePlugin
class TestPluginThreePlugin extends BasePlugin
Copy link
Member

Choose a reason for hiding this comment

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

oof, that name.

Copy link
Member Author

Choose a reason for hiding this comment

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

You know what they say about naming things in programming :)

@othercorey
Copy link
Member

You can now name the class the same as the plugin name with a "Plugin" prefix.

You mean "suffix", yes?

{
public function bootstrap(PluginApplicationInterface $app): void
{
Configure::write('ParentPlugin.bootstrap', true);
Configure::write('Named.bootstrap', true);
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any changes for this name lookup. Is it dependent on anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

See the BaseApplicationTest.

@ADmad
Copy link
Member Author

ADmad commented Mar 11, 2022

You mean "suffix", yes?

Yes, typo :)

@ADmad
Copy link
Member Author

ADmad commented Mar 11, 2022

For reference Symfony bundle classes are names similarly. For e.g. the "TwigBundle" has the class Symfony\Bundle\TwigBundle\TwigBundle.

@markstory
Copy link
Member

It would be good to update the docs too.

ADmad added a commit to cakephp/docs that referenced this pull request Mar 11, 2022
@ADmad ADmad merged commit 3f7eb85 into 4.next Mar 11, 2022
@ADmad ADmad deleted the 4.4-plugin-classname branch March 11, 2022 17:21
ADmad added a commit to cakephp/bake that referenced this pull request Mar 12, 2022
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.

None yet

3 participants