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

Refactoring hook callback methods #23

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Refactoring hook callback methods #23

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 5, 2021

Remove duplications on OJS/OPS metrics visualization. Rename variables to be more generic, instead of OJS specific terms (article).

Turn methods articleMainCallback and preprintMainCallback into publicationMainCallback.
Update variable 'article' to 'publication'.

@pablovp86
Copy link

I'm in doubt about the $_publicationNoun variable name.

It's used to decide between article or preprint, and me and @iudiz were inspired on the $submissionNoun variable from PdfJsViewerPlugin.

Any suggestion of a better name for this variable?

@asmecher
Copy link
Member

asmecher commented Apr 7, 2021

The correct generic term for article is submission; publication is something entirely different -- a submission consists of several publications, and these reflect the different versions of the submission.

@pablovp86
Copy link

pablovp86 commented Apr 7, 2021

Thanks @asmecher.

What would be the most appropriate name for the attribute? $_submissionNoun or $_submissionType?

@asmecher
Copy link
Member

asmecher commented Apr 7, 2021

Either is sensible to me!

@diegoabadan
Copy link

diegoabadan commented Apr 7, 2021

Alec,

Today we have these hooks:

Templates::Article::Main
Templates::Catalog::Book::Main
Templates::Preprint::Main

It would be interesting to have an alternative to simplify the plugins that use these mentioned, for example:
https://github.com/pkp/usageStats/blob/f2eaa334ba1719bd95bc43982ae6e3b0ad9c3c73/UsageStatsPlugin.inc.php#L162

and

HookRegistry::register('Templates::Article::Main', array($this, 'articleMainCallback'));
// Add visualization to preprint view page
HookRegistry::register('Templates::Preprint::Main', array(&$this, 'preprintMainCallback'));

Do you think of a good way to avoid these repetitions? For example, a generic hook that can be used instead of one per application?

If you find it interesting, we can send you a PR.

@pablovp86
Copy link

Either is sensible to me!

We did the commit, renaming the variable.

@asmecher
Copy link
Member

asmecher commented Apr 8, 2021

Do you think of a good way to avoid these repetitions? For example, a generic hook that can be used instead of one per application?

Yes, this would be good to do -- a generic hook for all 3 applications -- but we haven't done that yet because if we just rename the hook it'll be painful for 3rd-party users of the existing hooks to discover why parts of their plugins suddenly stopped working.

One approach that could work would be to add a new application-independent hook and then mark the current hooks in the code as deprecated. We can document the deprecation in the Release Notebook. If you'd like to give that a crack, it would be welcome!

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.

4 participants