/** * Returns a snippet model instance * * @param string $namespace * @return Enlight_Components_Snippet_Namespace */ public function getNamespace($namespace = null) { $key = $namespace === null ? '__ignore' : (string)$namespace; if (!isset($this->namespaces[$key])) { if (isset($this->fileAdapter) && strpos($namespace, 'backend/') === 0) { if (isset($this->locale) && $this->locale->toString() == 'de_DE') { $section = array('de_DE', 'default'); } else { $section = array('default'); } $this->namespaces[$key] = new $this->defaultNamespaceClass(array( 'adapter' => $this->fileAdapter, 'name' => $namespace, 'section' => $section )); } elseif ($this->shop !== null) { $this->namespaces[$key] = new $this->defaultNamespaceClass(array( 'adapter' => $this->adapter, 'name' => $namespace, 'section' => array( $this->shop->getId(), $this->locale->getId() ), 'extends' => $this->extends, )); } else { $this->namespaces[$key] = new $this->defaultNamespaceClass(array( 'adapter' => $this->adapter, 'name' => $namespace, 'section' => $this->defaultSection )); } } return $this->namespaces[$key]; }
/** * Returns a snippet model instance * * @param string $namespace * @return Enlight_Components_Snippet_Namespace */ public function getNamespace($namespace = null) { $key = $namespace === null ? '__ignore' : (string) $namespace; if (!isset($this->namespaces[$key])) { if ($this->snippetConfig['readFromDb']) { $this->namespaces[$key] = new $this->defaultNamespaceClass(array('adapter' => $this->adapter, 'name' => $namespace, 'section' => array($this->shop ? $this->shop->getId() : 1, $this->locale ? $this->locale->getId() : $this->getDefaultLocale()->getId()), 'extends' => $this->extends)); } if ($this->snippetConfig['readFromIni'] && (!isset($this->namespaces[$key]) || count($this->namespaces[$key]) == 0) && isset($this->fileAdapter)) { $fullNamespace = new $this->defaultNamespaceClass(array('adapter' => $this->fileAdapter, 'name' => $namespace, 'section' => null)); $locale = $this->locale ? $this->locale->getLocale() : $this->getDefaultLocale()->getLocale(); if (!array_key_exists($locale, $fullNamespace->toArray()) && in_array($locale, array('en_GB', 'default')) && count(array_keys($fullNamespace->toArray()))) { $locale = array_shift(array_diff(array('en_GB', 'default'), array($locale))); } $fullNamespace->setSection($locale); $fullNamespace->setData($fullNamespace->get($locale)); $this->namespaces[$key] = $fullNamespace; } } if (!isset($this->namespaces[$key])) { $this->namespaces[$key] = new $this->defaultNamespaceClass(array('name' => $namespace)); } return $this->namespaces[$key]; }