|
| 1 | +<?php |
| 2 | + |
| 3 | +defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die(); |
| 4 | + |
| 5 | +use Bitrix\Main\Config\Configuration; |
| 6 | +use Bitrix\Main\ModuleManager; |
| 7 | + |
| 8 | +/** |
| 9 | + * Class webpractik_sentry |
| 10 | + */ |
| 11 | +Class webpractik_sentry extends \CModule |
| 12 | +{ |
| 13 | + |
| 14 | + private static $arParametersForFullInstall = [ |
| 15 | + 'debug' => false, |
| 16 | + 'handled_errors_types' => 4437, |
| 17 | + 'exception_errors_types' => 4437, |
| 18 | + 'ignore_silence' => false, |
| 19 | + 'assertion_throws_exception' => true, |
| 20 | + 'assertion_error_type' => 256, |
| 21 | + 'log' => |
| 22 | + array ( |
| 23 | + 'settings' => |
| 24 | + array ( |
| 25 | + 'file' => 'local/php_interface/error.log', |
| 26 | + 'log_size' => 1000000, |
| 27 | + ), |
| 28 | + 'class_name' => '\\Webpractik\\Sentry\\ExceptionMailer', |
| 29 | + 'extension' => '', |
| 30 | + 'required_file' => '/modules/webpractik.sentry/lib/exceptionmailer.php', |
| 31 | + ), |
| 32 | + ]; |
| 33 | + |
| 34 | + private static $arParametersForPartialInstall = [ |
| 35 | + 'class_name' => '\\Webpractik\\Sentry\\ExceptionMailer', |
| 36 | + 'extension' => '', |
| 37 | + 'required_file' => '/modules/webpractik.sentry/lib/exceptionmailer.php', |
| 38 | + ]; |
| 39 | + /** |
| 40 | + * webpractik_sentry constructor. |
| 41 | + */ |
| 42 | + public function __construct() |
| 43 | + { |
| 44 | + $arModuleVersion = []; |
| 45 | + include __DIR__ . '/version.php'; |
| 46 | + |
| 47 | + $this->MODULE_NAME = 'Webpractik'; |
| 48 | + $this->MODULE_DESCRIPTION = 'Модуль для отправки логов в sentry'; |
| 49 | + $this->MODULE_ID = 'webpractik.sentry'; |
| 50 | + $this->MODULE_VERSION = $arModuleVersion['VERSION']; |
| 51 | + $this->MODULE_VERSION_DATE = $arModuleVersion['VERSION_DATE']; |
| 52 | + $this->MODULE_GROUP_RIGHTS = 'N'; |
| 53 | + $this->PARTNER_NAME = 'Webpractik'; |
| 54 | + $this->PARTNER_URI = 'https://webpractik.ru'; |
| 55 | + } |
| 56 | + |
| 57 | + public function DoInstall() |
| 58 | + { |
| 59 | + ModuleManager::registerModule($this->MODULE_ID); |
| 60 | + $this->addPointToSettings(); |
| 61 | + } |
| 62 | + |
| 63 | + public function DoUninstall() |
| 64 | + { |
| 65 | + ModuleManager::unRegisterModule($this->MODULE_ID); |
| 66 | + } |
| 67 | + |
| 68 | + public function addPointToSettings() |
| 69 | + { |
| 70 | + $configuration = Configuration::getInstance(); |
| 71 | + |
| 72 | + if(empty($configuration['exception_handling']) || (int)$configuration['exception_handling']['handled_errors_types'] !== 4437) { |
| 73 | + $configuration->add('exception_handling', self::$arParametersForFullInstall); |
| 74 | + $configuration->saveConfiguration(); |
| 75 | + |
| 76 | + } else { |
| 77 | + $fconf = $configuration['exception_handling']; |
| 78 | + $log = array_merge($configuration['exception_handling']['log'], self::$arParametersForPartialInstall); |
| 79 | + $fconf['log'] = $log; |
| 80 | + $configuration->add('exception_handling', $fconf); |
| 81 | + $configuration->saveConfiguration(); |
| 82 | + } |
| 83 | + } |
| 84 | +} |
0 commit comments