Returns and caches structures for given webspace.

@param string $webspaceKey

@return array
968583
protected function loadStructures($webspaceKey)
    {
        $structures = [];
        $keys = [];
        foreach ($this->structureManager->getStructures() as $page) {
            /* @var PageBridge $page */
            $template = sprintf('%s.html.twig', $page->getView());
            if ($this->templateExists($template)) {
                $keys[] = $page->getKey();
                $structures[] = $page;
            }
        }

        $this->cache->save($webspaceKey, $keys);

        return $structures;
    }
641731
protected function getCache($cacheKey)
    {
        $cacheKey = 'combiner.'.$cacheKey;

        if (!Cache::has($cacheKey)) {
            return false;
        }

        return @unserialize(@base64_decode(Cache::get($cacheKey)));
    }
852603
public function get($cacheKey)
    {
        // TODO: Refactor for strict types!
        $path = $this->resolvePath($cacheKey, false);
        if (file_exists($path)) {
            return file_get_contents($path);
        }

        return null;
    }
208374
public function getQueryMapping($schemaKey = 'default')
    {
        if (isset($this->responseCache[$schemaKey])) {
            return $this->responseCache[$schemaKey];
        }

        /** @noinspection PhpUndefinedFieldInspection */
        /** @noinspection StaticInvocationViaThisInspection */
        $urlWithKey = $this->getSchemaMapping();
        if (!isset($urlWithKey[$schemaKey])) {
            return [];
        }

        $url = trim($urlWithKey[$schemaKey]);
        $map = null;
        try {
            $contents = $this->getClient()->getURL($url, $this->config()->get('timeout'));
            $map = json_decode($contents, true);
        } catch (Exception $e) {
            user_error($e->getMessage(), E_USER_WARNING);
            $map = [];
        }
        if (!is_array($map)) {
            $map = [];
        }

        $this->responseCache[$schemaKey] = $map;

        return $map;
    }
505027
protected function parseNamespacedSegments($key)
    {
        list($namespace, $item) = explode('::', $key);

        // If the namespace is registered as a package, we will just assume the group
        // is equal to the namespace since all packages cascade in this way having
        // a single file per package, otherwise we'll just parse them as normal.
        if (in_array($namespace, $this->packages)) {
            return $this->parsePackageSegments($key, $namespace, $item);
        }

        // Next we'll just explode the first segment to get the namespace and group
        // since the item should be in the remaining segments. Once we have these
        // two pieces of data we can proceed with parsing out the item's value.
        $itemSegments = explode('.', $item);

        $groupAndItem = array_slice($this->parseBasicSegments($itemSegments), 1);

        return array_merge([$namespace], $groupAndItem);
    }
166957
private function outputWebspacePageTemplates(Webspace $webspace)
    {
        $this->output->writeln('Page Templates:');

        $structures = $this->structureManager->getStructures();

        $checkedTemplates = [];

        foreach ($webspace->getDefaultTemplates() as $template) {
            $checkedTemplates[] = $template;
        }

        foreach ($structures as $structure) {
            $template = $structure->getKey();

            if (!$structure->getInternal() && !in_array($template, $checkedTemplates)) {
                $this->validatePageTemplate('page', $structure->getKey());
            }
        }
    }
297504
public static function getArray($arrayKey) {
		self::start ();
		if (isset ( $_SESSION [$arrayKey] )) {
			$array = $_SESSION [$arrayKey];
			if (! is_array ( $array ))
				$array = [ ];
		} else
			$array = [ ];
		return $array;
	}
1039255
protected function getData($key)
    {
        $cacheKey = $this->key($key);
        return array_key_exists($cacheKey, $this->cache)?$this->cache[$this->key($key)]:false;
    }
1366369
private function outputWebspace(Webspace $webspace)
    {
        $this->output->writeln(
            sprintf(
                '<info>%s</info> - <info>%s</info>',
                $webspace->getKey(),
                $webspace->getName()
            )
        );

        $this->outputWebspaceDefaultTemplates($webspace);
        $this->outputWebspacePageTemplates($webspace);
        $this->outputWebspaceTemplates($webspace);
        $this->outputWebspaceLocalizations($webspace);
    }
1290129
private function getLocalesByPortalKey($portalKey)
    {
        $portal = $this->webspaceManager->findPortalByKey($portalKey);

        return array_map(
            function(Localization $localization) {
                return $localization->getLocale();
            },
            $portal->getLocalizations()
        );
    }
1147104
protected static function getTemplatesByKey($key)
    {
        $templates = [];
        $scheme = PhpSms::scheme();
        $config = PhpSms::config();
        foreach (array_keys($scheme) as $name) {
            if (isset($config[$name][$key])) {
                $templates[$name] = $config[$name][$key];
            }
        }

        return $templates;
    }
295139
protected function getCache($key) {
        $cached = ArrayHelper::getValue($this->cachedData, $key);
        if (!isset($cached)) {
            $cacheData = $this->resolveCacheComponent()->get($this->cacheKeyName);
            $cached = $this->cachedData[$key] = ArrayHelper::getValue($cacheData, $key);
        }
        return $cached;
    }
781604
protected function cacheData(string $key, string $data) : string
    {
        $this->cache[$key] = $data;

        return $data;
    }
778059
public function findByWebspaceKey($webspaceKey)
    {
        $queryBuilder = $this->createQueryBuilder('a')
            ->addSelect('domains')
            ->leftJoin('a.domains', 'domains')
            ->where('a.webspaceKey = :webspaceKey')
            ->andWhere('a.allDomains = TRUE OR domains.environment = :environment')
            ->orderBy('a.id', 'ASC');

        $query = $queryBuilder->getQuery();
        $query->setParameter('webspaceKey', $webspaceKey);
        $query->setParameter('environment', $this->environment);

        return $query->getResult();
    }
1191191
protected function getModel($key)
    {
        if (!array_key_exists($key, $this->models)) {
            list($namespace, $key) = $this->splitNamespaceAndKey($key);

            $this->models[$key] = Config::query()
                                        ->where(Config::FIELD_NAMESPACE, $namespace)
                                        ->where(Config::FIELD_KEY, $key)
                                        ->first();

            // Cache if data is found in database
            if ($this->models[$key] !== null) {
                $this->cache->forever($key, $this->models[$key]->value);
            }
        }

        return $this->models[$key];
    }
1179773
public function getTreeHints() {
        $json = '';

        $classes = array('Snippet', 'SnippetLanguage', 'SnippetFolder');

         $cacheCanCreate = array();
         foreach($classes as $class) $cacheCanCreate[$class] = singleton($class)->canCreate();

         // Generate basic cache key. Too complex to encompass all variations
         $cache=SS_Cache::factory('CodeBank_TreeHints');
         $cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes))));
         if($this->request->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
         $json = $cache->load($cacheKey);
         if(!$json) {
            $def['Root'] = array();
            $def['Root']['disallowedParents'] = array();

            foreach($classes as $class) {
                $sng=singleton($class);
                $allowedChildren = $sng->allowedChildren();
                
                // SiteTree::allowedChildren() returns null rather than an empty array if SiteTree::allowed_chldren == 'none'
                if($allowedChildren == null) $allowedChildren = array();
                
                // Find i18n - names and build allowed children array
                foreach($allowedChildren as $child) {
                    $instance = singleton($child);
                    
                    if($instance instanceof HiddenClass) continue;

                    if(!array_key_exists($child, $cacheCanCreate) || !$cacheCanCreate[$child]) continue;

                    // skip this type if it is restricted
                    if($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) continue;

                    $title = $instance->i18n_singular_name();

                    $def[$class]['allowedChildren'][] = array("ssclass" => $child, "ssname" => $title);
                }

                $allowedChildren = array_keys(array_diff($classes, $allowedChildren));
                if($allowedChildren) $def[$class]['disallowedChildren'] = $allowedChildren;
                $defaultChild = $sng->default_child();
                if($defaultChild != null) $def[$class]['defaultChild'] = $defaultChild;
                if(isset($def[$class]['disallowedChildren'])) {
                    foreach($def[$class]['disallowedChildren'] as $disallowedChild) {
                        $def[$disallowedChild]['disallowedParents'][] = $class;
                    }
                }
                
                // Are any classes allowed to be parents of root?
                $def['Root']['disallowedParents'][] = $class;
            }

            $json = Convert::raw2xml(Convert::raw2json($def));
            $cache->save($json, $cacheKey);
        }
        return $json;
    }
987258
public function getMetadata($key)
    {
        $this->init();
        list($containerName, $key) = $this->tokenizeKey($key);

        try {
            $properties = $this->blobProxy->getBlobProperties($containerName, $key);

            return $properties->getMetadata();
        } catch (ServiceException $e) {
            $errorCode = $this->getErrorCodeFromServiceException($e);

            throw new \RuntimeException(sprintf(
                'Failed to get metadata for blob "%s" in container "%s": %s (%s).',
                $key,
                $containerName,
                $e->getErrorText(),
                $errorCode
            ), $e->getCode());
        }
    }