1

I created a Custom Content Entity Type with all the basic CRUD operations. It is working but I do not understand how the links work in the entity annotation and therefore not why they are necessary.

My annotation:

/**
* @ContentEntityType(
*   id = "myent",
*   label = @Translation("My entity"),
*   handlers = {
*     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
*     "list_builder" = "Drupal\myent\Controller\MyentListBuilder",
*     "form" = {
*       "add" = "Drupal\Core\Entity\ContentEntityForm",
*       "edit" = "Drupal\Core\Entity\ContentEntityForm",
*       "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
*     },
*     "access" = "Drupal\myent\ContactAccessControlHandler",
*   },
*   base_table = "myent",
*   entity_keys = {
*     "id" = "id",
*     "uuid" = "uuid",
*   },
*   links = {
*     "edit-form" = "/",
*     "delete-form" = "/",
*   },
* )
*/

As you can see I just inserted the necessary slash at the links section. The actual routes to the operations have to be defined in the "myent.routing.yml" no matter what so I do not see why I should write them again in the annotation.

If I remove the links section completely the operations are gone too. So I have to write the links section in the annotation even though they have no additional information for the operations.

What am I missing?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.