|  | 
| 1 | 1 | <?php | 
|  | 2 | +/* | 
|  | 3 | + * Navigate Commerce | 
|  | 4 | + * | 
|  | 5 | + * @author        Navigate Commerce | 
|  | 6 | + * @package       Navigate_PasswordHideShow | 
|  | 7 | + * @copyright     Copyright (c) Navigate (https://www.navigatecommerce.com/) | 
|  | 8 | + * @license       https://www.navigatecommerce.com/end-user-license-agreement | 
|  | 9 | + */ | 
|  | 10 | + | 
| 2 | 11 | namespace Navigate\PasswordHideShow\Block; | 
| 3 | 12 | 
 | 
| 4 | 13 | use Magento\Framework\View\Element\Template; | 
|  | 
| 8 | 17 | 
 | 
| 9 | 18 | class Main extends \Magento\Framework\View\Element\Template | 
| 10 | 19 | { | 
| 11 |  | -    const IS_ENABLE = 'passwordhideshow/general/enable'; | 
| 12 |  | -    const ENABLE_LOGIN = 'passwordhideshow/general/enable_login_page'; | 
| 13 |  | -    const ENABLE_REGISTRATION = 'passwordhideshow/general/enable_registration_page'; | 
| 14 |  | -    const ENABLE_EDIT_ACCOUNT = 'passwordhideshow/general/enable_edit_account'; | 
| 15 |  | -    const SHOW_PASSWORD = 'passwordhideshow/general/show_pasword'; | 
| 16 |  | -    const HIDE_PASSWORD = 'passwordhideshow/general/hide_pasword'; | 
| 17 |  | -     | 
|  | 20 | +    protected const IS_ENABLE = 'passwordhideshow/general/enable'; | 
|  | 21 | +    protected const ENABLE_LOGIN = 'passwordhideshow/general/enable_login_page'; | 
|  | 22 | +    protected const ENABLE_REGISTRATION = 'passwordhideshow/general/enable_registration_page'; | 
|  | 23 | +    protected const ENABLE_EDIT_ACCOUNT = 'passwordhideshow/general/enable_edit_account'; | 
|  | 24 | +    protected const SHOW_PASSWORD = 'passwordhideshow/general/show_pasword'; | 
|  | 25 | +    protected const HIDE_PASSWORD = 'passwordhideshow/general/hide_pasword'; | 
|  | 26 | + | 
|  | 27 | +    /** | 
|  | 28 | +     * @var StoreManagerInterface | 
|  | 29 | +     */ | 
| 18 | 30 |     protected $modelStoreManagerInterface; | 
|  | 31 | + | 
|  | 32 | +    /** | 
|  | 33 | +     * Scope config Interface | 
|  | 34 | +     * | 
|  | 35 | +     * @var ScopeConfigInterface | 
|  | 36 | +     */ | 
| 19 | 37 |     protected $scopeConfig; | 
| 20 | 38 | 
 | 
| 21 |  | -    public function __construct(Template\Context $context, StoreManagerInterface $modelStoreManagerInterface, ScopeConfigInterface $scopeConfig, array $data = []) | 
| 22 |  | -    { | 
|  | 39 | +    /** | 
|  | 40 | +     * Construct method | 
|  | 41 | +     * | 
|  | 42 | +     * @param Template\Context $context | 
|  | 43 | +     * @param StoreManagerInterface $modelStoreManagerInterface | 
|  | 44 | +     * @param ScopeConfigInterface $scopeConfig | 
|  | 45 | +     * @param array $data | 
|  | 46 | +     */ | 
|  | 47 | +    public function __construct( | 
|  | 48 | +        Template\Context $context, | 
|  | 49 | +        StoreManagerInterface $modelStoreManagerInterface, | 
|  | 50 | +        ScopeConfigInterface $scopeConfig, | 
|  | 51 | +        array $data = [] | 
|  | 52 | +    ) { | 
| 23 | 53 |         $this->modelStoreManagerInterface = $modelStoreManagerInterface; | 
| 24 | 54 |         $this->scopeConfig = $scopeConfig; | 
| 25 | 55 |         parent::__construct($context, $data); | 
| 26 | 56 |     } | 
| 27 | 57 | 
 | 
|  | 58 | +    /** | 
|  | 59 | +     * Get Current Store Info | 
|  | 60 | +     * | 
|  | 61 | +     * @return $this | 
|  | 62 | +     */ | 
| 28 | 63 |     public function getCurrentStoreInfo() | 
| 29 | 64 |     { | 
| 30 | 65 |         return $this->modelStoreManagerInterface->getStore()->getId(); | 
| 31 | 66 |     } | 
| 32 | 67 | 
 | 
|  | 68 | +    /** | 
|  | 69 | +     * Function to check enabled or not | 
|  | 70 | +     * | 
|  | 71 | +     * @return boolean | 
|  | 72 | +     */ | 
| 33 | 73 |     public function isEnable() | 
| 34 | 74 |     { | 
| 35 |  | -        return (bool)$this->scopeConfig->getValue(self::IS_ENABLE, ScopeInterface::SCOPE_STORE, $this->getCurrentStoreInfo()); | 
|  | 75 | +        return (bool)$this->scopeConfig->getValue( | 
|  | 76 | +            self::IS_ENABLE, | 
|  | 77 | +            ScopeInterface::SCOPE_STORE, | 
|  | 78 | +            $this->getCurrentStoreInfo() | 
|  | 79 | +        ); | 
| 36 | 80 |     } | 
| 37 | 81 | 
 | 
| 38 |  | -    public function IsEnableForLogin() | 
|  | 82 | +    /** | 
|  | 83 | +     * Function to check enable for login or not | 
|  | 84 | +     * | 
|  | 85 | +     * @return boolean | 
|  | 86 | +     */ | 
|  | 87 | +    public function isEnableForLogin() | 
| 39 | 88 |     { | 
| 40 | 89 |         if ($this->isEnable()) { | 
| 41 |  | -            return $this->scopeConfig->getValue(self::ENABLE_LOGIN, ScopeInterface::SCOPE_STORE, $this->getCurrentStoreInfo()); | 
|  | 90 | +            return $this->scopeConfig->getValue( | 
|  | 91 | +                self::ENABLE_LOGIN, | 
|  | 92 | +                ScopeInterface::SCOPE_STORE, | 
|  | 93 | +                $this->getCurrentStoreInfo() | 
|  | 94 | +            ); | 
| 42 | 95 |         } | 
| 43 | 96 |         return false; | 
| 44 | 97 |     } | 
| 45 | 98 | 
 | 
| 46 |  | -    public function IsEnableForRegistration() | 
|  | 99 | +    /** | 
|  | 100 | +     * Function to check enabled for registration | 
|  | 101 | +     * | 
|  | 102 | +     * @return boolean | 
|  | 103 | +     */ | 
|  | 104 | +    public function isEnableForRegistration() | 
| 47 | 105 |     { | 
| 48 | 106 |         if ($this->isEnable()) { | 
| 49 |  | -            return $this->scopeConfig->getValue(self::ENABLE_REGISTRATION, ScopeInterface::SCOPE_STORE, $this->getCurrentStoreInfo()); | 
|  | 107 | +            return $this->scopeConfig->getValue( | 
|  | 108 | +                self::ENABLE_REGISTRATION, | 
|  | 109 | +                ScopeInterface::SCOPE_STORE, | 
|  | 110 | +                $this->getCurrentStoreInfo() | 
|  | 111 | +            ); | 
| 50 | 112 |         } | 
| 51 | 113 |         return false; | 
| 52 | 114 |     } | 
| 53 | 115 | 
 | 
| 54 |  | -    public function IsEnableForEditAccount() | 
|  | 116 | +    /** | 
|  | 117 | +     * Function to check enable for edit account | 
|  | 118 | +     * | 
|  | 119 | +     * @return boolean | 
|  | 120 | +     */ | 
|  | 121 | +    public function isEnableForEditAccount() | 
| 55 | 122 |     { | 
| 56 | 123 |         if ($this->isEnable()) { | 
| 57 |  | -            return $this->scopeConfig->getValue(self::ENABLE_EDIT_ACCOUNT, ScopeInterface::SCOPE_STORE, $this->getCurrentStoreInfo()); | 
|  | 124 | +            return $this->scopeConfig->getValue( | 
|  | 125 | +                self::ENABLE_EDIT_ACCOUNT, | 
|  | 126 | +                ScopeInterface::SCOPE_STORE, | 
|  | 127 | +                $this->getCurrentStoreInfo() | 
|  | 128 | +            ); | 
| 58 | 129 |         } | 
| 59 | 130 |         return false; | 
| 60 | 131 |     } | 
| 61 | 132 | 
 | 
|  | 133 | +    /** | 
|  | 134 | +     * Retrive password iamge | 
|  | 135 | +     * | 
|  | 136 | +     * @return boolean|string | 
|  | 137 | +     */ | 
| 62 | 138 |     public function getShowPasswordImage() | 
| 63 | 139 |     { | 
| 64 | 140 |         if ($this->isEnable()) { | 
| 65 | 141 |             $showpassword = ""; | 
| 66 |  | -            $showpassword = $this->scopeConfig->getValue(self::SHOW_PASSWORD, ScopeInterface::SCOPE_STORE, $this->getCurrentStoreInfo()); | 
|  | 142 | +            $showpassword = $this->scopeConfig->getValue( | 
|  | 143 | +                self::SHOW_PASSWORD, | 
|  | 144 | +                ScopeInterface::SCOPE_STORE, | 
|  | 145 | +                $this->getCurrentStoreInfo() | 
|  | 146 | +            ); | 
| 67 | 147 |             if (!empty($showpassword)) { | 
| 68 |  | -                $mediaUrl = $this->modelStoreManagerInterface->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'Navigate/Icon/'; | 
|  | 148 | +                $mediaUrl = $this->modelStoreManagerInterface->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'Navigate/Icon/'; // phpcs:ignore | 
| 69 | 149 |                 return $mediaUrl.$showpassword; | 
| 70 | 150 |             } | 
| 71 | 151 |         } | 
| 72 | 152 |         return false; | 
| 73 | 153 |     } | 
| 74 | 154 | 
 | 
|  | 155 | +    /** | 
|  | 156 | +     * Retrive hide password image | 
|  | 157 | +     * | 
|  | 158 | +     * @return boolean|string | 
|  | 159 | +     */ | 
| 75 | 160 |     public function getHidePasswordImage() | 
| 76 | 161 |     { | 
| 77 | 162 |         if ($this->isEnable()) { | 
| 78 | 163 |             $hidepassword = ""; | 
| 79 |  | -            $hidepassword = $this->scopeConfig->getValue(self::HIDE_PASSWORD, ScopeInterface::SCOPE_STORE, $this->getCurrentStoreInfo()); | 
|  | 164 | +            $hidepassword = $this->scopeConfig->getValue( | 
|  | 165 | +                self::HIDE_PASSWORD, | 
|  | 166 | +                ScopeInterface::SCOPE_STORE, | 
|  | 167 | +                $this->getCurrentStoreInfo() | 
|  | 168 | +            ); | 
| 80 | 169 |             if (!empty($hidepassword)) { | 
| 81 |  | -                $mediaUrl = $this->modelStoreManagerInterface->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'Navigate/Icon/'; | 
|  | 170 | +                $mediaUrl = $this->modelStoreManagerInterface->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'Navigate/Icon/'; // phpcs:ignore | 
| 82 | 171 |                 return $mediaUrl.$hidepassword; | 
| 83 | 172 |             } | 
| 84 | 173 |         } | 
|  | 
0 commit comments