Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 5147

Nodes, comments, taxonomy terms, and users, in the terminology used since Drupal 7, are generally called "entities."

1 vote
Accepted

Best practice design route for an estimates table

If needs change and you need to rework the feature, it's much easier to have your data in Drupal stored as entities. …
Patrick Kenny's user avatar
0 votes
Accepted

How to restrict access to GET with JSON:API for specific entity type?

Thanks to bradjones1 for pointing me in the right direction on Slack. PATCH and DELETE routes can be removed, but for GET, it is better to check access to avoid problems: protected function alterRou …
Patrick Kenny's user avatar
0 votes
1 answer
41 views

How to restrict access to GET with JSON:API for specific entity type?

According to the JSON:API docs, you can implement the alterRoutes() method on a route subscriber to restrict access to collections. In a custom module, I have an entity type that should be POST only …
Patrick Kenny's user avatar
0 votes
Accepted

"Route does not exist" in JSON:API for custom entity type

The error was a RouteSubscriber that was restricting the route as described here. Make sure nothing is calling alterRoutes() and modifying the JSON:API response.
Patrick Kenny's user avatar
0 votes
0 answers
16 views

In ListBuilder, UUID sometimes shown for anonymous

On ddev, when I go to admin/content/my-entity, for entities created by the anonymous user, I see Anonymous as the author. … However, on a platform.sh server, for entities created by the anonymous user, I see the UUID of the anonymous user as the author. Why am I seeing this difference in the display? …
Patrick Kenny's user avatar
0 votes
1 answer
61 views

"Route does not exist" in JSON:API for custom entity type

I can add my custom entities at admin/content as expected. … I've created other custom entities with drush and I haven't had this problem accessing them via JSON:API before. …
Patrick Kenny's user avatar
1 vote

How to get the title of a referenced entity with `?_format=json`?

JSON:API returns ID, UUID, and URL because that's the spec. If you want more properties, like the title or the content body, you have to include those. See the documentation on includes. Also two usef …
Patrick Kenny's user avatar
1 vote
Accepted

How to duplicate the Node entity?

So you can't just copy it by changing the name and have all the same features. 5,000 additional nodes vs. 5,000 custom entities will probably not be a huge difference in performance, although it's impossible … In particular, this allows you to create simplified entities that do not have revisioning, translations, and so on, which can improve performance. …
Patrick Kenny's user avatar
0 votes
Accepted

How to prevent the anonymous user from being the author of a custom entity type?

I decided to fix this in the preSave() method: /** * {@inheritdoc} */ public function preSave(EntityStorageInterface $storage): void { parent::preSave($storage); $owner_id = $this->g …
Patrick Kenny's user avatar
0 votes
1 answer
26 views

How to prevent the anonymous user from being the author of a custom entity type?

I am making a module that stores push notification tokens as a custom entity type. Because of the nature of push notification tokens (sending a notification to the user's device, like an email address …
Patrick Kenny's user avatar
0 votes
1 answer
232 views

How to inject RevisionableStorageInterface()?

I have a module I'm trying to update to Drupal 11. Here's the code: public function processItem($data) { $entity_type = $this->entityTypeManager->getDefinition($data['entity_type']); $storag …
Patrick Kenny's user avatar
1 vote

How to return different entity reference fields from multiple bundles using the same name wi...

From a #decoupled Slack conversation, bbrala (JSON:API maintainer) stated: Don't think there is a supported way to do that other than extending and overwriting the controller that handles responses. …
Patrick Kenny's user avatar
0 votes
1 answer
276 views

How to return different entity reference fields from multiple bundles using the same name wi...

The Goal My site structure looks like this: Node content type A with entity reference field groupA pointing to a term with field groupAfield Node content type B with entity reference field groupB poi …
Patrick Kenny's user avatar
0 votes
1 answer
67 views

How can I setRequired() for a BaseFieldDefinition per entity bundle?

I have an entity type animal with the following bundles: cow pig sparrow anteater In the Animal.php entity type definition, I create some base fields, one of which is an entity reference to Habitat. …
Patrick Kenny's user avatar
0 votes
0 answers
168 views

How to use setConstraints() for a custom constraint on BaseFieldDefinition?

I'm refactoring a node content type into a custom entity. On this entity, I add a datetime field: $fields['target_date'] = BaseFieldDefinition::create('datetime') ->setLabel(t('Target date') …
Patrick Kenny's user avatar

1
2 3 4 5
9
15 30 50 per page