An open API service indexing awesome lists of open source software.

https://github.com/unb-libraries/custom-entity

A collection of modules to ease working with custom entities in Drupal.
https://github.com/unb-libraries/custom-entity

Last synced: about 1 year ago
JSON representation

A collection of modules to ease working with custom entities in Drupal.

Awesome Lists containing this project

README

          

# unb-libraries/custom-entity [![GitHub license](https://img.shields.io/github/license/unb-libraries/docker-einbaum)](https://github.com/unb-libraries/lib.unb.ca/blob/prod/LICENSE)
A Drupal module improving the developer experience of working with **_custom entities_**.

## Installation
The module is a composer package hosted on packagist and can be installed by running
```sh
composer require unb-libraries/custom-entity
```

or by adding it to your project's ```composer.json``` file:

```json
{
"require": {
"unb-libraries/custom-entity": "dev-9.x-1.x"
}
}
```

Enable the module by running
```sh
drush en custom_entity
```

or via the Drupal UI under ```/admin/modules```.

## Usage
The module enhances Drupal by providing implementations of:

### Access handlers
The ```Drupal\custom_entity\Entity\Access\EntityAccessControlHandler``` dynamically grants or denies access to an entity whether a user has permission of the form ``` entities```.

For example, in order for a user to get permission to ```edit``` a ```node``` entity, the user would need to have the ```edit node entities``` permission assigned to them.

In order to activate the access control handler, set it in an entity's type definition:

```php
() entities```. Add permissions handler for an entity type as follows:

```php
```: creates a form route for a given form handler, if ```my_entity``` defines the according link.

The following defines an entity with ```entity.my_entity.delete-all``` and ```entity.my_entity.activate``` routes:

```php