*/ class Mage_Shell_Compiler extends Mage_Shell_Abstract { /** * Compiler process object * * @var Mage_Compiler_Model_Process */ protected $_compiler; /** * Get compiler process object * * @return Mage_Compiler_Model_Process */ protected function _getCompiler() { if ($this->_compiler === null) { $this->_compiler = Mage::getModel('compiler/process'); } return $this->_compiler; } /** * Run script * */ public function run() { if (isset($this->_args['disable'])) { $this->_getCompiler()->registerIncludePath(false); echo "Compiler include path disabled\n"; } else if (isset($this->_args['enable'])) { if ($this->_getCompiler()->getCompiledFilesCount() == 0) { die("Compilation State: Not Compiled\nPlease run with option compile\n"); } $this->_getCompiler()->registerIncludePath(); echo "Compiler include path enabled\n"; } else if (isset($this->_args['compile'])) { try { $this->_getCompiler()->run(); echo "Compilation successfully finished\n"; } catch (Mage_Core_Exception $e) { echo $e->getMessage() . "\n"; } catch (Exception $e) { echo "Compilation unknown error:\n\n"; echo $e . "\n"; } } else if (isset($this->_args['clear'])) { try { $this->_getCompiler()->clear(); echo "Compilation successfully cleared\n"; } catch (Mage_Core_Exception $e) { echo $e->getMessage() . "\n"; } catch (Exception $e) { echo "Compilation unknown error:\n\n"; echo $e . "\n"; } } else if (isset($this->_args['state']) || isset($this->_args['fullstate'])) { $compiler = $this->_getCompiler(); $compilerConfig = '../includes/config.php'; if (file_exists($compilerConfig)) { include $compilerConfig; } $status = defined('COMPILER_INCLUDE_PATH') ? 'Enabled' : 'Disabled'; $state = $compiler->getCollectedFilesCount() > 0 ? 'Compiled' : 'Not Compiled'; echo "Compiler Status: " . $status . "\n"; echo "Compilation State: " . $state . "\n"; echo "Collected Files Count: " . $compiler->getCollectedFilesCount() . "\n"; echo "Compiled Scopes Count: " . $compiler->getCompiledFilesCount() . "\n"; } else { echo $this->usageHelp(); } } /** * Retrieve Usage Help Message * */ public function usageHelp() { return <<run();