/** * call mode handler * * @throws Exception * @return void */ public function main() { $modeSettings = $this->config->get('mode', $this->request->getMode()); if ($modeSettings === null) { throw new RuntimeException('mode `' . $this->request->getMode() . '` not applied'); } if (!isset($modeSettings['handler']) || !class_exists($modeSettings['handler'])) { throw new RuntimeException('mode `' . $this->request->getMode() . '` is invalid'); } $handler = new $modeSettings['handler']($this->config, $this->request, $modeSettings); if (!$handler instanceof AbstractModeHandler) { throw new RuntimeException('mode `' . $this->request->getMode() . '` handler `' . $modeSettings['handler'] . '` is not instance of `handler\\mode\\AbstractModeHandler`'); } $handler->handle(); }
/** * @param string $formId * @return bool */ protected function isStoredFormClose($formId) { $form = $this->getStoredFormData(); if ($form === null || !$this->isFormId($formId) || $form['formId'] !== $formId) { return false; } return $this->storedForms->get($this->request->getArea(), $this->request->getPage())['close']; }
/** * make MySQL DELETE * * @see Delete * @throws RuntimeException * @return bool */ public final function delete() { if ($this->isReadOnly()) { throw new RuntimeException('can\'t delete read only object'); } if (!$this->isFilled()) { throw new RuntimeException('nothing to delete'); } $this->toReadOnly(); $request = new Request($this->config, $this->accessPoint); $queryList = array(); for ($i = 0; $i < $this->getLength(); $i++) { $queryList[] = (new Delete($this->getTableName()))->addCondition($this->primaryKey, $this->columnList[$this->primaryKey]['type'], $this->content->get($i, $this->primaryKey))->setLimit(1)->assemble(); } try { $request->queryList($queryList); } catch (Exception $e) { return false; } return true; }
/** * @return Bucket */ protected final function getTextBucket() { $texts = new Bucket(); if (isset($this->settings['multiLang']) && $this->settings['multiLang'] === true) { # additional lang-files if ($this->config->isArray('multiLang', 'loadList')) { $loadPathList = $this->config->get('multiLang', 'loadList'); } else { $loadPathList = array(); } # auto-loading lang-file if ($this->config->isTrue('multiLang', 'autoLoading')) { $language = $this->config->get('multiLang', 'language'); $area = $this->request->getArea(); $page = $this->request->getPage(); $loadPathList[] = 'area/' . $area . '/text/' . $language . '/page/' . $page . '.ini'; } foreach ($loadPathList as $loadPath) { $loadFile = (new File('private/src'))->attach($loadPath); if ($loadFile->isFile()) { $texts->applyIni($loadFile); } else { Logger::warning('lang-file `' . $loadFile . '` not found'); } } } return $texts; }
/** * @expectedException RuntimeException * @expectedExceptionCode 2 */ public function testSet_invalidKey() { $this->bucket->set(self::GROUP, self::INVALID_KEY, self::VALUE_INT); }