Пример #1
0
 /**
  * @param \Magento\Framework\Model\Context $context
  * @param \Magento\Framework\Registry $registry
  * @param \Magento\Framework\Model\Resource\AbstractResource $resource
  * @param \Magento\Framework\Data\Collection\Db $resourceCollection
  * @param array $data
  */
 public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [])
 {
     $this->_registry = $registry;
     $this->_appState = $context->getAppState();
     $this->_eventManager = $context->getEventDispatcher();
     $this->_cacheManager = $context->getCacheManager();
     $this->_resource = $resource;
     $this->_resourceCollection = $resourceCollection;
     $this->_logger = $context->getLogger();
     $this->_actionValidator = $context->getActionValidator();
     if (method_exists($this->_resource, 'getIdFieldName') || $this->_resource instanceof \Magento\Framework\Object) {
         $this->_idFieldName = $this->_getResource()->getIdFieldName();
     }
     parent::__construct($data);
     $this->_construct();
 }