_customerSession = $customerSession; $this->customerRepository = $customerRepository; parent::__construct($context, $addressHelper, $customerMetadata, $data); $this->_isScopePrivate = true; } /** * Initialize block * * @return void */ public function _construct() { parent::_construct(); $this->setTemplate('widget/gender.phtml'); } /** * Check if gender attribute enabled in system * @return bool */ public function isEnabled() { return $this->_getAttribute('gender') ? (bool)$this->_getAttribute('gender')->isVisible() : false; } /** * Check if gender attribute marked as required * @return bool */ public function isRequired() { return $this->_getAttribute('gender') ? (bool)$this->_getAttribute('gender')->isRequired() : false; } /** * Get current customer from session * * @return CustomerInterface */ public function getCustomer() { return $this->customerRepository->getById($this->_customerSession->getCustomerId()); } /** * Returns options from gender attribute * @return OptionInterface[] */ public function getGenderOptions() { return $this->_getAttribute('gender')->getOptions(); } }