Jawaban:
Jika Anda mengacu pada mode penyebaran, Anda bisa melakukannya melalui CLI menggunakan:
php bin/magento deploy:mode:show
Jika Anda perlu melakukannya melalui kode murni Anda dapat menggunakan:
protected $_appState;
public function __construct( \Magento\Framework\App\State $appState )
{
$this->_appState = $appState;
}
public function doSomething() {
switch ( $this->_appState->getMode() ) {
case \Magento\Framework\App\State::MODE_DEFAULT:
// Action for default mode
break;
case \Magento\Framework\App\State::MODE_PRODUCTION:
// Action for production mode
break;
case \Magento\Framework\App\State::MODE_DEVELOPER:
// Action for developer mode
break;
}
}