src/CRUDlex/AbstractData.php
protected function deleteChildren($id, $deleteCascade)
    {
        foreach ($this->definition->getChildren() as $childArray) {
            $childData = $this->definition->getService()->getData($childArray[2]);
            $children  = $childData->listEntries([$childArray[1] => $id]);
            foreach ($children as $child) {
                $result = $childData->events->shouldExecute($child, 'before', 'delete');
                if (!$result) {
                    return static::DELETION_FAILED_EVENT;
                }
                $childData->doDelete($child, $deleteCascade);
                $childData->events->shouldExecute($child, 'after', 'delete');
            }
        }
        return static::DELETION_SUCCESS;
    }
protected function deleteChildren($id, $deleteCascade)
    {
        foreach ($this->definition->getChildren() as $childArray) {
            $childData = $this->definition->getService()->getData($childArray[2]);
            $children  = $childData->listEntries([$childArray[1] => $id]);
            foreach ($children as $child) {
                $result = $childData->events->shouldExecute($child, 'before', 'delete');
                if (!$result) {
                    return static::DELETION_FAILED_EVENT;
                }
                $childData->doDelete($child, $deleteCascade);
                $childData->events->shouldExecute($child, 'after', 'delete');
            }
        }
        return static::DELETION_SUCCESS;
    }
protected function deleteChildren ( $ id , $ deleteCascade ) { foreach ( $ this -> definition -> getChildren ( ) as $ childArray ) { $ childData = $ this -> definition -> getService ( ) -> getData ( $ childArray [ 2 ] ) ; $ children = $ childData -> listEntries ( [ $ childArray [ 1 ] => $ id ] ) ; foreach ( $ children as $ child ) { $ result = $ childData -> events -> shouldExecute ( $ child , 'before' , 'delete' ) ; if ( ! $ result ) { return static :: DELETION_FAILED_EVENT ; } $ childData -> doDelete ( $ child , $ deleteCascade ) ; $ childData -> events -> shouldExecute ( $ child , 'after' , 'delete' ) ; } } return static :: DELETION_SUCCESS ; }
Performs the cascading children deletion.

@param integer $id
the current entities id
@param boolean $deleteCascade
whether to delete children and sub children

@return integer
returns one of:
- AbstractData::DELETION_SUCCESS -> successful deletion
- AbstractData::DELETION_FAILED_STILL_REFERENCED -> failed deletion due to existing references
- AbstractData::DELETION_FAILED_EVENT -> failed deletion due to a failed before delete event
Performs the cascading children deletion .