From 1435d90fa87da34fabf762557de84916d361b5fd Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 3 Jan 2022 19:34:28 +0400 Subject: [PATCH 1/3] Updating the isNew property false at retrieve and doc-bloc cleanup --- .../Database/Sleekdb/Statements/Result.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Libraries/Database/Sleekdb/Statements/Result.php b/src/Libraries/Database/Sleekdb/Statements/Result.php index bed33d90..9ca1a778 100644 --- a/src/Libraries/Database/Sleekdb/Statements/Result.php +++ b/src/Libraries/Database/Sleekdb/Statements/Result.php @@ -25,10 +25,8 @@ trait Result /** * @inheritDoc - * @throws \Quantum\Exceptions\DatabaseException * @throws \SleekDB\Exceptions\IOException * @throws \SleekDB\Exceptions\InvalidArgumentException - * @throws \SleekDB\Exceptions\InvalidConfigurationException */ public function get() { @@ -37,10 +35,8 @@ public function get() /** * @inheritDoc - * @throws \Quantum\Exceptions\DatabaseException - * @throws \SleekDB\Exceptions\IOException + * @return \Quantum\Libraries\Database\DbalInterface * @throws \SleekDB\Exceptions\InvalidArgumentException - * @throws \SleekDB\Exceptions\InvalidConfigurationException */ public function findOne(int $id): DbalInterface { @@ -48,16 +44,15 @@ public function findOne(int $id): DbalInterface $this->data = $result; $this->modifiedFields = $result; + $this->isNew = false; return $this; } /** * @inheritDoc - * @throws \Quantum\Exceptions\DatabaseException * @throws \SleekDB\Exceptions\IOException * @throws \SleekDB\Exceptions\InvalidArgumentException - * @throws \SleekDB\Exceptions\InvalidConfigurationException */ public function findOneBy(string $column, $value): DbalInterface { @@ -65,16 +60,16 @@ public function findOneBy(string $column, $value): DbalInterface $this->data = $result; $this->modifiedFields = $result; + $this->isNew = false; return $this; } /** * @inheritDoc - * @throws \Quantum\Exceptions\DatabaseException + * @return \Quantum\Libraries\Database\DbalInterface * @throws \SleekDB\Exceptions\IOException * @throws \SleekDB\Exceptions\InvalidArgumentException - * @throws \SleekDB\Exceptions\InvalidConfigurationException */ public function first(): DbalInterface { @@ -82,16 +77,15 @@ public function first(): DbalInterface $this->data = $result; $this->modifiedFields = $result; + $this->isNew = false; return $this; } /** * @inheritDoc - * @throws \Quantum\Exceptions\DatabaseException * @throws \SleekDB\Exceptions\IOException * @throws \SleekDB\Exceptions\InvalidArgumentException - * @throws \SleekDB\Exceptions\InvalidConfigurationException */ public function count(): int { From 1a69c899493557deafd66c39a470b70cfe3e48f7 Mon Sep 17 00:00:00 2001 From: armanist Date: Mon, 3 Jan 2022 21:50:13 +0400 Subject: [PATCH 2/3] Ignore the ID column in fillObjectProps() method --- src/Mvc/QtModel.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Mvc/QtModel.php b/src/Mvc/QtModel.php index 8edae8e5..5c3b30ea 100644 --- a/src/Mvc/QtModel.php +++ b/src/Mvc/QtModel.php @@ -83,13 +83,17 @@ public function setOrm(DbalInterface $orm) /** * Fills the object properties - * @param array $arguments + * @param array $props * @return \Quantum\Mvc\QtModel * @throws \Quantum\Exceptions\ModelException */ - public function fillObjectProps(array $arguments): QtModel + public function fillObjectProps(array $props): QtModel { - foreach ($arguments as $key => $value) { + foreach ($props as $key => $value) { + if ($key == $this->idColumn) { + continue; + } + if (!in_array($key, $this->fillable)) { throw ModelException::inappropriateProperty($key); } From a486791e223b62b83e6c49d0cfa8dceace90b8a8 Mon Sep 17 00:00:00 2001 From: armanist Date: Tue, 4 Jan 2022 01:18:30 +0400 Subject: [PATCH 3/3] Middlewares get lost on named routes and typo fixes --- src/Routes/Route.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Routes/Route.php b/src/Routes/Route.php index 5faaa8e2..58094dc6 100644 --- a/src/Routes/Route.php +++ b/src/Routes/Route.php @@ -35,17 +35,17 @@ class Route */ private $module; - /** + /**` * Identifies the group middleware * @var bool */ - private $isGroupeMiddlewares; + private $isGroupMiddlewares; /** * Identifies the group * @var boolean */ - private $isGroupe = false; + private $isGroup = false; /** * Current group name @@ -138,10 +138,10 @@ public function group(string $groupName, Closure $callback): self { $this->currentGroupName = $groupName; - $this->isGroupe = true; - $this->isGroupeMiddlewares = false; + $this->isGroup = true; + $this->isGroupMiddlewares = false; $callback($this); - $this->isGroupeMiddlewares = true; + $this->isGroupMiddlewares = true; $this->currentGroupName = null; return $this; @@ -154,7 +154,7 @@ public function group(string $groupName, Closure $callback): self */ public function middlewares(array $middlewares = []): self { - if (!$this->isGroupe) { + if (!$this->isGroup) { end($this->virtualRoutes['*']); $lastKey = key($this->virtualRoutes['*']); $this->virtualRoutes['*'][$lastKey]['middlewares'] = $middlewares; @@ -162,15 +162,14 @@ public function middlewares(array $middlewares = []): self end($this->virtualRoutes); $lastKeyOfFirstRound = key($this->virtualRoutes); - if (!$this->isGroupeMiddlewares) { + if (!$this->isGroupMiddlewares) { end($this->virtualRoutes[$lastKeyOfFirstRound]); $lastKeyOfSecondRound = key($this->virtualRoutes[$lastKeyOfFirstRound]); $this->virtualRoutes[$lastKeyOfFirstRound][$lastKeyOfSecondRound]['middlewares'] = $middlewares; } else { - $this->isGroupe = false; + $this->isGroup = false; foreach ($this->virtualRoutes[$lastKeyOfFirstRound] as &$route) { - $hasMiddleware = end($route); - if (!is_array($hasMiddleware)) { + if(!key_exists('middlewares', $route)) { $route['middlewares'] = $middlewares; } else { $reversedMiddlewares = array_reverse($middlewares); @@ -197,7 +196,7 @@ public function name(string $name): self throw RouteException::nameBeforeDefinition(); } - if ($this->isGroupeMiddlewares) { + if ($this->isGroupMiddlewares) { throw RouteException::nameOnGroup(); }