/**
  * Удаление элемента. Можно переопределить, если требуется сложная логика и нет возможности определить её в модели.
  *
  * @param $id
  * 
  * @return bool|\Bitrix\Main\Entity\DeleteResult
  * 
  * @throws \Exception
  * 
  * @api
  */
 protected function deleteElement($id)
 {
     if (!$this->hasDeleteRights()) {
         $this->addErrors(Loc::getMessage('DIGITALWAND_ADMIN_HELPER_EDIT_DELETE_FORBIDDEN'));
         return false;
     }
     $className = static::getModel();
     $entityManager = new EntityManager($className, array(), $id, $this);
     $deleteResult = $entityManager->delete();
     $this->addNotes($entityManager->getNotes());
     return $deleteResult;
 }
 /**
  * Обработчик групповых операций. По-умолчанию прописаны операции активации / деактивации и удаления.
  *
  * @param array $IDs
  * @param string $action
  *
  * @api
  */
 protected function groupActions($IDs, $action)
 {
     $sectionEditHelperClass = $this->getHelperClass(AdminSectionEditHelper::className());
     $listHelperClass = $this->getHelperClass(AdminListHelper::className());
     if (!isset($_REQUEST['model'])) {
         $className = static::getModel();
     } else {
         $className = $_REQUEST['model'];
     }
     if ($sectionEditHelperClass && !isset($_REQUEST['model-section'])) {
         $sectionClassName = $sectionEditHelperClass::getModel();
     } else {
         $sectionClassName = $_REQUEST['model-section'];
     }
     if ($action == 'delete') {
         if ($this->hasDeleteRights()) {
             $params = $_GET;
             unset($params['action']);
             unset($params['action_button']);
             unset($params['ID']);
             if ($sectionEditHelperClass) {
                 $sectionField = !isset($_REQUEST['model']) ? static::getSectionField() : $sectionEditHelperClass::getSectionField();
                 $element = $className::getById($IDs[0])->Fetch();
                 if ($element[$sectionField]) {
                     $params['ID'] = $element[$sectionField];
                 }
             }
             foreach ($IDs as $id) {
                 $entityManager = new EntityManager($className, array(), $id, $this);
                 $result = $entityManager->delete();
                 $this->addNotes($entityManager->getNotes());
                 if (!$result->isSuccess()) {
                     $this->addErrors($result->getErrorMessages());
                     break;
                 }
             }
             LocalRedirect($listHelperClass::getUrl($params));
         } else {
             $this->addErrors(Loc::getMessage('DIGITALWAND_ADMIN_HELPER_LIST_DELETE_FORBIDDEN'));
         }
     }
     if ($action == 'delete-section') {
         if ($this->hasDeleteRights()) {
             $section = $sectionClassName::getById($IDs[0])->Fetch();
             $sectionField = $sectionEditHelperClass::getSectionField();
             $params = $_GET;
             unset($params['action']);
             unset($params['action_button']);
             unset($params['ID']);
             if ($section[$sectionField]) {
                 $params['ID'] = $section[$sectionField];
             }
             foreach ($IDs as $id) {
                 $sectionClassName::delete($id);
             }
             LocalRedirect($listHelperClass::getUrl($params));
         } else {
             $this->addErrors(Loc::getMessage('DIGITALWAND_ADMIN_HELPER_LIST_DELETE_FORBIDDEN'));
         }
     }
 }