index action

Shows all settings with the specific prefix.

@param string $key The prefix.
@return void|\Cake\Network\Respose
@throws NotFoundException
490659
public function index($key = null)
    {
        if (!$key) {
            $key = 'App';
        }
        $this->Menu->active($this->prefixes[$key]);

        if (!$this->__prefixExists($key)) {
            throw new NotFoundException("The prefix-setting " . $key . " could not be found");
        }

        $prefix = Hash::get($this->prefixes, ucfirst($key));

        $settings = $this->Configurations->find('all')->where([
            'name LIKE' => $key . '%',
            'editable' => 1,
        ])->order(['weight', 'id']);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $settings = $this->Configurations->patchEntities($settings, $this->request->data);
            foreach ($settings as $setting) {
                $this->Flash->success('The settings has been saved.');
                if (!$this->Configurations->save($setting)) {
                    $this->Flash->error('The settings could not be saved. Please, try again.');
                }
            }
            Setting::clear(true);
            Setting::autoLoad();
            return $this->redirect([]);
        }

        $this->set(compact('prefix', 'settings'));
    }
969381
protected function loadProfileByKey($key)
    {
        if (isset($this->profiles['profiles'][$key])) {
            $profile = $this->profiles['profiles'][$key];

            if (is_array($profile)) {
                $this->mergeProfileWithConfig($profile);
            }
        }
    }
239644
public function setKey($key)
    {
        $this->key = $key;
        $this->driver->setNamespace($this->key);
    }
95637
private function getPosition($key)
    {
        if ($this->index->containsKey($key)) {
            return $this->index->get($key);
        }

        return false;
    }
1229057
private function applyPrefix($key)
    {
        $prefix = (string) $this->client->getOption(Redis::OPT_PREFIX);

        return $prefix.$key;
    }
560964
public function post(string $key)
    {
        if (array_key_exists($key, $this->post)) {
            return $this->post[$key];
        }

        return '';
    }
663940
public function useKeyAsIndex($key, $normalize = false)
    {
        if (null === $key) {
            $this->indexKey = null;
            return;
        }

        if (true !== $normalize && !$this->isValidNodeName($key)) {
            throw new \InvalidArgumentException(sprintf('%s is an invalid node name', $key));
        }

        $this->indexKey = $normalize ? $this->normalizer->normalize($key) : $key;
    }
1013395
private function prefix($key)
    {
        if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' && is_file($key) && substr($key, 0, 7) != 'file://') {
            $key = 'file://' . $key;
        }

        return $key;
    }
1112491
protected function _load($key)
    {
        $parts = explode('.', $key);
        $first = array_shift($parts);
        if (isset($this->_loaded[$first])) {
            return;
        }
        $cookie = $this->getController()->getRequest()->getCookie($first);
        if ($cookie === null) {
            return;
        }
        $config = $this->configKey($first);
        $this->_loaded[$first] = true;
        $this->_values[$first] = $this->_decrypt($cookie, $config['encryption'], $config['key']);
    }
719962
public function forget($key)
    {
        $this->checkReservedKeyPattern($key);

        if ($result = parent::forget($key)) {
            if (! $this->operatingOnKeywords()) {

                $affectedKeywords = $this->forgetInverseIndex($key);

                // Set all affected keywords as old keywords and request
                // empty new keywords to remove the flushed key from other indices as well.
                $this->determineKeywordsState($key, [], $affectedKeywords);
                $this->updateKeywordIndex($key);
            }
        }

        if (! $this->operatingOnKeywords()) {
            $this->resetCurrentKeywords();
        }

        return $result;
    }
781396
public function __unsetter($key)
    {
        if (strpos($key, ".") !== false) {
            throw new \Exception('The key to unset can\'t contain a "." ');
        }

        if (isset($this->cleanData[$key])) {
            unset($this->cleanData[$key]);
        }

        if (isset($this->dirtyData[$key])) {
            unset($this->dirtyData[$key]);
        }

        $this->unsetData[$key] = 1;
    }
124970
public function flushConfig($key)
    {
        if (null !== $this->cache) {
            if (isset($this->config[$key]) && array_key_exists('cacheKey', $this->config[$key])) {
                $cacheKey = $this->config[$key]['cacheKey'];
            } else {
                $cacheKey = $this->getCacheKeyForFile($this->getFileNameForKey($key));
            }

            $this->app[$this->cache]->delete($cacheKey);
        }

        unset($this->config[$key]);
    }
121497
protected function getNested(string $key)
    {
        $parts = explode('.', $key);
        $result = $this->settings[$parts[0]];

        for ($i = 1; $i < count($parts); ++$i) {
            $value = $parts[$i];

            if (is_array($result) && array_key_exists($value, $result)) {
                $result = $result[$value];
                continue;
            }

            $result = null;
            break;
        }

        return $result;
    }
31812
protected function hasTemplateOption($key)
    {
        if ($this->templateOptions === null) {
            $this->templateOptions = $this->buildTemplateOptions();
        }

        return isset($this->templateOptions[$key]);
    }
1150289
public function find($key)
    {
        $key = $this->normalize($key);

        $filePath = null;

        foreach ($this->paths as $path) {
            foreach ($this->extensions as $ext) {
                if (is_file($path . '/' . $key . $ext)) {
                    $filePath = $path . '/' . $key . $ext;

                    break 2;
                }
            }
        }

        if ($filePath === null) {
            $paths = implode(" |\n ", $this->paths);

            throw new LayoutNotFoundException('View file not found: ' . $key . ".\n (Paths: " . $paths . ')', 13001);
        }

        return $filePath;
    }
67308
protected function setKey($key)
    {
        // If a handler switches key, we need to decrement the counter for the old
        // key, and increment the counter for the new key.
        $this->removeKey();

        // Set the new key, and increment the counter appropriately.
        $this->key = $key;
        if (isset($key)) {
            static::$keys[$key] = isset(static::$keys[$key]) ? static::$keys[$key] + 1 : 1;
        }
    }
750948
public function &offsetGet($key) {
        for($i = 0; $i < count($this->arrays); ++$i) {
            if(Util::exists($this->arrays[$i], $key)) {
                return $this->arrays[$i][$key];
            }
        }
        throw new KeyNotFoundException($key);
    }