Over at #1549808: Port the lame D6 node/add/project-issue UI to D7 there's a patch that would really benefit from a project_issue_entity_bundles() helper function, similar to project_project_entity_bundles() from #1549538: Add a function to determine if a node or node type is a project. That'll help us write code that properly handles the fact that many different node types (aka entity bundles) can behave as issue types.

On projects, we know a node type is a project via the existence of the project_type field. However, for issues, there's just a per-node-type setting that controls this. See #1569524: Add a 'Project settings' tab on node type edit forms for more. So this function needs to ask core for all the node types on the system, iterate over them, and for each one, check this setting.

While we're at it, we might as well add functions like project_issue_entity_bundle_is_issue() and project_issue_node_is_issue($node). See the equivalents in project.module for more.

Since we need this for other things, assigning this to sprint 2.

CommentFileSizeAuthor
#3 1580178-3.pi-node-type-helpers.patch1.8 KBdww

Comments

dww’s picture

Title: Add a project_issue_entity_bundles() function » Add helper functions to handle multiple node types behaving as issues

I updated the summary to expand the scope a bit, so re-titling.

dww’s picture

Assigned: Unassigned » dww

I'll take a quick stab at this. Stay tuned.

dww’s picture

Status: Active » Needs review
StatusFileSize
new1.8 KB

After looking more closely at the project.module code, I want to reopen #1549538: Add a function to determine if a node or node type is a project. ;) It's a bit of a confused mess of trying to be entity-generic but ultimately relying on the fact that we assume nodes, anyway. I think it's going to be simpler and cleaner to just embrace the fact that we're assuming nodes for all this stuff, and make the API match that. So, here's my proposed API for project_issue. If folks are cool with this, I'll fix project.module to match.

Thoughts?
-Derek

mikey_p’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, I don't see any particular reason to use node_type_get_names() over any of the other node_type_get*() functions so I don't suppose that makes any difference.

dww’s picture

Status: Reviewed & tested by the community » Fixed

Yeah, I was using node_type_get_names() before I realized that was labels, not machine_names. But, I still get what I need in the keys, so that seemed as good as any. ;)

Anyway, tested again locally and committed/pushed.

Thanks for the review!
-Derek

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

expanding summary to talk about how this should work and to request a few other helper functions