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

hide annotation with tests #6382

Merged
merged 23 commits into from Oct 21, 2014
Merged

hide annotation with tests #6382

merged 23 commits into from Oct 21, 2014

Conversation

d-skora
Copy link

@d-skora d-skora commented Oct 3, 2014

Added @hide annotation.
@hide takes up to one argument.
If there's no argument @hide will always hide the annotated plugin's API.
If the argument is set then there is a API.DocumentGenerator.hide event dispatched.
The event should be handled in the plugin and it should set the &$response to true if the plugin API should be hidden from the current user or false if the user should be able to see the plugin API.

@d-skora d-skora changed the title PPP-349 hide annotation with tests hide annotation with tests Oct 3, 2014
@@ -23,7 +23,8 @@ public function getListHooksRegistered()
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
"TestingEnvironment.addHooks" => 'setupTestEnvironment'
"TestingEnvironment.addHooks" => 'setupTestEnvironment',
'API.DocumentationGenerator.hideExceptForSuperUser' => 'checkIfNotSuperUser'
Copy link
Member

Choose a reason for hiding this comment

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

this code is not needed?

@mattab
Copy link
Member

mattab commented Oct 6, 2014

Hi @d-skora, thanks for PR. I notice the build failed with a php notice.
Cheers

@mattab mattab added Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change. Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Oct 6, 2014
@mattab mattab added this to the Short term milestone Oct 6, 2014
@d-skora
Copy link
Author

d-skora commented Oct 6, 2014

Fixed up things, now it works correctly with classes and methods.
It allows easy future development thanks to using events and provides a quick way to hide API classes or methods.
By using a hide annotation it is possible to hide the API class or method for everyone.
By using a annotation starting with hide it dispatches an event with the same name as the annotation that allows to check if the user should see the API class or method.
A hook for hideExceptForSuperUser annotation is already added in CoreAdminHome class.

@mgazdzik
Copy link
Contributor

@mattab - any update on this? Can this be merged into Core before 2.8.1 ?

* @param bool &$response Boolean value containing information
* if the plugin API should be hidden from the current user.
*/
Piwik::postEvent(sprintf('API.DocumentationGenerator.%s', $hideString), array(&$response));
Copy link
Member

Choose a reason for hiding this comment

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

the event is not necessary as we need only hideExceptSuperUser for this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed with @mgazdzik - this PR should be more generic and flexible. Creating custom hook in this place gives us the ability to easily define our custom annotation and their behavior. As long this is core feature, not specific plugin we should look at this problem with wider perspective. Creating hard coded solutions in core is bad approach in Piwik architecture and we should avoid this.

mattab pushed a commit that referenced this pull request Oct 21, 2014
hide annotation with tests
@mattab mattab merged commit 11bb997 into matomo-org:master Oct 21, 2014
@mattab
Copy link
Member

mattab commented Oct 21, 2014

Thanks for PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants