isExists()) { $file->putContents(""); } } public function subscriptionSetup() { $pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . Constants::MODULE_ID . '/install'; CopyDirFiles( $pathFrom . '/export/sub-register', $_SERVER['DOCUMENT_ROOT'] . '/sub-register', true, true, false ); $templateNames = [ 'default_subscribe' => [ 0 => [ 'name' => 'sale.personal.section', 'templateDirectory' => '.default' ], 1 => [ 'name' => 'main.register', 'templateDirectory' => '.default_subscribe' ] ] ]; foreach ($templateNames as $directory => $templates) { foreach ($templates as $template) { $this->copy($directory, $template); } } $property = [ 'ENTITY_ID' => 'USER', 'FIELD_NAME' => 'UF_SUBSCRIBE_USER_EMAIL', 'USER_TYPE_ID' => 'boolean', 'MULTIPLE' => 'N', 'MANDATORY' => 'N', 'EDIT_FORM_LABEL' => ['ru' => GetMessage('UF_SUBSCRIBE_USER_EMAIL_TITLE')], ]; $obUserField = new CUserTypeEntity(); $dbRes = CUserTypeEntity::GetList([], ['FIELD_NAME' => 'UF_SUBSCRIBE_USER_EMAIL'])->fetch(); if (!$dbRes['ID']) { $obUserField->Add($property); } } private function copy($directory, $template): void { $templatePath = $_SERVER['DOCUMENT_ROOT'] . '/local/templates/.default/components/bitrix/' . $template['name'] . '/'. $directory ; if (!file_exists($templatePath)) { $pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/intaro.retailcrm/install/export/local/components/intaro/' . $template['name'] . '/templates/' . $template['templateDirectory'] ; CopyDirFiles( $pathFrom, $templatePath, true, true, false ); } } }