diff --git a/src/N98/Magento/Application.php b/src/N98/Magento/Application.php index 555fe8428..015accf25 100644 --- a/src/N98/Magento/Application.php +++ b/src/N98/Magento/Application.php @@ -275,8 +275,7 @@ public function initMagento($soft = false) $isMagento2 = $this->detectionResult->getMajorVersion() === self::MAGENTO_MAJOR_VERSION_2; if ($isMagento2) { $magento2Initializer = new Magento2Initializer($this->getAutoloader()); - $app = $magento2Initializer->init($this->getMagentoRootFolder()); - $this->_objectManager = $app->getObjectManager(); + $this->_objectManager = $magento2Initializer->init($this->getMagentoRootFolder()); } else { $magento1Initializer = new Magento1Initializer($this->getHelperSet()); $magento1Initializer->init(); diff --git a/src/N98/Magento/Application/Magento2Initializer.php b/src/N98/Magento/Application/Magento2Initializer.php index 63adb9280..f1c926854 100644 --- a/src/N98/Magento/Application/Magento2Initializer.php +++ b/src/N98/Magento/Application/Magento2Initializer.php @@ -5,9 +5,9 @@ use Composer\Autoload\ClassLoader; use Magento\Framework\App\Bootstrap; use Magento\Framework\Autoload\AutoloaderRegistry; +use Magento\Framework\ObjectManagerInterface; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManager; -use N98\Magento\Framework\App\Magerun; use N98\Util\PharWrapper; /** @@ -32,7 +32,7 @@ public function __construct(ClassLoader $autoloader) /** * @param string $magentoRootFolder - * @return \N98\Magento\Framework\App\Magerun + * @return ObjectManagerInterface * @throws \Exception */ public function init($magentoRootFolder) @@ -57,12 +57,9 @@ public function init($magentoRootFolder) $params['entryPoint'] = basename(__FILE__); $bootstrap = Bootstrap::create($magentoRootFolder, $params); - /** @var \Magento\Framework\App\Cron $app */ - $app = $bootstrap->createApplication(Magerun::class, []); - /* @var $app \N98\Magento\Framework\App\Magerun */ - $app->launch(); + $objectManager = $bootstrap->getObjectManager(); - return $app; + return $objectManager; } public static function loadMagentoBootstrap($magentoRootFolder) diff --git a/src/N98/Magento/Framework/App/Magerun.php b/src/N98/Magento/Framework/App/Magerun.php deleted file mode 100644 index 4ede25303..000000000 --- a/src/N98/Magento/Framework/App/Magerun.php +++ /dev/null @@ -1,77 +0,0 @@ -objectManager = $objectManager; - } - - /** - * Launch application - * - * @return \Magento\Framework\App\ResponseInterface - */ - public function launch() - { - /* - * this method is intentionally left empty - * - * earlier the area-code was set to "adminhtml" but this should be done - * within a Command::execute() implementation if the command needs a specific - * area. - * - * this might even extend to bootstrapping the application as it configures - * the ObjectManager: - * - * @see \N98\Magento\Application::initMagento() - */ - return null; - } - - /** - * @return ObjectManagerInterface - */ - public function getObjectManager() - { - if ($this->objectManager === null) { - throw new RuntimeException('Please initialize Magento to use the object manager.'); - } - - return $this->objectManager; - } - - /** - * Ability to handle exceptions that may have occurred during bootstrap and launch - * - * Return values: - * - true: exception has been handled, no additional action is needed - * - false: exception has not been handled - pass the control to Bootstrap - * - * @param Bootstrap $bootstrap - * @param \Exception $exception - * @return bool - */ - public function catchException(Bootstrap $bootstrap, \Exception $exception) - { - return false; - } -}