below is my block file code
class View extends \Magento\Framework\View\Element\Template
{
protected $_registry;
protected $_customerSession;
protected $_customer;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Customer\Model\Session $customerSession,
\Magento\Customer\Model\Customer $customer
) {
$this->_registry = $registry;
$this->_customerSession = $customerSession;
$this->_customer = $customer;
parent::__construct($context);
}
public function getUser()
{
if (!$this->_loadValidUser()) {
return;
}
return $this->registry->registry('current_user');
}
protected function _loadValidUser($userId = null)
{
$userId = (int) $this->getRequest()->getParam('user_id');
try {
$user = $this->_customer->load($userId);
$this->registry->register('current_user', $user);
return $user;
}catch (Exception $e) {
print_r($e->getMessage());
return false;
}
}
}
What is the mistake in above construction? I am getting the error like
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Framework\View\Element\Template