Check this out:
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\View\DesignInterface $design,
\Magento\Framework\Registry $registry,
\Magento\Store\Model\App\Emulation $appEmulation,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\RequestInterface $request,
\Magento\Newsletter\Model\Template\Filter $filter,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Newsletter\Model\TemplateFactory $templateFactory,
\Magento\Framework\Filter\FilterManager $filterManager,
array $data = []
) {
parent::__construct($context, $design, $registry, $appEmulation, $storeManager, $data);
$this->_storeManager = $storeManager;
$this->_request = $request;
$this->_filter = $filter;
$this->_scopeConfig = $scopeConfig;
$this->_templateFactory = $templateFactory;
$this->_filterManager = $filterManager;
}
It's from https://github.com/magento/magento2/blob/develop/app/code/Magento/Newsletter/Model/Template.php#L107
The function declaration takes more space than the body.
I think it has something to do with dependency injection.
What's the benefit of structuring your code as above instead of something like this:
public function __construct(Magento $magento, array $data = []
) {
parent::__construct($magento->context, $magento->design, $magento->registry, $magento->appEmulation, $magento->storeManager, $data);
$this->_storeManager = $magento->storeManager;
$this->_request = $magento->request;
$this->_filter = $magento->filter;
$this->_scopeConfig = $magento->scopeConfig;
$this->_templateFactory = $magento->templateFactory;
$this->_filterManager = $magento->filterManager;
}
Notice that I only need to create the Magento instance once. Then I pass it to all the classes that need stuff.