Score:3

How to setup access dependency on a block content created programatically

ng flag

In Drupal 8, I am creating block instances (BlockContent) for node layouts programatically and setting them all as non-reusable. That causes a following access error: "Non-reusable blocks must set an access dependency".

How do I set access dependency on an existing block instance (or during it's creation)? Was never in a position to have to manipulate access from such angle and I can't find a good example for this.

Score:0
bd flag

The BlockContent class uses the RefinableDependentAccessTrait which has 2 methods that can be used to add/set access dependencies:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.