/** * @param $query string * @param $object Contextual_Mysqli */ public function onError($query, Contextual_Mysqli $object) { if (in_array($object->last_errno, [Errors::ER_ROW_IS_REFERENCED, Errors::ER_ROW_IS_REFERENCED_2]) && $object->context && is_string($object->context) && $object->isDelete($query)) { $id = $this->extractId($query); if ($id) { $controller_uri = SL . $object->context . SL . $id . SL . 'deleteAndReplace'; echo (new Main())->runController($controller_uri, [Parameter::AS_WIDGET => true]); } } }