OnDelete Hook

Overview

Event fired before entity is deleted.

This hook is called before performing cascade deletion/nullification on other entities.

Boolean value returned by the hook's method determines if deletion operation can be performed (returning false prevents entity from being deleted).

Common Attributes

name

type

required

default value

description

class

string

yes

none

Name of the class defining hook.

method

string

yes

none

Name of the method defining hook.

Example

<onDelete class="com.sample.SampleHook" method="checkIfCanDeleteEntity" />

Hook method signature

public boolean checkIfCanDeleteEntity(final DataDefinition dataDefinition, final Entity entity) {
    // ...
} 

Hook method example

public boolean checkIfCanDeleteEntity(final DataDefinition dataDefinition, final Entity entity) {
    if (someCondition()) {
        entity.addGlobalError(..);
        return false;
    }
    return true;
}Â