/** * Returns the current context * * @param boolean $locale True to add locale object to context, false if not * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true) { if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \Aimeos\MW\DB\Manager\PDO($config); $context->setDatabaseManager($dbm); $fs = new \Aimeos\MW\Filesystem\Laravel(app('filesystem.disk')); $context->setFilesystem($fs); $mail = new \Aimeos\MW\Mail\Swift(function () { return app('mailer')->getSwiftMailer(); }); $context->setMail($mail); $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); $context->setLogger($logger); $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($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 \Aimeos\MW\Session\Laravel4($this->session); $context->setSession($session); $this->addUser($context); return $context; }