{"id":472677,"date":"2025-08-30T15:01:17","date_gmt":"2025-08-30T15:01:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=472677"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=472677","title":{"rendered":"<span>\u0411\u0438\u0442\u0440\u0438\u043a\u044124 Factory, Operation, Action \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043d\u043e\u0432\u044b\u043c API CRM \u0438 \u0441\u0442\u0440\u043e\u0438\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u044f\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/dev.1c-bitrix.ru\/api_d7\/bitrix\/crm\/crm%5C_new%5C_api.php\" rel=\"noopener noreferrer nofollow\">\u043d\u043e\u0432\u043e\u0435 API CRM<\/a> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0432 Bitrix24.<\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 (\u0441\u0434\u0435\u043b\u043a\u0438, \u043b\u0438\u0434\u044b, \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u044b \u0438 \u0442.\u043f.) \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (\u0441\u043e\u0431\u044b\u0442\u0438\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c). \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443 \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u044f\u0436\u0435\u043b\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c. \u041d\u043e\u0432\u043e\u0435 API \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u0438 \u043c\u043e\u0449\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 (\u041e\u041e\u041f).<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438:\u00a0<\/p>\n<ul>\n<li>\n<p>\u0421\u043a\u0443\u0434\u043d\u0430\u044f \u0438 \u0441\u0443\u0445\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u0438 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0431\u0430\u0433\u0438<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u0434\u0430\u0447\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<ul>\n<li>\n<p><strong>\u041e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b:<\/strong> \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 API CRM.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443<\/strong>: \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/strong>: \u0434\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u043e\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u043e\u043a\u0443\u0441 \u043c\u044b \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u2014 \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0443\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d \u0438 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043d\u0430 Habr.<\/p>\n<h3>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 API CRM: \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 Service Locator<\/h3>\n<p>\u0412\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043d\u043e\u0432\u043e\u043c API CRM \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 <a href=\"https:\/\/dev.1c-bitrix.ru\/learning\/course\/index.php?COURSE%5C_ID=43&amp;LESSON%5C_ID=14032\" rel=\"noopener noreferrer nofollow\">Service Locator <\/a>(\u0421\u0435\u0440\u0432\u0438\u0441-\u043b\u043e\u043a\u0430\u0442\u043e\u0440). \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e.<\/p>\n<h4>1. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/h4>\n<p>\u0411\u0438\u0442\u0440\u0438\u043a\u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b-\u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 CRM. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <code>bitrix\/modules\/crm\/.settings.php<\/code>:<\/p>\n<pre><code class=\"php\">'crm.service.factory.contact' =&gt; [     'className' =&gt; '\\\\Bitrix\\\\Crm\\\\Service\\\\Factory\\\\Contact', ],<\/code><\/pre>\n<h4>2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/h4>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 Service Locator \/** @var \\Bitrix\\Crm\\Service\\Factory\\Contact $factory *\/ $factory = \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()     -&gt;get('crm.service.factory.contact');<\/code><\/pre>\n<h4>3. \u041f\u043e\u0434\u043c\u0435\u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (\u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f)<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0435\u0433\u043e \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<pre><code class=\"php\">\/\/ \u041d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 class ContactFactory extends \\Bitrix\\Crm\\Service\\Factory\\Contact {     \/\/ \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0435 \u043d\u0430 \u043d\u0430\u0448:  <\/p>\n<pre><code class=\"php\">\/\/ \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0441\u0432\u043e\u0435\u0439 \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()     -&gt;addInstance('crm.service.factory.contact', new ContactFactory());<\/code><\/pre>\n<h4>4. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044b<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0430\u0448 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440:<\/p>\n<pre><code class=\"php\">\/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 ContactFactory \/** @var ContactFactory $factory *\/ $factory = \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()     -&gt;get('crm.service.factory.contact');<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u0448\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430.<\/p>\n<h4>5. \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Container<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0411\u0438\u0442\u0440\u0438\u043a\u044124 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443 Container. \u0415\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">\/\/ \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 Container \/\/ \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u043e\u043d \u0442\u043e\u0436\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \/** @var ContactFactory $factory *\/ $factory = \\Bitrix\\Crm\\Service\\Container::getInstance()     -&gt;getFactory(\\CCrmOwnerType::Contact);<\/code><\/pre>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u2014 \u044d\u0442\u043e \u043a\u043b\u044e\u0447 \u043a \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e API. \u0412\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u0435.  <\/p>\n<h3>Factory, Operation \u0438 Action: \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u043e\u0432\u043e\u0433\u043e API, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0430 \u0441\u0445\u0435\u043c\u0435. \u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e30\/e07\/7ed\/e30e077ed6ab128d938306892cebc082.png\" alt=\"UML Factory, Operation \u0438 Action\" title=\"UML Factory, Operation \u0438 Action\" width=\"1201\" height=\"254\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e30\/e07\/7ed\/e30e077ed6ab128d938306892cebc082.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e30\/e07\/7ed\/e30e077ed6ab128d938306892cebc082.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>UML Factory, Operation \u0438 Action<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9e1\/807\/2c0\/9e18072c052b8cbf4b1e0c838c5829d2.png\" alt=\"\u0412\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432\" title=\"\u0412\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432\" width=\"421\" height=\"331\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/9e1\/807\/2c0\/9e18072c052b8cbf4b1e0c838c5829d2.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9e1\/807\/2c0\/9e18072c052b8cbf4b1e0c838c5829d2.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<h4>1. Factory (\u0424\u0430\u0431\u0440\u0438\u043a\u0430)<\/h4>\n<ul>\n<li>\n<p><strong>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u044f<\/strong>: \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <a href=\"https:\/\/designpatternsphp.readthedocs.io\/ru\/latest\/Creational\/FactoryMethod\/README.html\" rel=\"noopener noreferrer nofollow\">\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u041c\u0435\u0442\u043e\u0434 (Factory Method)<\/a>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b Operation (\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 CRM.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440<\/strong>: <code>DinamicFactory<\/code> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e <code>Service\\Factory<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0427\u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442<\/strong>: \u0422\u0440\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439:<\/p>\n<ul>\n<li>\n<p><code>getAddOperation()<\/code> \u2192 <code>Operation\\Add<\/code> (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p><code>getUpdateOperation()<\/code> \u2192 <code>Operation\\Update<\/code> (\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p><code>getDeleteOperation()<\/code> \u2192 <code>Operation\\Delete<\/code> (\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>2. Operation (\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f)<\/h4>\n<ul>\n<li>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c (\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435).<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/strong>: \u041a\u0430\u0436\u0434\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 <code>Action<\/code> \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432 \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438.<\/p>\n<\/li>\n<\/ul>\n<h4>3. Action (\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435)<\/h4>\n<ul>\n<li>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u042d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439, \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 (\u0432\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u0434).<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/strong>: \u0412\u0430\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u2014 <code>process()<\/code>. \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Bitrix\\Crm\\Item<\/code> \u00a0(\u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f) \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Bitrix\\Main\\Result<\/code> (\u0443\u0441\u043f\u0435\u0445 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443).<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/h3>\n<p>\u0412\u0441\u044f \u043c\u0430\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0438. \u0412\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u2014 <code>getUpdateOperation<\/code>), \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0432 \u043d\u0435\u0435 \u0441\u0432\u043e\u0439 <code>Action<\/code>.<\/p>\n<pre><code class=\"php\">\/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update {     \/\/ 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     $operation = parent::getUpdateOperation($item, $context);          \/\/ 2. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439 Action \u043d\u0430 \u044d\u0442\u0430\u043f \"\u041f\u0415\u0420\u0415\u0414 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c\"     $operation-&gt;addAction(         Operation::ACTION_BEFORE_SAVE,         new ExampleAction()     );      return $operation; }<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>addAction()<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<ul>\n<li>\n<p>\u041c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:\u00a0<\/p>\n<ul>\n<li>\n<p><code>Operation::ACTION_BEFORE_SAVE<\/code> \u2014 \u0434\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0411\u0414.<\/p>\n<\/li>\n<li>\n<p><code>Operation::ACTION_AFTER_SAVE<\/code> \u2014 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0411\u0414.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a: \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u043a\u043b\u0430\u0441\u0441\u0430 <code>Action<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u0412 \u0444\u0430\u0431\u0440\u0438\u043a\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>getAddOperation<\/code>, <code>getUpdateOperation <\/code>\u0438\u043b\u0438 <code>getDeleteOperation<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 <code>Action<\/code> \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e addAction(), \u0443\u043a\u0430\u0437\u0430\u0432 \u044d\u0442\u0430\u043f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (BEFORE \u0438\u043b\u0438 AFTER).<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u00ab\u0417\u0430\u043a\u0430\u0437\u044b\u00bb \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c <code>1036<\/code>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fd1\/47d\/89c\/fd147d89c4a1bd9f604fec8e4ed5c46d.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0421\u041f\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0421\u041f\" width=\"1058\" height=\"539\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/fd1\/47d\/89c\/fd147d89c4a1bd9f604fec8e4ed5c46d.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fd1\/47d\/89c\/fd147d89c4a1bd9f604fec8e4ed5c46d.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0421\u041f<\/figcaption><\/div>\n<\/figure>\n<h4>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 (OrderFactory)<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441-\u0444\u0430\u0431\u0440\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u0432\u0430\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c.<\/p>\n<pre><code class=\"php\">&lt;?php  \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/OrderFactory.php  namespace Your\\Module\\Crm\\Service\\Factory;  use Bitrix\\Crm\\Service\\Factory\\Dynamic; use Bitrix\\Crm\\Service\\Context; use Bitrix\\Crm\\Service\\Operation; use Bitrix\\Crm\\Model\\Dynamic\\TypeTable; use Bitrix\\Crm\\Item;  \/**  * \u0421\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0417\u0430\u043a\u0430\u0437\u044b  *\/ class OrderFactory extends Dynamic {     \/** @var int *\/     protected int $entityTypeId = 1036; \/\/ \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430          public function __construct()      {         $type = TypeTable::getByEntityTypeId($this-&gt;entityTypeId)-&gt;fetchObject();          if (!is_null($type))          {             parent::__construct($type);         }          else          {             \/\/ \u0412\u0430\u0436\u043d\u043e: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0442\u0438\u043f \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d             throw new \\Exception(\"Smart process type with ID {$entityTypeId} not found.\");         }     }     \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update     {         \/\/ 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f         $operation = parent::getUpdateOperation($item, $context);                  \/\/ 2. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439 Action \u043d\u0430 \u044d\u0442\u0430\u043f \"\u041f\u0415\u0420\u0415\u0414 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c\"         $operation-&gt;addAction(             Operation::ACTION_BEFORE_SAVE,             new \\Your\\Module\\Crm\\Service\\Operation\\Action\\OrderAction()         );          return $operation;     } }<\/code><\/pre>\n<h4>2. \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441-\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0435<\/h4>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u043e\u0447\u043a\u0435 \u0432\u0445\u043e\u0434\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <code>init.php<\/code>.<\/p>\n<pre><code class=\"php\">&lt;?php  \/\/\/ \u0444\u0430\u0439\u043b local\/php_interface\/init.php  use Your\\Module\\Crm\\Service\\Factory\\OrderFactory;  \/\/ \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (ID=1036) \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()-&gt;addInstance(     'crm.service.factory.dynamic.1036', \/\/ \u041a\u043b\u044e\u0447 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430     new OrderFactory() );<\/code><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e: \u041a\u043b\u044e\u0447 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 <code>crm.service.factory.dynamic.{ID_\u0421\u0423\u0429\u041d\u041e\u0421\u0422\u0418}<\/code>.  <\/p>\n<h4>3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c Action \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432\u0430\u0448\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<pre><code class=\"php\">&lt;?php  \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/OrderAction.php  namespace Your\\Module\\Crm\\Service\\Operation\\Action;  use Bitrix\\Main\\Result; use Bitrix\\Main\\Error; use Bitrix\\Crm\\Item; use Bitrix\\Crm\\Service\\Operation\\Action;  \/\/ \u0412\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 class OrderAction extends Action {     \/**      * @param Item $iteml      * @return Result      *\/     public function process(Item $item): Result     {         $result = new Result();                  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u043b\u044f \"\u0421\u0443\u043c\u043c\u0430\"         if ($item-&gt;get('OPPORTUNITY') &lt; 0)          {             $result-&gt;addError(new Error(\"\u0421\u0443\u043c\u043c\u0430 \u0437\u0430\u043a\u0430\u0437\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439!\"));         }                  return $result; \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438     } }<\/code><\/pre>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ec\/b10\/911\/8ecb10911cc2b25d6106ae3b143c8ca6.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440\" width=\"1029\" height=\"613\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/8ec\/b10\/911\/8ecb10911cc2b25d6106ae3b143c8ca6.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ec\/b10\/911\/8ecb10911cc2b25d6106ae3b143c8ca6.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440<\/figcaption><\/div>\n<\/figure>\n<h4>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/h4>\n<ul>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441-\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 <code>OrderFactory<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <code>getUpdateOperation<\/code> \u0443 \u0444\u0430\u0431\u0440\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043d\u0435\u0435 \u0432\u0430\u0448 <code>OrderAction<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u041f\u0435\u0440\u0435\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c (<code>ACTION_BEFORE_SAVE<\/code>) \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434 <code>process<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <code>process <\/code>\u0432\u0435\u0440\u043d\u0443\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 <code>Result <\/code>\u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u0441\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u2014 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u043e\u0432\u043e\u0433\u043e API CRM<\/h3>\n<p>\u0421\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u0435 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0443 \u2014 \u044d\u0442\u043e \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e. \u041d\u043e\u0432\u043e\u0435 API \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u0443\u044e \u0438 \u043c\u043e\u0449\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u0439\u043d\u043e\u0439.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430. \u0412 \u043d\u0435\u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u0440\u0443\u043a\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0447\u0435\u043c \u0440\u0435\u0448\u0438\u0442\u044c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 1: \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/h4>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u2014 \u044d\u0442\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435, \u0435\u0451 \u043f\u0435\u0434\u0430\u0433\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f.<\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u00ab<a href=\"https:\/\/dev.1c-bitrix.ru\/api_d7\/bitrix\/crm\/dynamic\/examples.php\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/a>\u00bb. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 (\u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Factory, Operation, Action \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b), \u043e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0f7\/c86\/638\/0f7c86638d0bb17c890da39826934d59.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" width=\"979\" height=\"472\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/0f7\/c86\/638\/0f7c86638d0bb17c890da39826934d59.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0f7\/c86\/638\/0f7c86638d0bb17c890da39826934d59.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430:<\/h3>\n<ul>\n<li>\n<p><strong>\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430<\/strong>. \u0412 \u0441\u043e\u0431\u044b\u0442\u0438\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u043e\u0434\u043d\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0438 \u0442\u0440\u0435\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u0435\u043c\u0443 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0442\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 (<code>Factory<\/code>, <code>Operation<\/code>, <code>Action<\/code>) \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/strong>. \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <code>new class (...) { ... }<\/code> \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u2014 \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u043b\u043e\u0445\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u00ab\u041a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u00bb<\/strong>. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0442\u0430\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0447\u0430\u0441\u0442\u043e \u0431\u0435\u0437\u0434\u0443\u043c\u043d\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c\u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043e\u0442\u043b\u0430\u0434\u0438\u0442\u044c \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u0432\u043e\u0434\u043d\u044b\u0445, \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435 \u0441\u0430\u043c\u044b\u0445 \u043b\u0443\u0447\u0448\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u044e\u0442 \u0432\u0445\u043e\u0434 \u0432 \u043d\u043e\u0432\u043e\u0435 API \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u0443\u044e\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u043f\u043b\u043e\u0445\u043e\u0433\u043e, \u0442\u0440\u0443\u0434\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/strong>: \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u0438 \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041c\u044b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c \u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u2014 \u0447\u0435\u0440\u0435\u0437 \u044f\u0432\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 2: \u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432<\/h4>\n<p>\u0424\u0440\u0430\u0437\u0430 \u00ab<em>\u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432<\/em>\u00bb \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0439. \u041d\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u043c\u044b\u0441\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u043e \u0443\u043f\u0443\u0441\u043a\u0430\u044e\u0442, \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u2014 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u043a\u0430\u043a <em>\u041a\u043e\u043d\u0442\u0430\u043a\u0442<\/em> \u0438\u043b\u0438 <em>\u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f<\/em>. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u043b\u043e\u0433\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u0441\u0432\u043e\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0432\u0435\u0434\u0435\u0442 \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u0438 \u043d\u0435\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0433\u043e \u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u043a\u043e\u0434\u0430.<\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<\/strong>: \u041e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u043d\u0430 \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438<\/p>\n<p><strong>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e00\/d3d\/ec4\/e00d3dec4514ab476a363235642df46b.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" width=\"932\" height=\"383\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e00\/d3d\/ec4\/e00d3dec4514ab476a363235642df46b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e00\/d3d\/ec4\/e00d3dec4514ab476a363235642df46b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430:<\/h3>\n<ol>\n<li>\n<p><strong>\u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 OCP (<\/strong><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D1%80%D0%B8%D0%BD%D1%86%D0%B8%D0%BF_%D0%BE%D1%82%D0%BA%D1%80%D1%8B%D1%82%D0%BE%D1%81%D1%82%D0%B8\/%D0%B7%D0%B0%D0%BA%D1%80%D1%8B%D1%82%D0%BE%D1%81%D1%82%D0%B8\" rel=\"noopener noreferrer nofollow\"><strong>Open-Closed Principle<\/strong><\/a><strong>)<\/strong>. \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u0435\u0437\u0442\u044c \u0432 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0442\u043a\u0443 <code>if-else<\/code>. \u042d\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0443\u0442\u044c \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u043e\u0441\u0442\u044c<\/strong>. \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u043e\u0431\u0440\u0430\u043d \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u043d\u043e\u0432\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438<\/strong>. \u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0442\u0430\u043a\u043e\u043c \u043a\u043e\u0434\u0435 \u0438 \u043d\u0430\u0439\u0442\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0442\u044f\u0436\u0435\u043b\u043e.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/strong>: \u042f\u0432\u043d\u0430\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430<\/p>\n<p>\u0411\u0438\u0442\u0440\u0438\u043a\u0441 \u0441\u0430\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 <code>crm.service.factory.dynamic.{ID_\u0421\u0423\u0429\u041d\u041e\u0421\u0422\u0418}<\/code>.\u00a0<\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043c\u044b \u044f\u0432\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u0442\u043e\u043c \u0436\u0435 <code>init.php<\/code>:<\/p>\n<pre><code class=\"php\">\/\/\/ \u0424\u0430\u0439\u043b: local\/php_interface\/init.php  \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()-&gt;addInstance(     'crm.service.factory.dynamic.1036', \/\/ \u0421\u041f: \u0417\u0430\u043a\u0430\u0437\u044b     new \\Your\\Module\\Crm\\Service\\Factory\\OrderFactory() );  \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()-&gt;addInstance(     'crm.service.factory.dynamic.1037', \/\/ \u0421\u041f: \u041b\u044e\u0434\u0438     new \\Your\\Module\\Crm\\Service\\Factory\\PeopleFactory() );  \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()-&gt;addInstance(     'crm.service.factory.dynamic.1038', \/\/ \u0421\u041f: \u0420\u043e\u0434\u0438\u0442\u0435\u043b\u0438     new \\Your\\Module\\Crm\\Service\\Factory\\ParentFactory() );<\/code><\/pre>\n<h3>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430:<\/h3>\n<ol>\n<li>\n<p><strong>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c SOLID<\/strong>. \u041a\u0430\u0436\u0434\u0430\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 \u043e\u0434\u043d\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c (\u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438). \u041a\u043e\u0434 \u0437\u0430\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439, \u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u2014 \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0430 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0427\u0438\u0441\u0442\u043e\u0442\u0430 \u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a<\/strong>. \u041b\u043e\u0433\u0438\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u0441\u0432\u043e\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0438 \u043a\u043b\u0430\u0441\u0441\u0435. \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e, \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c. <\/strong>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 11-\u0433\u043e, 12-\u0433\u043e \u0438\u043b\u0438 100-\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u0435\u043c \u0436\u0435: \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u2192 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u043a\u0443.<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u041d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0439\u0442\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u043f\u043e \u0438\u0445 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0447\u0438\u0449\u0435 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u0435\u0435.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 3: \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e Actions<\/h4>\n<p>\u041f\u043e \u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 (<code>Action<\/code>) \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043d\u043e\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>$operation-&gt;addAction()<\/code>, \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0433\u043e \u043c\u043e\u043d\u0441\u0442\u0440\u0430.<\/p>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u0430\u0442\u0430\u0441\u0442\u0440\u043e\u0444\u0438\u0447\u043d\u043e \u044d\u0442\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0448\u043b\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 <code>if ($entityTypeId === ...)<\/code> \u0438\u043b\u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 1: \u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435-\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0435<\/h3>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u042d\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0447\u0438\u0449\u0435 \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435.<\/p>\n<pre><code class=\"php\">&lt;?php \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/OrderFactory.php  namespace Your\\Module\\Crm\\Service\\Factory;  use Bitrix\\Crm\\Service\\Factory\\Dynamic; use Bitrix\\Crm\\Service\\Context; use Bitrix\\Crm\\Service\\Operation; use Bitrix\\Crm\\Model\\Dynamic\\TypeTable; use Bitrix\\Crm\\Item;  \/**  * \u0421\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0417\u0430\u043a\u0430\u0437\u044b  *\/ class OrderFactory extends Dynamic {     \/** @var int *\/     protected int $entityTypeId = 1036; \/\/ \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430          public function __construct()      {         $type = TypeTable::getByEntityTypeId($this-&gt;entityTypeId)-&gt;fetchObject();          if (!is_null($type))          {             parent::__construct($type);         }          else          {             \/\/ \u0412\u0430\u0436\u043d\u043e: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0442\u0438\u043f \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d             throw new \\Exception(\"Smart process type with ID {$entityTypeId} not found.\");         }     }      \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update     {         \/\/ 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f         $operation = parent::getUpdateOperation($item, $context);                  \/\/ \u0412\u044b\u043d\u043e\u0441\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434         $this-&gt;registerBeforeSaveActions($operation);          return $operation;     }          \/\/ \u041c\u0435\u0442\u043e\u0434-\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c     protected function registerBeforeSaveActions(Operation\\Update &amp;$operation): void     {         $actions = [             new \\Your\\Module\\Crm\\Service\\Operation\\Action\\ValidateOrderSumAction(),             new \\Your\\Module\\Crm\\Service\\Operation\\Action\\GenerateOrderTitleAction(),             new \\Your\\Module\\Crm\\Service\\Operation\\Action\\SendNotificationAction(),             \/\/ \u041d\u043e\u0432\u044b\u0439 Action \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0437\u0434\u0435\u0441\u044c         ];          foreach ($actions as $action)          {             $operation-&gt;addAction(Operation::ACTION_BEFORE_SAVE, $action);         }     }          \/\/ \u041f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c registerAfterSaveActions() }<\/code><\/pre>\n<h3>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430:<\/h3>\n<ul>\n<li>\n<p><strong>\u0427\u0438\u0441\u0442\u043e\u0442\u0430<\/strong>: \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>getUpdateOperation<\/code> \u043d\u0435 \u0437\u0430\u0433\u0440\u043e\u043c\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u044c<\/strong>: \u0412\u0441\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0438\u0445 \u0441\u043f\u0438\u0441\u043e\u043a \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430<\/strong>: \u041d\u043e\u0432\u044b\u0439 Action \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 2: \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0420\u0435\u0435\u0441\u0442\u0440\u0430 (Registry)<\/h3>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0434\u043b\u044f 5-10 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041d\u043e \u0435\u0441\u043b\u0438 \u0438\u0445 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 (\u0434\u0435\u0441\u044f\u0442\u043a\u0438), \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0435 \u0441\u043d\u043e\u0432\u0430 \u043d\u0430\u0447\u043d\u0435\u0442 \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441-\u0420\u0435\u0435\u0441\u0442\u0440.<\/p>\n<pre><code class=\"php\">protected function registerBeforeSaveActions(Operation\\Update $operation): void {     $actions = \\Your\\Module\\Crm\\Service\\Operation\\ActionRegistry::getBeforeSaveActions($this-&gt;entityTypeId);      foreach ($actions as $action)     {         $operation-&gt;addAction(Operation::ACTION_BEFORE_SAVE, $action);     } }<\/code><\/pre>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u041d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0439\u0442\u0435 \u0432\u0430\u0448\u0438\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u043c \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0442\u044c\u0441\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434\u044b-\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0438 \u043b\u043e\u0433\u0438\u043a\u0438, \u0430 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0437\u0430\u0432\u0435\u0434\u0438\u0442\u0435 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0420\u0435\u0435\u0441\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0433\u0438\u0431\u043a\u043e\u0439 \u0438 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u043a \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 4: \u041a\u0430\u0441\u043a\u0430\u0434 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0438 \u0445\u0440\u0443\u043f\u043a\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h4>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043a\u043e\u0432\u0430\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u043f\u044b\u0442\u0430\u044f\u0441\u044c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/491\/f9c\/2b0\/491f9c2b0a76ed1bf369eec52c72702a.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\" width=\"321\" height=\"494\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/491\/f9c\/2b0\/491f9c2b0a76ed1bf369eec52c72702a.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/491\/f9c\/2b0\/491f9c2b0a76ed1bf369eec52c72702a.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u0441\u0445\u0435\u043c\u0435 \u0432\u044b\u0448\u0435 \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u043a\u0430\u0434 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430:<\/h3>\n<ol>\n<li>\n<p><strong>\u0425\u0440\u0443\u043f\u043a\u043e\u0441\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. <\/strong>\u0426\u0435\u043f\u043e\u0447\u043a\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0436\u0435\u0441\u0442\u043a\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0432\u0441\u0435\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>CustomDinamicFactory<\/code>) \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0438.<\/strong> \u041a\u0440\u0430\u0439\u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>getUpdateOperation <\/code>\u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0437\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u043d\u0430 \u0432\u043e\u043e\u0431\u0449\u0435. \u041b\u0435\u0433\u043a\u043e \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u0438 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u043e\u0442 \u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u0447\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 LSP (<\/strong><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D1%80%D0%B8%D0%BD%D1%86%D0%B8%D0%BF%5C_%D0%BF%D0%BE%D0%B4%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B8%5C_%D0%9B%D0%B8%D1%81%D0%BA%D0%BE%D0%B2\" rel=\"noopener noreferrer nofollow\"><strong>Liskov Substitution Principle<\/strong><\/a><strong>)<\/strong>. \u0414\u043b\u0438\u043d\u043d\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b-\u043f\u043e\u0442\u043e\u043c\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0431\u044b\u0442\u044c \u043d\u0430 100% \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u043c\u0438 \u0441 \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f\u043c\u0438, \u0447\u0442\u043e \u0432\u0435\u0434\u0435\u0442 \u043a \u0442\u043e\u043d\u043a\u0438\u043c \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0431\u0430\u0433\u0430\u043c.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e8a\/9d8\/e1d\/e8a9d8e1de359a701f4fbe7e2a1189d7.png\" width=\"842\" height=\"494\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/e8a\/9d8\/e1d\/e8a9d8e1de359a701f4fbe7e2a1189d7.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e8a\/9d8\/e1d\/e8a9d8e1de359a701f4fbe7e2a1189d7.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>\u041a\u043b\u044e\u0447 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u2014 \u043e\u0442\u043a\u0430\u0437 \u043e\u0442 \u0433\u043b\u0443\u0431\u043e\u043a\u0438\u0445 \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0430 <code>CustomDinamicFactory<\/code>, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0437 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p><strong>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435:<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0431\u0440\u0438\u043a<\/strong>. \u0412\u0430\u0448\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0411\u0438\u0442\u0440\u0438\u043a\u0441 (<code>Dynamic<\/code>). \u0412\u0441\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432, \u0430 \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u043e\u0433\u043e \u0436\u0435 \u0420\u0435\u0435\u0441\u0442\u0440\u0430 Actions \u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b).<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/strong>. \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 Action, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u0418\u0445 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0434\u0430\u0441\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p><strong>\u0410\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f.<\/strong> \u0412\u0430\u0448\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u043d\u0430\u0442\u044c \u0432\u0441\u0435 \u043e \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u0445. \u0415\u0451 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0438\u0437\u0432\u043d\u0435 (\u0438\u0437 \u041a\u043e\u043d\u0444\u0438\u0433\u0430 \u0438\u043b\u0438 \u0420\u0435\u0435\u0441\u0442\u0440\u0430) \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0445.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"php\">class OrderFactory extends Dynamic {     \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update     {         \/\/ 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f         $operation = parent::getUpdateOperation($item, $context);                  \/\/ \u0420\u0435\u0435\u0441\u0442\u0440 \u2014 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441. \u041c\u044b \u043d\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0435\u0433\u043e, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c.         $actions = ActionRegistry::make($this-&gt;entityTypeId);                  foreach ($actions-&gt;getOnBeforeUpdate() as $action)         {             $operation-&gt;addAction(Operation::ACTION_BEFORE_SAVE, $action);         }          return $operation;     } }<\/code><\/pre>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u0421\u0442\u0440\u0435\u043c\u0438\u0442\u0435\u0441\u044c \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Action \u0438 \u0435\u0433\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0442\u043e\u043c \u0436\u0435 \u0420\u0435\u0435\u0441\u0442\u0440\u0435), \u0430 \u043d\u0435 \u043f\u0443\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430-\u0444\u0430\u0431\u0440\u0438\u043a\u0438. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0433\u0438\u0431\u043a\u043e\u0439, \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c SOLID \u0438 DRY.<\/p>\n<p>\u0418\u0437\u0443\u0447\u0430\u0439\u0442\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0439\u0442\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u0434\u0430\u044e\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<h3>\u041c\u043e\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435: \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b<\/h3>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b, \u043d\u043e \u0441 \u0440\u043e\u0441\u0442\u043e\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u043a\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442. \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u044f \u0432\u044b\u043d\u0435\u0441 \u0435\u0451 \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/github.com\/dimayadikin1997\/bitrix24-crm\" rel=\"noopener noreferrer nofollow\">dimayadikin1997\/bitrix24-crm<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u0432\u0441\u0435\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c: \u0445\u0440\u0443\u043f\u043a\u0438\u0445 \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0431\u0440\u0438\u043a \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 Composer:<\/p>\n<pre><code class=\"powershell\">composer require dimayadikin1997\/bitrix24-crm<\/code><\/pre>\n<h4>\u0428\u0430\u0433 1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e <code>Dynamic<\/code> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>FactoryInteface<\/code>.<\/p>\n<pre><code class=\"php\">&lt;?php    \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/OrderFactory.php  namespace Your\\Module\\Crm\\Service\\Factory;  use Bitrix\\Crm\\Service\\Factory\\Dynamic; use Bitrix\\Crm\\Service\\Container; use Bitrix\\Crm\\Service\\Context; use Bitrix\\Crm\\Service\\Operation; use Bitrix\\Crm\\Model\\Dynamic\\TypeTable; use Bitrix\\Crm\\Item;  use Yadikin\\Bitrix24\\Crm\\Factory\\Intefaces\\FactoryInteface;  \/**  * \u0421\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0417\u0430\u043a\u0430\u0437\u044b  *\/ class OrderFactory extends Dynamic implements FactoryInteface {     \/** @var int *\/     protected int $entityTypeId = 1036; \/\/ \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430          public function __construct()      {         $type = TypeTable::getByEntityTypeId($this-&gt;entityTypeId)-&gt;fetchObject();          if (!is_null($type))          {             parent::__construct($type);         }          else          {             \/\/ \u0412\u0430\u0436\u043d\u043e: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0442\u0438\u043f \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d             throw new \\Exception(\"Smart process type with ID {$entityTypeId} not found.\");         }     }          \/**      * return string      *\/     public function getInstanceCode() : string     {         \/\/\/ \u0412\u0435\u0440\u043d\u0435\u0442 \"crm.service.factory.dynamic.1036\"         $identifier = Container::getIdentifierByClassName(Dynamic::class, [$this-&gt;entityTypeId]);         return $identifier;     }      \/\/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434     public function getAddOperation(Item $item, Context $context = null): Operation\\Add     {         $operation = parent::getAddOperation($item, $context);          \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Action`s          return $operation;     }      \/\/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434     public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update     {         $operation = parent::getUpdateOperation($item, $context);          \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Action`s          return $operation;     }      \/\/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434     public function getDeleteOperation(Item $item, Context $context = null): Operation\\Delete     {         $operation = parent::getDeleteOperation($item, $context);          \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c Action`s          return $operation;     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 2. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0432 Service Locator<\/h4>\n<p>\u042f\u0432\u043d\u043e \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u043e \u0435\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443.<\/p>\n<pre><code class=\"php\">&lt;?php  \/\/\/ \u0424\u0430\u0439\u043b: local\/php_interface\/init.php    $orderFactory = new Your\\Module\\Crm\\Service\\Factory\\OrderFactory();  \/\/ \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (ID=1036) \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()-&gt;addInstance(     $orderFactory-&gt;getInstanceCode(), \/\/ \u041a\u043b\u044e\u0447 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430     $orderFactory );<\/code><\/pre>\n<h4>\u0428\u0430\u0433 3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c Action \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043b\u044e\u0431\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0430\u0448\u0443 \u043b\u043e\u0433\u0438\u043a\u0443. \u042d\u0442\u043e <strong><abbr class=\"habraabbr\" title=\"\u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043e\u0442 Operation\\Action, \u0442.\u043a. \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.\" data-title=\"&lt;p&gt;\u041d\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043e\u0442 Operation\\Action, \u0442.\u043a. \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.&lt;\/p&gt;&lt;p&gt;&lt;\/p&gt;\" data-abbr=\"\u043d\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\">\u043d\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a<\/abbr><\/strong> <code>Operation\\Action<\/code>. <\/p>\n<pre><code class=\"php\">&lt;?php    \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/ExampleFactory.php  namespace Your\\Module\\Crm\\Service\\Operation\\Action;  use Bitrix\\Main\\Result; use Bitrix\\Main\\Error; use Bitrix\\Crm\\Item;  class OrderAction {     \/**      * @param Item $iteml      * @return Result      *\/     public function run(Item $item): Result     {         $result = new Result();                  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u043b\u044f \"\u0421\u0443\u043c\u043c\u0430\"         if ($item-&gt;get('OPPORTUNITY') &lt; 0)          {             $result-&gt;addError(new Error(\"\u0421\u0443\u043c\u043c\u0430 \u0437\u0430\u043a\u0430\u0437\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439!\"));         }                  return $result; \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 4. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c Action \u0432 \u0420\u0435\u0435\u0441\u0442\u0440\u0435<\/h4>\n<p>\u0421\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448 Action \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 (\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435) \u0438 \u044d\u0442\u0430\u043f\u043e\u043c (\u0434\u043e \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f).<\/p>\n<pre><code class=\"php\">&lt;?php    \/\/\/ ... \u0414\u0430\u043b\u0435\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435: local\/php_interface\/init.php  $orderRegistry = Yadikin\\Bitrix24\\Crm\\Action\\Actions::make($orderFactory);  $orderRegistry-&gt;onBeforeAdd(new Your\\Module\\Crm\\Service\\Operation\\Action\\OrderAction, 'run'); $orderRegistry-&gt;onBeforeUpdate(new Your\\Module\\Crm\\Service\\Operation\\Action\\OrderAction, 'run');<\/code><\/pre>\n<h4>\u0428\u0430\u0433 5. \u0418\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u043c \u0420\u0435\u0435\u0441\u0442\u0440 \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0443<\/h4>\n<p>\u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u043b\u0438 \u0432\u0441\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<pre><code class=\"php\">&lt;?php \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/OrderFactory.php  namespace Your\\Module\\Crm\\Service\\Factory;  use Bitrix\\Crm\\Service\\Factory\\Dynamic; use Bitrix\\Crm\\Service\\Container; use Bitrix\\Crm\\Service\\Context; use Bitrix\\Crm\\Service\\Operation; use Bitrix\\Crm\\Model\\Dynamic\\TypeTable; use Bitrix\\Crm\\Item;  use Yadikin\\Bitrix24\\Crm\\Factory\\Intefaces\\FactoryInteface;  \/**  * \u0421\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0417\u0430\u043a\u0430\u0437\u044b  *\/ class OrderFactory extends Dynamic implements FactoryInteface {     \/** @var int *\/     protected int $entityTypeId = 1036; \/\/ \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430          public function __construct()      {         $type = TypeTable::getByEntityTypeId($this-&gt;entityTypeId)-&gt;fetchObject();          if (!is_null($type))          {             parent::__construct($type);         }          else          {             \/\/ \u0412\u0430\u0436\u043d\u043e: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0442\u0438\u043f \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d             throw new \\Exception(\"Smart process type with ID {$entityTypeId} not found.\");         }     }          \/**      * return string      *\/     public function getInstanceCode() : string     {         \/\/\/ \u0412\u0435\u0440\u043d\u0435\u0442 \"crm.service.factory.dynamic.1036\"         $identifier = Container::getIdentifierByClassName(Dynamic::class, [$this-&gt;entityTypeId]);         return $identifier;     }      public function getAddOperation(Item $item, Context $context = null): Operation\\Add     {         $operation = parent::getAddOperation($item, $context);          $orderRegistry = \\Yadikin\\Bitrix24\\Crm\\Action\\Actions::make(\/** @var OrderFactory *\/$this);                  foreach ($orderRegistry-&gt;getOnBeforeAdd() as $action)          {             $operation-&gt;addAction(Operation::ACTION_BEFORE_SAVE, \/** @var Action *\/$action);         }                  foreach ($orderRegistry-&gt;getOnAfterAdd() as $action)          {             $operation-&gt;addAction(Operation::ACTION_AFTER_SAVE, \/** @var Action *\/$action);         }          return $operation;     }      public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update     {         $operation = parent::getUpdateOperation($item, $context);          $orderRegistry = \\Yadikin\\Bitrix24\\Crm\\Action\\Actions::make(\/** @var OrderFactory *\/$this);                  foreach ($orderRegistry-&gt;getOnBeforeUpdate() as $action)          {             $operation-&gt;addAction(Operation::ACTION_BEFORE_SAVE, \/** @var Action *\/$action);         }                  foreach ($orderRegistry-&gt;getOnAfterUpdate() as $action)          {             $operation-&gt;addAction(Operation::ACTION_AFTER_SAVE, \/** @var Action *\/$action);         }          return $operation;     }      \/\/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434     public function getDeleteOperation(Item $item, Context $context = null): Operation\\Delete     {         $operation = parent::getDeleteOperation($item, $context);          $orderRegistry = \\Yadikin\\Bitrix24\\Crm\\Action\\Actions::make(\/** @var OrderFactory *\/$this);                  foreach ($orderRegistry-&gt;getOnBeforeDelete() as $action)          {             $operation-&gt;addAction(Operation::ACTION_BEFORE_SAVE, \/** @var Action *\/$action);         }                  foreach ($orderRegistry-&gt;getOnAfterDelete() as $action)          {             $operation-&gt;addAction(Operation::ACTION_AFTER_SAVE, \/** @var Action *\/$action);         }          return $operation;     } }<\/code><\/pre>\n<h4>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442<\/h4>\n<ul>\n<li>\n<p><strong>\u041c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/strong>: \u041d\u043e\u0432\u044b\u0439 <code>Action<\/code> \u0434\u043b\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432 <code>init.php<\/code> \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0441\u0430\u043c\u0438\u0445 \u0444\u0430\u0431\u0440\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p><strong>\u0427\u0438\u0441\u0442\u043e\u0442\u0430 \u043a\u043e\u0434\u0430<\/strong>: \u0412\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445. \u0424\u0430\u0431\u0440\u0438\u043a\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0447\u0438\u0441\u0442\u044b\u043c\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u044e \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u0437\u0431\u0435\u0433\u0430\u043d\u0438\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f<\/strong>: \u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0412\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/strong>: <code>Action<\/code> \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0441 \u043e\u0434\u043d\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c. \u0418\u0445 \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u042f\u0432\u043d\u0430\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<\/strong>: \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0438 \u0441\u0432\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0439 \u0438 \u043b\u0435\u0433\u043a\u043e\u0439 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u2014 \u043d\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0438\u0441\u0442\u0438\u043d\u0430, \u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0432 \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043d\u0430 Bitrix24.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0439\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a \u043d\u043e\u0432\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 API CRM \u0432 Bitrix24 \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0433 \u0432\u043f\u0435\u0440\u0451\u0434 \u0434\u043b\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u041d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u0438 \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u043a \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u0438\u0448\u043b\u0438 \u0438 \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0440\u0438\u0441\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0445\u0440\u0443\u043f\u043a\u0438\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041a\u043b\u044e\u0447 \u043a \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430. \u0412\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c SOLID \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0435\u0441\u0442\u0440\u043e\u0432 (Registry) \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0433\u0438\u0431\u043a\u043e\u0439 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u2014 \u044d\u0442\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0435. <\/p>\n<p>\u041d\u043e\u0432\u043e\u0435 API CRM \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u0434 Bitrix24. \u041e\u0441\u0432\u043e\u0438\u0432 \u0435\u0433\u043e \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435, \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0435 \u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0442\u0438 \u0438 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/942338\/\"> https:\/\/habr.com\/ru\/articles\/942338\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u044f\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/dev.1c-bitrix.ru\/api_d7\/bitrix\/crm\/crm%5C_new%5C_api.php\" rel=\"noopener noreferrer nofollow\">\u043d\u043e\u0432\u043e\u0435 API CRM<\/a> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0432 Bitrix24.<\/p>\n<p>\u0420\u0430\u043d\u044c\u0448\u0435 \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 (\u0441\u0434\u0435\u043b\u043a\u0438, \u043b\u0438\u0434\u044b, \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u044b \u0438 \u0442.\u043f.) \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (\u0441\u043e\u0431\u044b\u0442\u0438\u0439\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c). \u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u043e\u0436\u043d\u043e\u043c\u0443 \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u044f\u0436\u0435\u043b\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c. \u041d\u043e\u0432\u043e\u0435 API \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u0438 \u043c\u043e\u0449\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 (\u041e\u041e\u041f).<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442 \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438:\u00a0<\/p>\n<ul>\n<li>\n<p>\u0421\u043a\u0443\u0434\u043d\u0430\u044f \u0438 \u0441\u0443\u0445\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u0438 \u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0431\u0430\u0433\u0438<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u0434\u0430\u0447\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<ul>\n<li>\n<p><strong>\u041e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b:<\/strong> \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 API CRM.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443<\/strong>: \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/strong>: \u0434\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u043e\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u043e\u043a\u0443\u0441 \u043c\u044b \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u043c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u2014 \u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0443\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d \u0438 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u043d\u0430 Habr.<\/p>\n<h3>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 API CRM: \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 Service Locator<\/h3>\n<p>\u0412\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043d\u043e\u0432\u043e\u043c API CRM \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 <a href=\"https:\/\/dev.1c-bitrix.ru\/learning\/course\/index.php?COURSE%5C_ID=43&amp;LESSON%5C_ID=14032\" rel=\"noopener noreferrer nofollow\">Service Locator <\/a>(\u0421\u0435\u0440\u0432\u0438\u0441-\u043b\u043e\u043a\u0430\u0442\u043e\u0440). \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e.<\/p>\n<h4>1. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/h4>\n<p>\u0411\u0438\u0442\u0440\u0438\u043a\u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b-\u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 CRM. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <code>bitrix\/modules\/crm\/.settings.php<\/code>:<\/p>\n<pre><code class=\"php\">'crm.service.factory.contact' =&gt; [     'className' =&gt; '\\\\Bitrix\\\\Crm\\\\Service\\\\Factory\\\\Contact', ],<\/code><\/pre>\n<h4>2. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/h4>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">\/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 Service Locator \/** @var \\Bitrix\\Crm\\Service\\Factory\\Contact $factory *\/ $factory = \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()     -&gt;get('crm.service.factory.contact');<\/code><\/pre>\n<h4>3. \u041f\u043e\u0434\u043c\u0435\u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (\u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u044f)<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0435\u0433\u043e \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<pre><code class=\"php\">\/\/ \u041d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 class ContactFactory extends \\Bitrix\\Crm\\Service\\Factory\\Contact {     \/\/ \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 }<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 \u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0435 \u043d\u0430 \u043d\u0430\u0448:  <\/p>\n<pre><code class=\"php\">\/\/ \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0441\u0432\u043e\u0435\u0439 \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()     -&gt;addInstance('crm.service.factory.contact', new ContactFactory());<\/code><\/pre>\n<h4>4. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044b<\/h4>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0430\u0448 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440:<\/p>\n<pre><code class=\"php\">\/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 ContactFactory \/** @var ContactFactory $factory *\/ $factory = \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()     -&gt;get('crm.service.factory.contact');<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u0448\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0430.<\/p>\n<h4>5. \u0423\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Container<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0411\u0438\u0442\u0440\u0438\u043a\u044124 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441-\u043e\u0431\u0435\u0440\u0442\u043a\u0443 Container. \u0415\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u0438\u0442\u044c. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">\/\/ \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 Container \/\/ \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u043e\u043d \u0442\u043e\u0436\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \/** @var ContactFactory $factory *\/ $factory = \\Bitrix\\Crm\\Service\\Container::getInstance()     -&gt;getFactory(\\CCrmOwnerType::Contact);<\/code><\/pre>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u2014 \u044d\u0442\u043e \u043a\u043b\u044e\u0447 \u043a \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e API. \u0412\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u0435.  <\/p>\n<h3>Factory, Operation \u0438 Action: \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u043e\u0432\u043e\u0433\u043e API, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0430 \u0441\u0445\u0435\u043c\u0435. \u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>UML Factory, Operation \u0438 Action<\/figcaption><\/div>\n<\/figure>\n<figure class=\"\">\n<div><figcaption>\u0412\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<h4>1. Factory (\u0424\u0430\u0431\u0440\u0438\u043a\u0430)<\/h4>\n<ul>\n<li>\n<p><strong>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u044f<\/strong>: \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <a href=\"https:\/\/designpatternsphp.readthedocs.io\/ru\/latest\/Creational\/FactoryMethod\/README.html\" rel=\"noopener noreferrer nofollow\">\u0424\u0430\u0431\u0440\u0438\u0447\u043d\u044b\u0439 \u041c\u0435\u0442\u043e\u0434 (Factory Method)<\/a>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b Operation (\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 CRM.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440<\/strong>: <code>DinamicFactory<\/code> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e <code>Service\\Factory<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0427\u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442<\/strong>: \u0422\u0440\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439:<\/p>\n<ul>\n<li>\n<p><code>getAddOperation()<\/code> \u2192 <code>Operation\\Add<\/code> (\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p><code>getUpdateOperation()<\/code> \u2192 <code>Operation\\Update<\/code> (\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p><code>getDeleteOperation()<\/code> \u2192 <code>Operation\\Delete<\/code> (\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>2. Operation (\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f)<\/h4>\n<ul>\n<li>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c (\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435).<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/strong>: \u041a\u0430\u0436\u0434\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 <code>Action<\/code> \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432 \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u044d\u0442\u0438 \u0448\u0430\u0433\u0438.<\/p>\n<\/li>\n<\/ul>\n<h4>3. Action (\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435)<\/h4>\n<ul>\n<li>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u042d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439, \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438 (\u0432\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u0434).<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/strong>: \u0412\u0430\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u2014 <code>process()<\/code>. \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 <code>Bitrix\\Crm\\Item<\/code> \u00a0(\u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f) \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Bitrix\\Main\\Result<\/code> (\u0443\u0441\u043f\u0435\u0445 \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0443).<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/h3>\n<p>\u0412\u0441\u044f \u043c\u0430\u0433\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0438. \u0412\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u2014 <code>getUpdateOperation<\/code>), \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0432 \u043d\u0435\u0435 \u0441\u0432\u043e\u0439 <code>Action<\/code>.<\/p>\n<pre><code class=\"php\">\/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update {     \/\/ 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     $operation = parent::getUpdateOperation($item, $context);          \/\/ 2. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439 Action \u043d\u0430 \u044d\u0442\u0430\u043f \"\u041f\u0415\u0420\u0415\u0414 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c\"     $operation-&gt;addAction(         Operation::ACTION_BEFORE_SAVE,         new ExampleAction()     );      return $operation; }<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>addAction()<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<ul>\n<li>\n<p>\u041c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:\u00a0<\/p>\n<ul>\n<li>\n<p><code>Operation::ACTION_BEFORE_SAVE<\/code> \u2014 \u0434\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0411\u0414.<\/p>\n<\/li>\n<li>\n<p><code>Operation::ACTION_AFTER_SAVE<\/code> \u2014 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0411\u0414.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a: \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u043a\u043b\u0430\u0441\u0441\u0430 <code>Action<\/code><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u0442\u043e\u0433<\/strong>: \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u0412 \u0444\u0430\u0431\u0440\u0438\u043a\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>getAddOperation<\/code>, <code>getUpdateOperation <\/code>\u0438\u043b\u0438 <code>getDeleteOperation<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 <code>Action<\/code> \u0432 \u043d\u0443\u0436\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e addAction(), \u0443\u043a\u0430\u0437\u0430\u0432 \u044d\u0442\u0430\u043f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (BEFORE \u0438\u043b\u0438 AFTER).<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u00ab\u0417\u0430\u043a\u0430\u0437\u044b\u00bb \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c <code>1036<\/code>.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0421\u041f<\/figcaption><\/div>\n<\/figure>\n<h4>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 (OrderFactory)<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441-\u0444\u0430\u0431\u0440\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u0432\u0430\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c.<\/p>\n<pre><code class=\"php\">&lt;?php  \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/OrderFactory.php  namespace Your\\Module\\Crm\\Service\\Factory;  use Bitrix\\Crm\\Service\\Factory\\Dynamic; use Bitrix\\Crm\\Service\\Context; use Bitrix\\Crm\\Service\\Operation; use Bitrix\\Crm\\Model\\Dynamic\\TypeTable; use Bitrix\\Crm\\Item;  \/**  * \u0421\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0417\u0430\u043a\u0430\u0437\u044b  *\/ class OrderFactory extends Dynamic {     \/** @var int *\/     protected int $entityTypeId = 1036; \/\/ \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430          public function __construct()      {         $type = TypeTable::getByEntityTypeId($this-&gt;entityTypeId)-&gt;fetchObject();          if (!is_null($type))          {             parent::__construct($type);         }          else          {             \/\/ \u0412\u0430\u0436\u043d\u043e: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0442\u0438\u043f \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d             throw new \\Exception(\"Smart process type with ID {$entityTypeId} not found.\");         }     }     \/\/ \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f     public function getUpdateOperation(Item $item, Context $context = null): Operation\\Update     {         \/\/ 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f         $operation = parent::getUpdateOperation($item, $context);                  \/\/ 2. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439 Action \u043d\u0430 \u044d\u0442\u0430\u043f \"\u041f\u0415\u0420\u0415\u0414 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c\"         $operation-&gt;addAction(             Operation::ACTION_BEFORE_SAVE,             new \\Your\\Module\\Crm\\Service\\Operation\\Action\\OrderAction()         );          return $operation;     } }<\/code><\/pre>\n<h4>2. \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441-\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0435<\/h4>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0442\u043e\u0447\u043a\u0435 \u0432\u0445\u043e\u0434\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <code>init.php<\/code>.<\/p>\n<pre><code class=\"php\">&lt;?php  \/\/\/ \u0444\u0430\u0439\u043b local\/php_interface\/init.php  use Your\\Module\\Crm\\Service\\Factory\\OrderFactory;  \/\/ \u041f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (ID=1036) \\Bitrix\\Main\\DI\\ServiceLocator::getInstance()-&gt;addInstance(     'crm.service.factory.dynamic.1036', \/\/ \u041a\u043b\u044e\u0447 \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430     new OrderFactory() );<\/code><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e: \u041a\u043b\u044e\u0447 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 <code>crm.service.factory.dynamic.{ID_\u0421\u0423\u0429\u041d\u041e\u0421\u0422\u0418}<\/code>.  <\/p>\n<h4>3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c Action \u0441 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u043e\u0439<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432\u0430\u0448\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. <\/p>\n<pre><code class=\"php\">&lt;?php  \/\/\/ \u0444\u0430\u0439\u043b local\/modules\/your.module\/lib\/Crm\/Service\/Factory\/OrderAction.php  namespace Your\\Module\\Crm\\Service\\Operation\\Action;  use Bitrix\\Main\\Result; use Bitrix\\Main\\Error; use Bitrix\\Crm\\Item; use Bitrix\\Crm\\Service\\Operation\\Action;  \/\/ \u0412\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 class OrderAction extends Action {     \/**      * @param Item $iteml      * @return Result      *\/     public function process(Item $item): Result     {         $result = new Result();                  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u043b\u044f \"\u0421\u0443\u043c\u043c\u0430\"         if ($item-&gt;get('OPPORTUNITY') &lt; 0)          {             $result-&gt;addError(new Error(\"\u0421\u0443\u043c\u043c\u0430 \u0437\u0430\u043a\u0430\u0437\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439!\"));         }                  return $result; \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438     } }<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440<\/figcaption><\/div>\n<\/figure>\n<h4>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/h4>\n<ul>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441-\u043b\u043e\u043a\u0430\u0442\u043e\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0444\u0430\u0431\u0440\u0438\u043a\u0443 <code>OrderFactory<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043c\u0430\u0440\u0442-\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <code>getUpdateOperation<\/code> \u0443 \u0444\u0430\u0431\u0440\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0424\u0430\u0431\u0440\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043d\u0435\u0435 \u0432\u0430\u0448 <code>OrderAction<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e. \u041f\u0435\u0440\u0435\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c (<code>ACTION_BEFORE_SAVE<\/code>) \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434 <code>process<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <code>process <\/code>\u0432\u0435\u0440\u043d\u0443\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 <code>Result <\/code>\u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u0441\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u2014 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u043e\u0432\u043e\u0433\u043e API CRM<\/h3>\n<p>\u0421\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u0435 \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0443 \u2014 \u044d\u0442\u043e \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e. \u041d\u043e\u0432\u043e\u0435 API \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u0443\u044e \u0438 \u043c\u043e\u0449\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u0439\u043d\u043e\u0439.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0435\u0441\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430. \u0412 \u043d\u0435\u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u0440\u0443\u043a\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0447\u0435\u043c \u0440\u0435\u0448\u0438\u0442\u044c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 1: \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/h4>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u2014 \u044d\u0442\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435, \u0435\u0451 \u043f\u0435\u0434\u0430\u0433\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f.<\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u00ab<a href=\"https:\/\/dev.1c-bitrix.ru\/api_d7\/bitrix\/crm\/dynamic\/examples.php\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u0430\u0441\u0442\u043e\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/a>\u00bb. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 (\u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Factory, Operation, Action \u0438 \u043a\u0430\u043a \u043e\u043d\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b), \u043e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 <\/figcaption><\/div>\n<\/figure>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-472677","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/472677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=472677"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/472677\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=472677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=472677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=472677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}