6

Accessing and Working with Entities

In this chapter, we will go through the create, read, update, and delete (CRUD) operations of working with entities in Drupal. We will create a series of routes to create, read, update, and delete nodes that are articles.

In this chapter, we will cover the following:

  • Creating and saving an entity
  • Querying and loading entities
  • Checking entity access
  • Updating an entity’s field values
  • Performing entity validation
  • Deleting an entity

Technical requirements

This chapter will require a custom module that has a routing.yml file and a controller named ArticleController in the src/Controller directory of the module. In the following recipes, the module name is mymodule. Replace as appropriate. You can find the full ...

Get Drupal 10 Development Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.