I'm currently creating a custom 'sticky' queue handler that will keep entities containing a boolean field with a true value in the same position in the queue, no matter what is added to the queue, until the user manually removes the sticky item from the list.

In order to do this cleanly, I need someway to override the entityreference behavior on only this queue type. Specifically, I need to write new implementations of the validate() and presave() methods of EntityReferenceBehavior_EntityQueue to calculate the new order of the queue.

I didn't see anyway to do that without modifying the module code. If there's a different way I should be approaching this, I'm open to that as well. Would be willing to try to create a patch if I can get some direction as to how to proceed. Thanks.

CommentFileSizeAuthor
#1 behavior-per-handler-2448115-1.patch6.02 KBbropp

Comments

bropp’s picture

Status: Active » Needs review
StatusFileSize
new6.02 KB

First attempt at a patch.

Creates two new methods on the queue handler: validateItems() and preSaveItems(). These are called inside of the entityreference behavior allowing each queue type to have its own implementation if desired.

The simple queue is given the current behavior implementation (from which multiple subqueue inherits), so no default functionality should differ.

jojonaloha’s picture

Status: Needs review » Needs work

I haven't tested it yet, but I think the implementation looks solid. I'm just curious why you can't subclass EntityReferenceBehavior_EntityQueue? Think I just need an explanation of how this solves the problem where subclassing EntityReferenceBehavior_EntityQueue won't.

Also, I think you'll need to change $queue to $this->queue in the SimpleEntityQueueHandler methods.

amateescu’s picture

Status: Needs work » Closed (outdated)

Closing issues for the 7.x version, which is not supported anymore.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.