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.
- Host: GitHub
- URL: https://github.com/unb-libraries/custom-entity
- Owner: unb-libraries
- License: mit
- Created: 2021-09-13T19:08:59.000Z (almost 5 years ago)
- Default Branch: 9.x-1.x
- Last Pushed: 2023-07-25T11:01:50.000Z (almost 3 years ago)
- Last Synced: 2025-03-16T07:06:29.629Z (over 1 year ago)
- Language: PHP
- Size: 172 KB
- Stars: 1
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unb-libraries/custom-entity [](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