fix
This commit is contained in:
+42
-20
@@ -1,4 +1,4 @@
|
||||
<?
|
||||
<?php
|
||||
|
||||
use Bitrix\Main\EventManager;
|
||||
|
||||
@@ -9,11 +9,11 @@ class bx_nullable extends \CModule
|
||||
public $module = [];
|
||||
var $MODULE_GROUP_RIGHTS = 'Y';
|
||||
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$module = [];
|
||||
if(file_exists(__DIR__.'/../.module.json')){
|
||||
$module = json_decode(file_get_contents(__DIR__.'/../.module.json'), true);
|
||||
if (file_exists(__DIR__ . '/../.module.json')) {
|
||||
$module = json_decode(file_get_contents(__DIR__ . '/../.module.json'), true);
|
||||
}
|
||||
|
||||
$this->module = $module;
|
||||
@@ -25,18 +25,18 @@ class bx_nullable extends \CModule
|
||||
$langPrefix = $module['prefix'];
|
||||
|
||||
$this->PARTNER_NAME = GetMessage("{$langPrefix}_partner_name");
|
||||
$this->PARTNER_URI = GetMessage("{$langPrefix}_partner_uri");
|
||||
$this->PARTNER_URI = GetMessage("{$langPrefix}_partner_uri");
|
||||
$this->MODULE_NAME = GetMessage("{$langPrefix}_module_name");
|
||||
$this->MODULE_DESCRIPTION = GetMessage("{$langPrefix}_module_description");
|
||||
}
|
||||
|
||||
|
||||
function DoInstall()
|
||||
public function DoInstall()
|
||||
{
|
||||
global $DOCUMENT_ROOT, $APPLICATION;
|
||||
global $APPLICATION;
|
||||
|
||||
if(is_array($this->module['deps'])){
|
||||
foreach ($this->module['deps'] as $moduleId){
|
||||
if (is_array($this->module['deps'])) {
|
||||
foreach ($this->module['deps'] as $moduleId) {
|
||||
if (!\Bitrix\Main\Loader::includeModule($moduleId)) {
|
||||
$APPLICATION->ThrowException("Module {$moduleId} not installed!");
|
||||
return false;
|
||||
@@ -44,13 +44,13 @@ class bx_nullable extends \CModule
|
||||
}
|
||||
}
|
||||
|
||||
if (!CheckVersion(PHP_VERSION, "5.4.0")) {
|
||||
if (!CheckVersion(PHP_VERSION, '5.4.0')) {
|
||||
$APPLICATION->ThrowException('Php version required more 5.4.0');
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisterModule($this->MODULE_ID);
|
||||
RegisterModuleDependences("main", "OnPageStart", $this->MODULE_ID);
|
||||
RegisterModuleDependences('main', 'OnPageStart', $this->MODULE_ID);
|
||||
$this->InstallEvents();
|
||||
$this->InstallCatalogExport();
|
||||
|
||||
@@ -58,37 +58,59 @@ class bx_nullable extends \CModule
|
||||
return true;
|
||||
}
|
||||
|
||||
function DoUninstall()
|
||||
public function DoUninstall()
|
||||
{
|
||||
global $DOCUMENT_ROOT, $APPLICATION;
|
||||
global $APPLICATION;
|
||||
UnRegisterModule($this->MODULE_ID);
|
||||
UnRegisterModuleDependences("main", "OnPageStart", $this->MODULE_ID, "", "");
|
||||
UnRegisterModuleDependences('main', 'OnPageStart', $this->MODULE_ID, '', '');
|
||||
$this->UnInstallEvents();
|
||||
$this->UnInstallCatalogExport();
|
||||
return true;
|
||||
}
|
||||
|
||||
function InstallCatalogExport()
|
||||
public function InstallCatalogExport()
|
||||
{
|
||||
if(is_dir(__DIR__."/catalog_export") && \Bitrix\Main\Loader::includeModule('catalog')){
|
||||
CopyDirFiles(__DIR__."/catalog_export", $_SERVER["DOCUMENT_ROOT"].CATALOG_PATH2EXPORTS, true, true);
|
||||
if (is_dir(__DIR__ . '/catalog_export') && \Bitrix\Main\Loader::includeModule('catalog')) {
|
||||
CopyDirFiles(__DIR__ . '/catalog_export', $_SERVER['DOCUMENT_ROOT'] . CATALOG_PATH2EXPORTS, true, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function UnInstallCatalogExport()
|
||||
public function UnInstallCatalogExport()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function InstallEvents()
|
||||
public function InstallEvents()
|
||||
{
|
||||
if (class_exists('\Bitrix\Main\EventManager')) {
|
||||
$eventManager = EventManager::getInstance();
|
||||
// $eventManager->registerEventHandler(
|
||||
// 'main',
|
||||
// 'OnPageStart',
|
||||
// $this->MODULE_ID,
|
||||
// 'Bx\Nullable\Handler\Handler',
|
||||
// 'exec',
|
||||
// 100
|
||||
// );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function UnInstallEvents()
|
||||
public function UnInstallEvents()
|
||||
{
|
||||
if (class_exists('\Bitrix\Main\EventManager')) {
|
||||
$eventManager = \Bitrix\Main\EventManager::getInstance();
|
||||
// $eventManager->unRegisterEventHandler(
|
||||
// 'main',
|
||||
// 'OnPageStart',
|
||||
// $this->MODULE_ID,
|
||||
// 'Bx\Nullable\Handler\Handler',
|
||||
// 'exec'
|
||||
// );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user