Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/sale/checkout-form/src/form/ |
Upload File : |
import {Type} from 'main.core'; import {EventEmitter} from 'main.core.events'; import Form from './form'; import Model from './model'; import Scheme from './scheme'; export class EntityType { static FORM = 'form'; static MODEL = 'model'; static SCHEME = 'scheme'; } const entities = [ { type: EntityType.FORM, entity: Form }, { type: EntityType.MODEL, entity: Model }, { type: EntityType.SCHEME, entity: Scheme } ]; export default class Factory extends EventEmitter { static createForm(model: Object, scheme: Object, parameters: Object) { const modelEntity = this.create(EntityType.MODEL, model); const schemeEntity = this.create(EntityType.SCHEME, scheme); return this.create(EntityType.FORM, modelEntity, schemeEntity, parameters); } static create(type: string, ...options) { this.emit('BX.Sale.Checkout.Factory:onBeforeCreate', entities); let entity = entities.find((item) => { return item.type === type; })['entity']; if (!entity) { const eventData = {}; this.emit('BX.Sale.Checkout.Factory:onCreate', eventData); if (eventData[type]) { entity = eventData[type]; } } if (Type.isFunction(entity)) { return new entity(...options); } return null; } }