Documentation

onBeforeSiteRecycle

Event is executed when site moved into/restored from into recycle bin. Event is not triggered when directly deleting a physical site, use the standard method ORM for this purpose (Learn more).

Parameters

Class Description Available from version
id Site ID.
delete Flag (Y – moving to recycle bin; N – returning from recycle bin).

Event allows denying moving into recycle bin and a required code must be commented in the example.

EXample

$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler('landing', 'onBeforeSiteRecycle',
   function(\Bitrix\Main\Event $event)
   {
      $result = new \Bitrix\Main\Entity\EventResult;

      $id = $event->getParameter('id');
      $delete = $event->getParameter('delete');

      AddMessage2Log(
         ('запись ' . $id) .
         ($delete ? ' moved to recycle bin' : ' returned from recycle bin')
      );

      /*$result->setErrors(array(
         new \Bitrix\Main\Entity\EntityError(
            'Deleting denied!',
            'DELETE_DISABLED'
         )
      ));*/

      return $result;
   }
);


© «Bitrix24», 2001-2024
Up