示例#1
0
 /**
  * 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\Manager\Standard($config);
         $context->setFilesystemManager($fs);
         $container = $this->container;
         $mail = new \Aimeos\MW\Mail\Swift(function () use($container) {
             return $container->get('mailer');
         });
         $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($this->container->get('aimeos_i18n')->get(array($langid)));
     }
     $session = new \Aimeos\MW\Session\Symfony2($this->container->get('session'));
     $context->setSession($session);
     $this->addUser($context);
     return $context;
 }
示例#2
0
 /**
  * Returns the current context.
  *
  * @param boolean $locale True to add locale object to context, false if not
  * @param string $type Configuration type ("frontend" or "backend")
  * @return \Aimeos\MShop\Context\Item\Iface Context object
  */
 public function get($locale = true, $type = 'frontend')
 {
     $config = $this->container->get('aimeos_config')->get($type);
     if (self::$context === null) {
         $context = new \Aimeos\MShop\Context\Item\Standard();
         $context->setConfig($config);
         $this->addDataBaseManager($context);
         $this->addFilesystemManager($context);
         $this->addMessageQueueManager($context);
         $this->addLogger($context);
         $this->addCache($context);
         $this->addMailer($context);
         self::$context = $context;
     }
     $context = self::$context;
     $context->setConfig($config);
     if ($locale === true) {
         $localeItem = $this->container->get('aimeos_locale')->get($context);
         $context->setI18n($this->container->get('aimeos_i18n')->get(array($localeItem->getLanguageId())));
         $context->setLocale($localeItem);
     }
     $this->addSession($context);
     $this->addUserGroups($context);
     return $context;
 }
示例#3
0
 /**
  * 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);
         $container = $this->container;
         $mail = new \MW_Mail_Swift(function () use($container) {
             return $container->get('mailer');
         });
         $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($this->container->get('aimeos_i18n')->get(array($langid)));
     }
     $session = new \MW_Session_Symfony2($this->container->get('session'));
     $context->setSession($session);
     $this->addUser($context);
     return $context;
 }