PHPackages                             heimrichhannot/contao-entity\_lock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. heimrichhannot/contao-entity\_lock

ActiveContao-module[Utility &amp; Helpers](/categories/utility)

heimrichhannot/contao-entity\_lock
==================================

A generic helper module to store locks for arbitrary entities in Contao.

1.1.3(9y ago)040LGPL-3.0+PHPPHP ~5.4 || ~7.0

Since Jun 29Pushed 9y ago4 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-entity_lock)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-entity_lock)[ Docs](https://github.com/heimrichhannot/contao-entity_lock)[ RSS](/packages/heimrichhannot-contao-entity-lock/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (6)Versions (13)Used By (0)

Entity Lock
===========

[](#entity-lock)

A generic module to store arbitrary entity locks in Contao.

Known limitations
-----------------

[](#known-limitations)

- backend user support is not done, yet -&gt; currently frontend handling only

Features
--------

[](#features)

- adds a lock entity for storing the current editor, lock time, locked entity, ...
- offers a rich model interface to easily handle creation, update and deletion of locks for any entity
- read the "Usage" chapter for more details on the functionality

Usage
-----

[](#usage)

The module is just a helper module for storing lock relevant information like the editor, the lock time, ...

The intended usage is as follows:

- Some kind of edit form is opened -&gt; Hence the currently edited record (aka entity) should be locked from another concurrent editing.
- A lock is created in the moment of the form's loading.
- On submit of the form the lock is removed and a the user has to be redirected to some other page in order to prevent the form from locking the entity again as happened in the previous step.
- In case of deletion of the entity, of course, all linked locks are also removed.
- The developer can specify how long the lock interval is (in the global settings or overrride it in the module config using *EntityLock::DEFAULT\_PALETTE*). After the age of a lock passed this interval it isn't active anymore (it times out).
- The developer can specify in a module's config whether any frontend user can delete active locks (e.g. if the lock is more a hint than a hard barrier)

A module developer using entity\_lock can store a new lock, check for their existance in the appropriate places and could use [heimrichhannot/contao-entity\_cleaner](https://github.com/heimrichhannot/contao-entity_cleaner)in order to remove elapsed locks.

In addition you could use [heimrichhannot/contao-frontendedit](https://github.com/heimrichhannot/contao-frontendedit) to build your frontend module, since it already supports entity\_lock, i.e. new locks are created automatically in frontend.

### Defining custom title fields for auto completion in the parent entity field in a lock

[](#defining-custom-title-fields-for-auto-completion-in-the-parent-entity-field-in-a-lock)

Extend `$GLOBALS['TL_CONFIG']['entityLockEntityTitleFields']` defined in config/config.php in order to define mapping for your custom entities. Otherwise auto completion will only use the id field.

Technical instructions
----------------------

[](#technical-instructions)

Do the following in your frontend module (or use [heimrichhannot/contao-frontendedit](https://github.com/heimrichhannot/contao-frontendedit) since it already does that for you):

1. Add the necessary fields to tl\_module and check addEntityLock in the module config in Contao:

```
$GLOBALS['TL_DCA']['tl_module']['palettes']['my_module'] .= \HeimrichHannot\EntityLock\EntityLock::DEFAULT_PALETTE;

```

2. Check for existing locks and create one if necessary:

    ```
    if ($this->addEntityLock && EntityLockModel::isLocked('tl_calendar_events', $objEvent->id, $this))
    {
        // do something like display a message that the entity is locked (or check for lock removal being allowed -> see 4.)
    }
    else
    {
        EntityLockModel::create('tl_calendar_events', $objEvent->id, $this);
    }

    ```
3. Remove all locks linked to a certain entity after submission of the edit form and on deletion of the entity:

    ```
    EntityLockModel::deleteLocks('tl_calendar_events', $objEvent->id);

    ```
4. If a frontend user should be able to take over some other user's record (i.e. delete a lock), you can check for that in the module as follows:

    ```
    $strMessage = EntityLock::generateErrorMessage('tl_calendar_events', $objEvent->id, $this);

    if ($this->allowLockDeletion)
    {
        // generateUnlockForm() also does the actual deletion of the lock and the sending of a notification to the former editor
        $strUnlockForm = $this->generateUnlockForm($objItem, $objLock);
        $strMessage .= $strUnlockForm;
    }

    ```

Hooks
-----

[](#hooks)

NameArgumentsDescriptioncustomizeLockErrorMessage$strMessage, $objLock, $objEditor, $objModuleHook for customizing the error message

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity65

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Recently: every ~75 days

Total

12

Last Release

3312d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/28ad3224d8727b622ebd229840eea6b9dbcb83eb0bd609e6ce65b614830ff538?d=identicon)[digitales@heimrich-hannot.de](/maintainers/digitales@heimrich-hannot.de)

---

Tags

lockingentityrecordmodulecontaoformdeveloperlock

### Embed Badge

![Health badge](/badges/heimrichhannot-contao-entity-lock/health.svg)

```
[![Health](https://phpackages.com/badges/heimrichhannot-contao-entity-lock/health.svg)](https://phpackages.com/packages/heimrichhannot-contao-entity-lock)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
