Aimeos\ShopBundle\Service\Context::get PHP Method

get() public method

Returns the current context.
public get ( boolean $locale = true, string $type = 'frontend' ) : Aimeos\MShop\Context\Item\Iface
$locale boolean True to add locale object to context, false if not
$type string 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;
    }