/** * Returns the current context * * @param boolean $locale True to add locale object to context, false if not * @return \MShop_Context_Item_Interface Context object */ public function get($locale = true) { if (self::$context === null) { $context = new \MShop_Context_Item_Default(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \MW_DB_Manager_PDO($config); $context->setDatabaseManager($dbm); $mail = new \MW_Mail_Swift(function () { return app('mailer')->getSwiftMailer(); }); $context->setMail($mail); $logger = \MAdmin_Log_Manager_Factory::createManager($context); $context->setLogger($logger); $cache = new \MAdmin_Cache_Proxy_Default($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($locale === true) { $localeItem = $this->getLocale($context); $langid = $localeItem->getLanguageId(); $context->setLocale($localeItem); $context->setI18n(app('\\Aimeos\\Shop\\Base\\I18n')->get(array($langid))); } $session = new \MW_Session_Laravel4($this->session); $context->setSession($session); $this->addUser($context); return $context; }
/** * Returns the current context. * * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object * @return \MShop_Context_Item_Interface */ public function get(\TYPO3\Flow\Mvc\RequestInterface $request = null) { if (self::$context === null) { $context = new \MShop_Context_Item_Default(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \MW_DB_Manager_PDO($config); $context->setDatabaseManager($dbm); $mail = new \MW_Mail_Swift($this->mailer); $context->setMail($mail); $logger = \MAdmin_Log_Manager_Factory::createManager($context); $context->setLogger($logger); $cache = $this->getCache($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($request !== null) { $localeItem = $this->getLocale($context, $request); $context->setLocale($localeItem); $i18n = $this->i18n->get(array($localeItem->getLanguageId())); $context->setI18n($i18n); } $session = new \MW_Session_Flow($this->session); $context->setSession($session); $this->addUser($context); return $context; }