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

Add method to convert namespaced class names to plugin split names #8224

Merged
merged 1 commit into from Feb 12, 2016

Conversation

Marlinc
Copy link
Contributor

@Marlinc Marlinc commented Feb 9, 2016

This method is pretty much the opposite of App::className and can be useful for all kinds of reasons.

  • I personally think plugin split names are easier to read then long namespaces.
  • Its very difficult to detect the plugin name based on the namespace. This in combination with pluginSplit makes that very easy.

@@ -74,6 +74,59 @@ public static function className($class, $type = '', $suffix = '')
}

/**
* Returns the plugin split name of a class
*
Copy link
Member

Choose a reason for hiding this comment

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

Adding some examples here will make me understand what this method is for :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added some examples down below.

@Marlinc Marlinc force-pushed the plugin-split-name branch 4 times, most recently from 22c2c34 to d4145fe Compare February 9, 2016 21:38
@jadb
Copy link
Contributor

jadb commented Feb 9, 2016

👍

@Marlinc Marlinc force-pushed the plugin-split-name branch 2 times, most recently from 85e7454 to b457769 Compare February 9, 2016 22:40
@markstory markstory added this to the 3.2.2 milestone Feb 10, 2016
@@ -69,6 +69,26 @@ public function testClassname($class, $type, $suffix = '', $existsInBase = false
}

/**
* testClassname
*
* $checkCake and $existsInCake are derived from the input parameters
Copy link
Member

Choose a reason for hiding this comment

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

This comment doesn't make sense in the context of the function.

@markstory
Copy link
Member

Other than readability, what do you see this method being used for?

@Marlinc Marlinc force-pushed the plugin-split-name branch 3 times, most recently from 784dd88 to 5705dc6 Compare February 10, 2016 11:56
@Marlinc
Copy link
Contributor Author

Marlinc commented Feb 10, 2016

This method can be used to get the name of the plugin to which a class belongs. This is for example being used in UseMuffin/Webservice to detect other classes in the plugin. As the plugin can be detected based on the panel class.

@Marlinc
Copy link
Contributor Author

Marlinc commented Feb 11, 2016

Another use case would be https://github.com/cakephp/debug_kit/blob/master/src/DebugPanel.php#L34 . With this method defining a plugin would not be necessary.

@dereuromark
Copy link
Member

👍 Looks good

@markstory markstory modified the milestones: 3.2.2, 3.2.3 Feb 12, 2016
lorenzo added a commit that referenced this pull request Feb 12, 2016
Add method to convert namespaced class names to plugin split names
@lorenzo lorenzo merged commit a524970 into cakephp:master Feb 12, 2016
@lorenzo
Copy link
Member

lorenzo commented Feb 12, 2016

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

5 participants