From 082a493cc7831bf98b3100b01f1d51011f2b0d8f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 13 Mar 2017 15:16:17 +0100 Subject: [PATCH] Test fixes (working) --- Account/AccountMapper.php | 2 +- Message/Http/Request.php | 30 ++++++++++-------------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Account/AccountMapper.php b/Account/AccountMapper.php index 6153a710b..81062128e 100644 --- a/Account/AccountMapper.php +++ b/Account/AccountMapper.php @@ -40,7 +40,7 @@ class AccountMapper extends DataMapperAbstract 'account_name3' => ['name' => 'account_name3', 'type' => 'string', 'internal' => 'name3'], 'account_email' => ['name' => 'account_email', 'type' => 'string', 'internal' => 'email'], 'account_lactive' => ['name' => 'account_lactive', 'type' => 'DateTime', 'internal' => 'lastActive'], - 'account_created_at' => ['name' => 'account_created', 'type' => 'DateTime', 'internal' => 'createdAt'], + 'account_created_at' => ['name' => 'account_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], ]; protected static $hasMany = [ diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 78959a11e..a54376f26 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -103,6 +103,7 @@ class Request extends RequestAbstract { if (!isset($this->uri)) { $this->initCurrentRequest(); + $this->lock(); } $this->data = array_change_key_case($this->data, CASE_LOWER); @@ -112,8 +113,6 @@ class Request extends RequestAbstract $this->path = explode('/', $this->uri->getPath()); $this->setupUriBuilder(); - $this->createRequestHashs(); - $this->lock(); } /** @@ -214,39 +213,30 @@ class Request extends RequestAbstract /** * Create request hashs of current request * + * The hashes are based on the request path and can be used as unique id. + * + * @param int $start Start hash from n-th path element + * * @return void * + * @todo: maybe change to normal path string e.g. /some/path/here instead of hash! Remember to adjust navigation elements + * * @since 1.0.0 * @author Dennis Eichhorn */ - private function createRequestHashs() /* : void */ + public function createRequestHashs(int $start = 0) /* : void */ { $this->hash = []; foreach ($this->path as $key => $path) { $paths = []; - for ($i = 0; $i < $key + 1; $i++) { + for ($i = $start; $i < $key + 1; $i++) { $paths[] = $this->path[$i]; } - $this->hash[] = $this->hashRequest($paths); + $this->hash[] = sha1(implode('', $paths)); } } - /** - * Generate request hash. - * - * @param array $request Request array - * - * @return string - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - private function hashRequest(array $request) : string - { - return sha1(implode('', $request)); - } - /** * Is Mobile *