I created a custom plugin block that relies on RedHen Contacts for context (any of the RedHen entities will do). At the top of the block definition, I added in a context, like so:

/**
 *
 * @Block(
 *   id = "example_block",
 *   admin_label = @Translation("Example Block"),
 *   context = {
 *     "redhen_contact" = @ContextDefinition(
 *       "entity:redhen_contact",
 *       label = @Translation("Contact"),
 *       required = FALSE,
 *     )
 *   }
 * )
 */

When I try to place the block in a region, I now see an option to select how the context will be set.

However, it has no options in the select widget.

As it turns out, it appears that the entities would require ContextProvider classes to be created, in order for this to work.

The example for Node shows the "Node from URL" option being set in the comments section.

@see: https://api.drupal.org/api/drupal/core%21modules%21node%21src%21ContextP...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jeremylichtman created an issue. See original summary.

jeremylichtman’s picture

Adding patch for Org and Contact.

gcb’s picture

Assigned: Unassigned » gcb
gcb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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