| Summary: | [pmi] Display project specific information for project-related content types | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | Community | Reporter: | Wayne Beaton <wayne.beaton> | ||||||||
| Component: | Project Management & Portal | Assignee: | Portal Bugzilla Dummy Inbox <portal-inbox> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | nathan | ||||||||
| Version: | unspecified | ||||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Linux | ||||||||||
| Whiteboard: | |||||||||||
| Bug Depends on: | 379192 | ||||||||||
| Bug Blocks: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Wayne Beaton
(In reply to comment #0) > The use of a hook here may be a bit of overkill; we'll wind up calling a lot of > different hook implementations. We may be able to do better with a > call_user_func > > $function = $node->type . '_get_related_project'; > if (function_exists($function)) return call_user_func($function, $node) > > Then we can implement functions like function page_get_related_project($node) > that return exactly one result. I think this is the more elegant solution as it would only call the relevant hook The minor quirk here is that I would use a page_get_related_project function here instead of a project_pages_get_related_project which might clutters the module namespace a bit but I think its something we can live with. For completness, once this functionality has been implemented, we should ensure that it works as expected for elections, releases, and projectroles as well as custom pages. (In reply to comment #1) > The minor quirk here is that I would use a page_get_related_project function > here instead of a project_pages_get_related_project which might clutters the > module namespace a bit but I think its something we can live with. A more important consideration is that another module may try to define the same function. This would be bad. I've commited a variation of what's been discussed here. The projects__get_related_project function first checks to see if the node is of the "project" content type and returns the corresponding Project class instance if it is. Otherwise, if there is a wrapper class that corresponds to the content type that has a getProject method, an instance is created and sent the getProject message. If all else fails, the hook hook_projects_related_project is invoked. If all fails, the function just returns NULL. I can't fully test the hook functionality until Bug 379192 is addressed. (In reply to comment #4) > I've commited a variation of what's been discussed here. > > The projects__get_related_project function first checks to see if the node is > of the "project" content type and returns the corresponding Project class > instance if it is. Otherwise, if there is a wrapper class that corresponds to > the content type that has a getProject method, an instance is created and sent > the getProject message. If all else fails, the hook > hook_projects_related_project is invoked. If all fails, the function just > returns NULL. > > I can't fully test the hook functionality until Bug 379192 is addressed. After closing out Bug 379188 i noticed that in the project pages version of the hook my function name is 'project_pages_projects_related_project' There are 3 different mentions of the word project, and the hook itself contains two. Can we change this to hook_related_project()? Created attachment 215439 [details]
Patch for shortened hook name
Attached is a patch for shortening the hook name, fixing a refactoring issue with mismatched variable name, and added the hook_related_projects call to the release module.
Created attachment 215440 [details]
Patch for shortened hook name
Same comment as before only this time i'll check the patch button
(In reply to comment #5) > There are 3 different mentions of the word project, and the hook itself > contains two. Can we change this to hook_related_project()? Pretty crazy. What is the Drupal convention for naming hooks? After a cursory Google search I found this post in a thread about naming hooks. http://grokbase.com/t/drupal/development/09afy65wr1/convention-for-naming-contrib-hooks#200910157s6kf9tq1gen8bamzq0mc1b63g Larry Garfield is a committer on Drupal Core if that lends any credence to his statement. It would seem your original proposal matches the convention. Its not pretty to read but i understand its purpose. Maybe hook_projects_related is enough? I also provided a stub implementation of the hook; I've seen this other modules. I think it's a good convention to provide a template implementation of every hook as it provides a convenient means of documenting the existence of the hook, providing documentation for its use, and makes content assist possible. Thoughts? I've switched it to hook_projects_related. Marking as FIXED. Created attachment 215492 [details]
mylyn/context/zip
I've committed some changes to a few modules that rename any function using the old _module_name_function_call to module_name__function call. |