Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

0 votes

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-&...
Patrick Kenny's user avatar
0 votes

Content type title field not available in manage display

In Drupal 9.4 I had to select a layout first before the title field appeared in "manage display". See https://www.drupal.org/forum/support/post-installation/2013-12-26/why-doesnt-the-title-...
cweiske's user avatar
  • 154
0 votes

Listing two different custom entity types in one view

I fiddeled around this issue for quite some time... and found that Search API was the solution for my specific scenario. Create search index Add field A from content type "contacts" Add ...
mazze's user avatar
  • 1
2 votes
Accepted

How to inject RevisionableStorageInterface()?

You don't need to change custom code. The storage you have loaded from entityTypeManager has this interface if it is for a content entity type and not for config which is not revisionable. $storage = $...
4uk4's user avatar
  • 100k
2 votes

How to get a deep clone of an entity object

You can use the PHP standard clone operator: $clone = clone $entity; The base class for content entities implements the magic method ContentEntityBase::__clone() to deep clone the entity including ...
4uk4's user avatar
  • 100k
0 votes

Two-way Entity reference, programmatically

I ended up writing the custom save method. Inside Contact entity class: public function save() { // save contact entity (this will generate id for the contact record) parent::save(); /...
bdereta's user avatar
  • 151
0 votes

Add description to each entity reference

This might be an even easier solution: https://www.drupal.org/project/reference_value_pair The reference value pair combines an entity reference with a free text value field in one new field type. ...
Patrick Man's user avatar

Top 50 recent answers are included