{"id":340688,"date":"2022-11-02T21:00:17","date_gmt":"2022-11-02T21:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=340688"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=340688","title":{"rendered":"<span>\u041e Dependency Injection \u0432 Magento\u00a02<\/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>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u0432 M2: <a href=\"https:\/\/habr.com\/ru\/post\/674316\/\" rel=\"noopener noreferrer nofollow\">\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438 (\u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438) \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 Magento 2. \u041a\u0430\u043a \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439\u200a\u2014\u200a\u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b. \u042d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043b\u0435\u0436\u0438\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f <strong>Dependency Inversion<\/strong> (\u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439) \u0438\u0437 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/SOLID_%28%D0%BE%D0%B1%D1%8A%D0%B5%D0%BA%D1%82%D0%BD%D0%BE-%D0%BE%D1%80%D0%B8%D0%B5%D0%BD%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5%29\" rel=\"noopener noreferrer nofollow\"><strong>SOLID<\/strong><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0433\u0434\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439, \u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<h3>ObjectManager<\/h3>\n<p>\u0417\u0430 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 M2 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <strong>ObjectManager<\/strong> (\u0434\u0430\u043b\u0435\u0435 OM), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. OM \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u0435\u0433\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0431\u044b\u0442\u044c \u044f\u0432\u043d\u044b\u043c\u0438 \u0438 \u0432\u0435\u0441\u044c \u0441\u043c\u044b\u0441\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Dependency Injection \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u043e\u0434\u043d\u0430\u043a\u043e, \u0431\u044b\u0432\u0430\u044e\u0442 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0438\u0436\u0435. \u0410 \u0432\u043e\u0442 \u0438 \u043a\u043e\u0434 \u0441\u0430\u043c\u043e\u0433\u043e OM:<\/p>\n<pre><code class=\"php\">&lt;?php \/**  * Magento object manager. Responsible for instantiating objects taking into account:  * - constructor arguments (using configured, and provided parameters)  * - class instances life style (singleton, transient)  * - interface preferences  *  * Intentionally contains multiple concerns for best performance  *  * Copyright \u00a9 Magento, Inc. All rights reserved.  * See COPYING.txt for license details.  *\/ namespace Magento\\Framework\\ObjectManager;  class ObjectManager implements \\Magento\\Framework\\ObjectManagerInterface {     \/**      * @var \\Magento\\Framework\\ObjectManager\\FactoryInterface      *\/     protected $_factory;      \/**      * List of shared instances      *      * @var array      *\/     protected $_sharedInstances = [];      \/**      * @var ConfigInterface      *\/     protected $_config;      \/**      * @param FactoryInterface $factory      * @param ConfigInterface $config      * @param array &amp;$sharedInstances      *\/     public function __construct(FactoryInterface $factory, ConfigInterface $config, &amp;$sharedInstances = [])     {         $this->_config = $config;         $this->_factory = $factory;         $this->_sharedInstances = &amp;$sharedInstances;         $this->_sharedInstances[\\Magento\\Framework\\ObjectManagerInterface::class] = $this;     }      \/**      * Create new object instance      *      * @param string $type      * @param array $arguments      * @return mixed      *\/     public function create($type, array $arguments = [])     {         return $this->_factory->create($this->_config->getPreference($type), $arguments);     }      \/**      * Retrieve cached object instance      *      * @param string $type      * @return mixed      *\/     public function get($type)     {         $type = ltrim($type, '\\\\');         $type = $this->_config->getPreference($type);         if (!isset($this->_sharedInstances[$type])) {             $this->_sharedInstances[$type] = $this->_factory->create($type);         }         return $this->_sharedInstances[$type];     }      \/**      * Configure di instance      * Note: All arguments should be pre-processed (sort order, translations, etc) before passing to method configure.      *      * @param array $configuration      * @return void      *\/     public function configure(array $configuration)     {         $this->_config->extend($configuration);     } } <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, <strong>OM <\/strong>\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>di.xml <\/strong>(<a href=\"https:\/\/habr.com\/ru\/post\/674316\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442 <\/a>\u043f\u0440\u043e di.xml) \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430. \u0415\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 (Exception). \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u043d\u043e \u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u0438\u0437 \u043b\u0435\u0436\u0430\u0449\u0438\u0445 (\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439) \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0432\u0441\u0435.<\/p>\n<p><strong>\u0418\u0442\u0430\u043a, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 OM:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u0438 \u043f\u0440\u043e\u043a\u0441\u0438-\u043a\u043b\u0430\u0441\u0441\u0430\u0445<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 singleton-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0442.\u0435. \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 di.xml:<\/strong><\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 OM \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (<a href=\"https:\/\/habr.com\/ru\/post\/674316\/\" rel=\"noopener noreferrer nofollow\">Service Contract<\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0440\u0443\u0433\u0438\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u0432\u043e\u0438\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%BC%D0%B5%D1%81%D1%82%D0%B8%D1%82%D0%B5%D0%BB%D1%8C_%28%D1%88%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD_%D0%BF%D1%80%D0%BE%D0%B5%D0%BA%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F%29\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u043a\u0441\u0438<\/a>, \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Object\u00a0Manager?<\/h3>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 OM \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 __wakeup() \u0438 __sleep();<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0442\u0435\u0441\u0442\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445-\u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u0438 \u043f\u0440\u043e\u043a\u0441\u0438-\u043a\u043b\u0430\u0441\u0441\u0430\u0445.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a \u0431\u044b\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430?<\/h3>\n<p>\u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c <strong>\u0444\u0430\u0431\u0440\u0438\u043a\u0438<\/strong>. \u0424\u0430\u0431\u0440\u0438\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0447\u0435\u0440\u0435\u0437 <strong>use<\/strong> \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <strong>Factory <\/strong>\u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>use Magento\\Framework\\Controller\\Result\\RawFactory;<\/code><\/pre>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440.<\/p>\n<pre><code class=\"php\">public function __construct(RawFactory $resultRawFactory) {         $this->resultRawFactory = $resultRawFactory; }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <strong>create()<\/strong>.<\/p>\n<pre><code class=\"php\">$resultRaw = $this->resultRawFactory->create();<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 M2 \u0441\u0430\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0432 <strong>production mode<\/strong>, \u043b\u0438\u0431\u043e \u043d\u0430 \u043b\u0435\u0442\u0443, \u0435\u0441\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u0435\u043d <strong>developer mode<\/strong> \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0435\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>\/generated\/code<\/strong>. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php  namespace Magento\\Framework\\Controller\\Result;  \/**  * Factory class for @see \\Magento\\Framework\\Controller\\Result\\Raw  *\/ class RawFactory {     \/**      * Object Manager instance      *      * @var \\Magento\\Framework\\ObjectManagerInterface      *\/     protected $_objectManager = null;        \/**      * Instance name to create      *      * @var string      *\/     protected $_instanceName = null;        \/**      * Factory constructor      *      * @param \\Magento\\Framework\\ObjectManagerInterface $objectManager      * @param string $instanceName      *\/     public function __construct(         \\Magento\\Framework\\ObjectManagerInterface $objectManager,          $instanceName = '\\\\Magento\\\\Framework\\\\Controller\\\\Result\\\\Raw'     ) {         $this->_objectManager = $objectManager;         $this->_instanceName = $instanceName;     }        \/**      * Create class instance with specified parameters      *      * @param array $data      * @return \\Magento\\Framework\\Controller\\Result\\Raw      *\/     public function create(array $data = [])     {         return $this->_objectManager->create($this->_instanceName, $data);     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435, \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <strong>object manager<\/strong>. \u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445-\u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u044d\u0442\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 preference?<\/h3>\n<p><strong>Preference<\/strong>\u200a\u2014\u200a\u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u044f\u0437\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u0435\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043a\u043b\u0430\u0441\u0441 \u0441\u0432\u043e\u0435\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u0447\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435.<\/p>\n<p><strong>Preference<\/strong> \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <strong>Service Contract<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e, \u0430 \u043d\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a, \u0433\u0434\u0435 <strong>for<\/strong>\u200a\u2014\u200a\u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0430 <strong>type<\/strong>\u200a\u2014\u200a\u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c:<\/p>\n<pre><code class=\"xml\">&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">     &lt;preference for=\"Magento\\Framework\\Search\\Adapter\\OptionsInterface\"                 type=\"Magento\\CatalogSearch\\Model\\Adapter\\Options\"\/> &lt;\/config><\/code><\/pre>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435\u00a0Proxy?<\/h3>\n<p>Proxy (\u0417\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c)\u200a\u2014\u200a\u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0443\u0440\u0440\u043e\u0433\u0430\u0442\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u043c\u0443.<\/p>\n<p>\u0412 M2 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u201c\u0442\u044f\u0436\u0435\u043b\u044b\u0439\u201d. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430), \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0441\u043a\u043e\u0440\u044f\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 di.xml. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"xml\">&lt;type name=\"Magento\\Framework\\DataObject\\Copy\\Config\">     &lt;arguments>         &lt;argument name=\"dataStorage\" xsi:type=\"object\">Magento\\Framework\\DataObject\\Copy\\Config\\Data\\Proxy&lt;\/argument>     &lt;\/arguments> &lt;\/type><\/code><\/pre>\n<p>\u0412 \u0443\u0437\u043b\u0435 <strong>&lt;type><\/strong> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0440\u043e\u043a\u0441\u0438.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u0443\u0437\u043b\u0435 <strong>&lt;arguments><\/strong> \u043c\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u043d\u0430 \u043f\u0440\u043e\u043a\u0441\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <strong>dataStorage<\/strong>. \u0412 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043d\u043e\u0434\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u044c \u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u043b\u0435\u0448 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <strong>\\Proxy<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6d8\/cfa\/0e8\/6d8cfa0e86a71203d2f2ab3182eca58a.png\" alt=\"\" title=\"\" width=\"800\" height=\"351\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6d8\/cfa\/0e8\/6d8cfa0e86a71203d2f2ab3182eca58a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>di.xml<\/strong>. \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e. M2 \u0441\u0430\u043c\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0438\u0445 \u0432 \u043f\u0430\u043f\u043a\u0443<strong> \/generated<\/strong><\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Virtual Type \u0438\u00a0Type?<\/h3>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u043a \u0431\u044b \u201c\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439\u201d \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u043e \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0431\u0435\u0437 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0442.\u0435 \u201c\u0441\u0442\u0430\u0440\u044b\u0439\u201d \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f Virtual Type \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>di.xml<\/strong>:<\/p>\n<pre><code class=\"xml\">&lt;virtualType name=\"layoutFileSourceBase\"               type=\"Magento\\Framework\\View\\File\\Collector\\Base\">       &lt;arguments>             &lt;argument name=\"subDir\" xsi:type=\"string\">layout&lt;\/argument>       &lt;\/arguments> &lt;\/virtualType><\/code><\/pre>\n<p>\u0412 \u0443\u0437\u043b\u0435 <strong>&lt;virtualType><\/strong> \u0430\u0442\u0440\u0438\u0431\u0443\u0442 name \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 type \u0443\u043a\u0430\u0437\u0430\u043d \u201c\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439\u201d \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0412 \u0443\u0437\u043b\u0435 <strong>&lt;arguments><\/strong> \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <strong>subDir<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 layout.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u044d\u0442\u043e\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u0430\u0441\u0441 \u0447\u0435\u0440\u0435\u0437 \u0442\u043e\u0442 \u0436\u0435 <strong>di.xml<\/strong> \u0447\u0435\u0440\u0435\u0437 \u0443\u0437\u0435\u043b <strong>&lt;type><\/strong> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 subject \u043a\u043b\u0430\u0441\u0441\u0430 <em>Magento\\Framework\\View\\File\\Collector\\Decorator\\ModuleOutput<\/em> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"xml\">&lt;type name=\"Magento\\Framework\\View\\File\\Collector\\Decorator\\ModuleOutput\">       &lt;arguments>             &lt;argument name=\"subject\" xsi:type=\"object\">layoutFileSourceBase&lt;\/argument>       &lt;\/arguments> &lt;\/type><\/code><\/pre>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Virtual Type, Type \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443.<\/p>\n<hr\/>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043a\u0430\u043a \u0432 Magento 2 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Dependency Injection \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u0443\u0435\u0442 \u0438 \u043f\u0440\u0438\u0434\u0430\u0435\u0442 \u0444\u043e\u0440\u043c\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/697140\/\"> https:\/\/habr.com\/ru\/post\/697140\/<\/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>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u0432 M2: <a href=\"https:\/\/habr.com\/ru\/post\/674316\/\" rel=\"noopener noreferrer nofollow\">\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438 (\u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438) \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 Magento 2. \u041a\u0430\u043a \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439\u200a\u2014\u200a\u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u043c\u0443-\u043b\u0438\u0431\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b. \u042d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439.<\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043b\u0435\u0436\u0438\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f <strong>Dependency Inversion<\/strong> (\u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439) \u0438\u0437 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/SOLID_%28%D0%BE%D0%B1%D1%8A%D0%B5%D0%BA%D1%82%D0%BD%D0%BE-%D0%BE%D1%80%D0%B8%D0%B5%D0%BD%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5%29\" rel=\"noopener noreferrer nofollow\"><strong>SOLID<\/strong><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0433\u0434\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439, \u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<h3>ObjectManager<\/h3>\n<p>\u0417\u0430 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 M2 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <strong>ObjectManager<\/strong> (\u0434\u0430\u043b\u0435\u0435 OM), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. OM \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u0435\u0433\u043e \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0431\u044b\u0442\u044c \u044f\u0432\u043d\u044b\u043c\u0438 \u0438 \u0432\u0435\u0441\u044c \u0441\u043c\u044b\u0441\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Dependency Injection \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u043e\u0434\u043d\u0430\u043a\u043e, \u0431\u044b\u0432\u0430\u044e\u0442 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043d\u0438\u0436\u0435. \u0410 \u0432\u043e\u0442 \u0438 \u043a\u043e\u0434 \u0441\u0430\u043c\u043e\u0433\u043e OM:<\/p>\n<pre><code class=\"php\">&lt;?php \/**  * Magento object manager. Responsible for instantiating objects taking into account:  * - constructor arguments (using configured, and provided parameters)  * - class instances life style (singleton, transient)  * - interface preferences  *  * Intentionally contains multiple concerns for best performance  *  * Copyright \u00a9 Magento, Inc. All rights reserved.  * See COPYING.txt for license details.  *\/ namespace Magento\\Framework\\ObjectManager;  class ObjectManager implements \\Magento\\Framework\\ObjectManagerInterface {     \/**      * @var \\Magento\\Framework\\ObjectManager\\FactoryInterface      *\/     protected $_factory;      \/**      * List of shared instances      *      * @var array      *\/     protected $_sharedInstances = [];      \/**      * @var ConfigInterface      *\/     protected $_config;      \/**      * @param FactoryInterface $factory      * @param ConfigInterface $config      * @param array &amp;$sharedInstances      *\/     public function __construct(FactoryInterface $factory, ConfigInterface $config, &amp;$sharedInstances = [])     {         $this->_config = $config;         $this->_factory = $factory;         $this->_sharedInstances = &amp;$sharedInstances;         $this->_sharedInstances[\\Magento\\Framework\\ObjectManagerInterface::class] = $this;     }      \/**      * Create new object instance      *      * @param string $type      * @param array $arguments      * @return mixed      *\/     public function create($type, array $arguments = [])     {         return $this->_factory->create($this->_config->getPreference($type), $arguments);     }      \/**      * Retrieve cached object instance      *      * @param string $type      * @return mixed      *\/     public function get($type)     {         $type = ltrim($type, '\\\\');         $type = $this->_config->getPreference($type);         if (!isset($this->_sharedInstances[$type])) {             $this->_sharedInstances[$type] = $this->_factory->create($type);         }         return $this->_sharedInstances[$type];     }      \/**      * Configure di instance      * Note: All arguments should be pre-processed (sort order, translations, etc) before passing to method configure.      *      * @param array $configuration      * @return void      *\/     public function configure(array $configuration)     {         $this->_config->extend($configuration);     } } <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, <strong>OM <\/strong>\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0435\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>di.xml <\/strong>(<a href=\"https:\/\/habr.com\/ru\/post\/674316\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442 <\/a>\u043f\u0440\u043e di.xml) \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430. \u0415\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 (Exception). \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0443\u0440\u043e\u0432\u043d\u0435, \u043d\u043e \u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 \u043d\u0438\u0437 \u043b\u0435\u0436\u0430\u0449\u0438\u0445 (\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439) \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0432\u0441\u0435.<\/p>\n<p><strong>\u0418\u0442\u0430\u043a, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 OM:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u0438 \u043f\u0440\u043e\u043a\u0441\u0438-\u043a\u043b\u0430\u0441\u0441\u0430\u0445<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 singleton-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u0430, \u0442.\u0435. \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 di.xml:<\/strong><\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 OM \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (<a href=\"https:\/\/habr.com\/ru\/post\/674316\/\" rel=\"noopener noreferrer nofollow\">Service Contract<\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0440\u0443\u0433\u0438\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u0432\u043e\u0438\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%97%D0%B0%D0%BC%D0%B5%D1%81%D1%82%D0%B8%D1%82%D0%B5%D0%BB%D1%8C_%28%D1%88%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD_%D0%BF%D1%80%D0%BE%D0%B5%D0%BA%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F%29\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u043a\u0441\u0438<\/a>, \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Object\u00a0Manager?<\/h3>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 OM \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 __wakeup() \u0438 __sleep();<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0442\u0435\u0441\u0442\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445-\u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u0438 \u043f\u0440\u043e\u043a\u0441\u0438-\u043a\u043b\u0430\u0441\u0441\u0430\u0445.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a \u0431\u044b\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430?<\/h3>\n<p>\u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c <strong>\u0444\u0430\u0431\u0440\u0438\u043a\u0438<\/strong>. \u0424\u0430\u0431\u0440\u0438\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0447\u0435\u0440\u0435\u0437 <strong>use<\/strong> \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <strong>Factory <\/strong>\u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>use Magento\\Framework\\Controller\\Result\\RawFactory;<\/code><\/pre>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440.<\/p>\n<pre><code class=\"php\">public function __construct(RawFactory $resultRawFactory) {         $this->resultRawFactory = $resultRawFactory; }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <strong>create()<\/strong>.<\/p>\n<pre><code class=\"php\">$resultRaw = $this->resultRawFactory->create();<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 M2 \u0441\u0430\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0432 <strong>production mode<\/strong>, \u043b\u0438\u0431\u043e \u043d\u0430 \u043b\u0435\u0442\u0443, \u0435\u0441\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u0435\u043d <strong>developer mode<\/strong> \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0435\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>\/generated\/code<\/strong>. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">&lt;?php  namespace Magento\\Framework\\Controller\\Result;  \/**  * Factory class for @see \\Magento\\Framework\\Controller\\Result\\Raw  *\/ class RawFactory {     \/**      * Object Manager instance      *      * @var \\Magento\\Framework\\ObjectManagerInterface      *\/     protected $_objectManager = null;        \/**      * Instance name to create      *      * @var string      *\/     protected $_instanceName = null;        \/**      * Factory constructor      *      * @param \\Magento\\Framework\\ObjectManagerInterface $objectManager      * @param string $instanceName      *\/     public function __construct(         \\Magento\\Framework\\ObjectManagerInterface $objectManager,          $instanceName = '\\\\Magento\\\\Framework\\\\Controller\\\\Result\\\\Raw'     ) {         $this->_objectManager = $objectManager;         $this->_instanceName = $instanceName;     }        \/**      * Create class instance with specified parameters      *      * @param array $data      * @return \\Magento\\Framework\\Controller\\Result\\Raw      *\/     public function create(array $data = [])     {         return $this->_objectManager->create($this->_instanceName, $data);     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435, \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <strong>object manager<\/strong>. \u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445-\u0444\u0430\u0431\u0440\u0438\u043a\u0430\u0445 \u044d\u0442\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 preference?<\/h3>\n<p><strong>Preference<\/strong>\u200a\u2014\u200a\u044d\u0442\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u044f\u0437\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438 \u0435\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043a\u043b\u0430\u0441\u0441 \u0441\u0432\u043e\u0435\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u0447\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0433\u0438\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435.<\/p>\n<p><strong>Preference<\/strong> \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <strong>Service Contract<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e, \u0430 \u043d\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a, \u0433\u0434\u0435 <strong>for<\/strong>\u200a\u2014\u200a\u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0430 <strong>type<\/strong>\u200a\u2014\u200a\u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c:<\/p>\n<pre><code class=\"xml\">&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"         xsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager\/etc\/config.xsd\">     &lt;preference for=\"Magento\\Framework\\Search\\Adapter\\OptionsInterface\"                 type=\"Magento\\CatalogSearch\\Model\\Adapter\\Options\"\/> &lt;\/config><\/code><\/pre>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435\u00a0Proxy?<\/h3>\n<p>Proxy (\u0417\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c)\u200a\u2014\u200a\u044d\u0442\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0443\u0440\u0440\u043e\u0433\u0430\u0442\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0435\u043c\u0443.<\/p>\n<p>\u0412 M2 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u201c\u0442\u044f\u0436\u0435\u043b\u044b\u0439\u201d. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 (\u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430), \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0441\u043a\u043e\u0440\u044f\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 di.xml. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"xml\">&lt;type name=\"Magento\\Framework\\DataObject\\Copy\\Config\">     &lt;arguments>         &lt;argument name=\"dataStorage\" xsi:type=\"object\">Magento\\Framework\\DataObject\\Copy\\Config\\Data\\Proxy&lt;\/argument>     &lt;\/arguments> &lt;\/type><\/code><\/pre>\n<p>\u0412 \u0443\u0437\u043b\u0435 <strong>&lt;type><\/strong> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0440\u043e\u043a\u0441\u0438.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u0443\u0437\u043b\u0435 <strong>&lt;arguments><\/strong> \u043c\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u043d\u0430 \u043f\u0440\u043e\u043a\u0441\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <strong>dataStorage<\/strong>. \u0412 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043d\u043e\u0434\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u044c \u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u043b\u0435\u0448 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <strong>\\Proxy<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>di.xml<\/strong>. \u0412\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e. M2 \u0441\u0430\u043c\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0438\u0445 \u0432 \u043f\u0430\u043f\u043a\u0443<strong> \/generated<\/strong><\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Virtual Type \u0438\u00a0Type?<\/h3>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u0430\u043a \u0431\u044b \u201c\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439\u201d \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u043e \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0431\u0435\u0437 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u0442.\u0435 \u201c\u0441\u0442\u0430\u0440\u044b\u0439\u201d \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f Virtual Type \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <strong>di.xml<\/strong>:<\/p>\n<pre><code class=\"xml\">&lt;virtualType name=\"layoutFileSourceBase\"               type=\"Magento\\Framework\\View\\File\\Collector\\Base\">       &lt;arguments>             &lt;argument name=\"subDir\" xsi:type=\"string\">layout&lt;\/argument>       &lt;\/arguments> &lt;\/virtualType><\/code><\/pre>\n<p>\u0412 \u0443\u0437\u043b\u0435 <strong>&lt;virtualType><\/strong> \u0430\u0442\u0440\u0438\u0431\u0443\u0442 name \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u043c\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 type \u0443\u043a\u0430\u0437\u0430\u043d \u201c\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439\u201d \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0412 \u0443\u0437\u043b\u0435 <strong>&lt;arguments><\/strong> \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <strong>subDir<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 layout.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u044d\u0442\u043e\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u0430\u0441\u0441 \u0447\u0435\u0440\u0435\u0437 \u0442\u043e\u0442 \u0436\u0435 <strong>di.xml<\/strong> \u0447\u0435\u0440\u0435\u0437 \u0443\u0437\u0435\u043b <strong>&lt;type><\/strong> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435<\/p>\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-340688","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340688","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=340688"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340688\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}