How to define constants or environment variables in Magento 2.2.6?
-
19-02-2021 - |
Pergunta
I want to define constants to use in all my project. How to define constant or environment variables to access all over the project without any special declaration ?
Solução
Define the constant with const
keyword as :
const PATH_EMAIL_IDENTITY = 'trans_email/ident_sales';
To call constant in the same file use : self::PATH_EMAIL_IDENTITY
To call the same constant in another file use : VendorName\ModuleName\Controller\FileName::PATH_EMAIL_IDENTITY
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange