예제 #1
0
 /**
  * @param \Enlight_Bootstrap $bootstrap
  * @deprecated
  * @return Shop
  */
 public function registerResources(\Enlight_Bootstrap $bootstrap)
 {
     $bootstrap->registerResource('Shop', $this);
     /** @var $locale \Zend_Locale */
     $locale = $bootstrap->getResource('Locale');
     $locale->setLocale($this->getLocale()->toString());
     /** @var $currency \Zend_Currency */
     $currency = $bootstrap->getResource('Currency');
     $currency->setLocale($locale);
     $currency->setFormat($this->getCurrency()->toArray());
     /** @var $config \Shopware_Components_Config */
     $config = $bootstrap->getResource('Config');
     $config->setShop($this);
     /** @var $snippets \Shopware_Components_Config */
     $snippets = $bootstrap->getResource('Snippets');
     $snippets->setShop($this);
     /** @var $snippets \Enlight_Plugin_PluginManager */
     $plugins = $bootstrap->getResource('Plugins');
     /** @var $pluginNamespace  \Shopware_Components_Plugin_Namespace */
     $pluginNamespace = null;
     foreach ($plugins as $pluginNamespace) {
         if ($pluginNamespace instanceof \Shopware_Components_Plugin_Namespace) {
             $pluginNamespace->setShop($this);
         }
     }
     if ($this->getTemplate() !== null) {
         /** @var $template \Enlight_Template_Manager */
         $templateManager = $bootstrap->getResource('Template');
         $template = $this->getTemplate();
         $localeName = $this->getLocale()->toString();
         if ($template->getVersion() == 2) {
             $templateManager->addTemplateDir(array('custom' => $template->toString(), 'local' => '_emotion_local', 'emotion' => '_emotion'));
         } else {
             $templateManager->addTemplateDir(array('custom' => $template->toString(), 'local' => '_local', 'emotion' => '_default'));
         }
         $templateManager->setCompileId('frontend' . '_' . $template->toString() . '_' . $localeName . '_' . $this->getId());
     }
     /** @var $templateMail \Shopware_Components_TemplateMail */
     $templateMail = $bootstrap->getResource('TemplateMail');
     $templateMail->setShop($this);
     return $this;
 }
예제 #2
0
    /**
     * Init template method
     *
     * @return Enlight_Template_Manager
     */
    protected function initTemplate()
    {
        $template = parent::initTemplate();

        $template->setEventManager(
            $this->Application()->Events()
        );

        $template->setTemplateDir(array(
            'custom' => '_local',
            'local' => '_local',
            'emotion' => '_default',
            'default' => '_default',
            'base' => 'templates',
            'include_dir' => '.',
        ));

        $snippetManager = $this->getResource('Snippets');
        $resource = new Enlight_Components_Snippet_Resource($snippetManager);
        $template->registerResource('snippet', $resource);
        $template->setDefaultResourceType('snippet');

        return $template;
    }
예제 #3
0
 /**
  * The class constructor sets the instance of the given enlight application into
  * the internal $application property.
  *
  * @param Shopware $application
  */
 public function __construct(Shopware $application)
 {
     $this->setApplication($application);
     $this->container = $application->Container();
     parent::__construct();
 }
예제 #4
0
 /**
  * @param \Enlight_Bootstrap $bootstrap
  * @return Shop
  */
 public function registerResources(\Enlight_Bootstrap $bootstrap)
 {
     $bootstrap->registerResource('Shop', $this);
     /** @var $locale \Zend_Locale */
     $locale = $bootstrap->getResource('Locale');
     $locale->setLocale($this->getLocale()->toString());
     /** @var $currency \Zend_Currency */
     $currency = $bootstrap->getResource('Currency');
     $currency->setLocale($locale);
     $currency->setFormat($this->getCurrency()->toArray());
     /** @var $config \Shopware_Components_Config */
     $config = $bootstrap->getResource('Config');
     $config->setShop($this);
     /** @var $snippets \Shopware_Components_Config */
     $snippets = $bootstrap->getResource('Snippets');
     $snippets->setShop($this);
     /** @var $snippets \Enlight_Plugin_PluginManager */
     $plugins = $bootstrap->getResource('Plugins');
     /** @var $pluginNamespace  \Shopware_Components_Plugin_Namespace */
     $pluginNamespace = null;
     foreach ($plugins as $pluginNamespace) {
         if ($pluginNamespace instanceof \Shopware_Components_Plugin_Namespace) {
             $pluginNamespace->setShop($this);
         }
     }
     Shopware()->Container()->get('shopware_storefront.context_service')->initializeShopContext();
     if ($this->getTemplate() !== null) {
         /** @var $templateManager \Enlight_Template_Manager */
         $templateManager = $bootstrap->getResource('Template');
         $template = $this->getTemplate();
         $localeName = $this->getLocale()->toString();
         if ($template->getVersion() == 3) {
             $this->registerTheme($template);
         } elseif ($template->getVersion() == 2) {
             $templateManager->addTemplateDir(array('custom' => $template->toString(), 'local' => '_emotion_local', 'emotion' => '_emotion', 'include_dir' => '.'));
         } else {
             throw new \Exception(sprintf('Tried to load unsupported template version %s for template: %s', $template->getVersion(), $template->getName()));
         }
         $templateManager->setCompileId('frontend' . '_' . $template->toString() . '_' . $localeName . '_' . $this->getId());
     }
     /** @var $templateMail \Shopware_Components_TemplateMail */
     $templateMail = $bootstrap->getResource('TemplateMail');
     $templateMail->setShop($this);
     return $this;
 }