handler function(
 string language_id
The event OnBeforeLanguageDelete is called before language is deleted. Usually, the purpose of this event hander is to allow or deny language deletion.


language_id Deleted language ID.

Returned value

To cancel deletion of language and terminate the execution for the method CLanguage::Delete, throw an exception in the handler function via the method$APPLICATION->[link= 6658261]ThrowException()[/link] and return false.

See Also

Example of handler function:

// file /bitrix/modules/my_module_id/include.php
class MyClass
    // create the event handler "OnBeforeLanguageDelete"
    public static function OnBeforeLanguageDeleteHandler($language_id)
        // check if records, associated with deleted language are available
        $strSql = "SEL ECT * FR OM my_table WHERE LANGUAGE_ID=".$DB->ForSql($language_id);
        $rs = $DB->Query($strSql, false, "FILE: ".__FILE__."<br>LINE: ".__LINE__);

        // if associated records are available 
        if ($ar = $rs->Fetch()) 
            // deny the language deletion 
            global $APPLICATION;
            $APPLICATION->throwException("My table has the associated records.");
            return false;

Example of the handler function registration:

// register the event handler "OnBeforeLanguageDelete"
RegisterModuleDependences("main", "OnBeforeLanguageDelete", 
         "my_module_id", "MyClass", "OnBeforeLanguageDeleteHandler");

© «Bitrix24», 2001-2024