This module provides a new type of entities that cannot be created or deleted using the Drupal UI. This is valid also for site administrators with full privileges.

Permanent entities can only be created and deleted by code (using hook_update_N or via drush commands). Edit permissions are available per bundle.

Use cases

The main use case of this module is to have regular entities that you don't want to be deleted by error by a content administrator. Also this usually applies for a set of content that rarely varies over time. Like the planets of the solar system, the districts of a city, weather season, etc.

Users will still be able to edit and translate this entities. But they won't be able to delete them, or create new ones using an user interface.

Mode of use

Before create a permanent entity, you will need to create a Permanent Entity Type. This can be done via admin/structure/permanent_entity_types Then you can create instances either using drush:

drush pec planet jupiter Jupiter

Or using PHP code:

    use Drupal\permanent_entities\Entity\PermanentEntity;
    PermanentEntity::create([
      'id' => 'jupiter',
      'label' => 'Jupiter',
      'type' => 'planet',
    ])->save();

Finally all permanent entities can be edited or translated via /admin/content/permanent_entities

Do you want to know more?

Checkout the documentation.

Supporting organizations: 

Project information

Releases