From 026a3d786abff51a6085e1aa5cfa7c2545d0fc22 Mon Sep 17 00:00:00 2001 From: Robin Krahnen Date: Tue, 3 Apr 2018 10:23:53 +0200 Subject: [PATCH 1/8] just some code and annotation cleanup --- Classes/Service/Exception.php | 3 --- Classes/Service/SequenceGenerator.php | 8 ++------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Classes/Service/Exception.php b/Classes/Service/Exception.php index 0a46197..4d1cd00 100644 --- a/Classes/Service/Exception.php +++ b/Classes/Service/Exception.php @@ -1,12 +1,9 @@ getPrevious() && $e->getPrevious() instanceof \PDOException) { // Do nothing, new Doctrine handling hides the above error - } - else { + } else { $this->systemLogger->logException($e); } } catch (\Exception $e) { @@ -126,9 +123,8 @@ class SequenceGenerator /** * @param string|object $stringOrObject * - * @throws Exception - * * @return string + * @throws Exception */ protected function inferTypeFromSource($stringOrObject) { From 27b3bd9af126aad17fab3f9164156e564fc63b30 Mon Sep 17 00:00:00 2001 From: Christian Krause Date: Tue, 3 Apr 2018 13:50:46 +0200 Subject: [PATCH 2/8] TASK: Apply migration DigiComp.SettingValidator-20170603120900 Restructures Validation.yamls to new format Note: This migration did not produce any changes, so the commit simply marks the migration as applied. This makes sure it will not be applied again. --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c08726b..b5eba4a 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,8 @@ "TYPO3.FluidAdaptor-20161130112935", "Neos.Media-20161219094126", "Neos.Flow-20170125103800", - "Neos.Flow-20170127183102" + "Neos.Flow-20170127183102", + "DigiComp.SettingValidator-20170603120900" ] } -} +} \ No newline at end of file From 029d5995774723a74ee24d05999dd623b6a30012 Mon Sep 17 00:00:00 2001 From: Robin Krahnen Date: Wed, 4 Apr 2018 09:26:23 +0200 Subject: [PATCH 3/8] reordered inline @var-doctypes --- Classes/Service/SequenceGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Service/SequenceGenerator.php b/Classes/Service/SequenceGenerator.php index 6a800bf..3df0193 100644 --- a/Classes/Service/SequenceGenerator.php +++ b/Classes/Service/SequenceGenerator.php @@ -64,7 +64,7 @@ class SequenceGenerator */ protected function validateFreeNumber($count, $type) { - /** @var $em EntityManager */ + /** @var EntityManager $em */ $em = $this->entityManager; try { $em->getConnection()->insert( @@ -107,7 +107,7 @@ class SequenceGenerator */ public function getLastNumberFor($type) { - /** @var $em EntityManager */ + /** @var EntityManager $em */ $em = $this->entityManager; $result = $em->getConnection()->executeQuery( From 1124d3626e6bfee4b513e4daab106940508ff8a2 Mon Sep 17 00:00:00 2001 From: Robin Krahnen Date: Wed, 4 Apr 2018 22:48:18 +0200 Subject: [PATCH 4/8] removed useless brackets --- Classes/Service/SequenceGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Service/SequenceGenerator.php b/Classes/Service/SequenceGenerator.php index 3df0193..cedfc92 100644 --- a/Classes/Service/SequenceGenerator.php +++ b/Classes/Service/SequenceGenerator.php @@ -97,7 +97,7 @@ class SequenceGenerator { $type = $this->inferTypeFromSource($type); - return ($this->validateFreeNumber($to, $type)); + return $this->validateFreeNumber($to, $type); } /** From 5465b3933289d40cbe2542890ffd9be81e955c06 Mon Sep 17 00:00:00 2001 From: Robin Krahnen Date: Wed, 4 Apr 2018 23:39:03 +0200 Subject: [PATCH 5/8] do not save value into variable if it's only returned afterwards --- Classes/Service/SequenceGenerator.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Classes/Service/SequenceGenerator.php b/Classes/Service/SequenceGenerator.php index cedfc92..63cbde4 100644 --- a/Classes/Service/SequenceGenerator.php +++ b/Classes/Service/SequenceGenerator.php @@ -110,14 +110,10 @@ class SequenceGenerator /** @var EntityManager $em */ $em = $this->entityManager; - $result = $em->getConnection()->executeQuery( + return $em->getConnection()->executeQuery( 'SELECT MAX(number) AS count FROM digicomp_sequence_domain_model_insert WHERE type=:type', ['type' => $this->inferTypeFromSource($type)] - ); - $count = $result->fetchAll(); - $count = $count[0]['count']; - - return $count; + )->fetchAll()[0]['count']; } /** From 8fa1e1089ee995e8c0673001031298f7ecdb78a9 Mon Sep 17 00:00:00 2001 From: Robin Krahnen Date: Wed, 4 Apr 2018 23:48:06 +0200 Subject: [PATCH 6/8] use entity manager to resolve class table name --- Classes/Service/SequenceGenerator.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Classes/Service/SequenceGenerator.php b/Classes/Service/SequenceGenerator.php index 63cbde4..fd65201 100644 --- a/Classes/Service/SequenceGenerator.php +++ b/Classes/Service/SequenceGenerator.php @@ -1,6 +1,7 @@ entityManager; try { $em->getConnection()->insert( - 'digicomp_sequence_domain_model_insert', + $em->getClassMetadata(Insert::class)->getTableName(), ['number' => $count, 'type' => $type] ); return true; @@ -111,7 +112,7 @@ class SequenceGenerator $em = $this->entityManager; return $em->getConnection()->executeQuery( - 'SELECT MAX(number) AS count FROM digicomp_sequence_domain_model_insert WHERE type=:type', + 'SELECT MAX(number) AS count FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type=:type', ['type' => $this->inferTypeFromSource($type)] )->fetchAll()[0]['count']; } From da9d014c9d6b731335daf05331ddcb276c732267 Mon Sep 17 00:00:00 2001 From: Robin Krahnen Date: Wed, 4 Apr 2018 23:50:19 +0200 Subject: [PATCH 7/8] optimized query for getLastNumberFor function --- Classes/Service/SequenceGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Service/SequenceGenerator.php b/Classes/Service/SequenceGenerator.php index fd65201..9dcc82f 100644 --- a/Classes/Service/SequenceGenerator.php +++ b/Classes/Service/SequenceGenerator.php @@ -112,9 +112,9 @@ class SequenceGenerator $em = $this->entityManager; return $em->getConnection()->executeQuery( - 'SELECT MAX(number) AS count FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type=:type', + 'SELECT MAX(number) FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type = :type', ['type' => $this->inferTypeFromSource($type)] - )->fetchAll()[0]['count']; + )->fetchAll(\PDO::FETCH_COLUMN)[0]; } /** From 2856fa764b864172ec85172654d827e541ed1625 Mon Sep 17 00:00:00 2001 From: Robin Krahnen Date: Thu, 5 Apr 2018 09:02:16 +0200 Subject: [PATCH 8/8] replaced doctype annotation in methods with comment --- Classes/Service/SequenceGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Service/SequenceGenerator.php b/Classes/Service/SequenceGenerator.php index 9dcc82f..3b1975b 100644 --- a/Classes/Service/SequenceGenerator.php +++ b/Classes/Service/SequenceGenerator.php @@ -65,7 +65,7 @@ class SequenceGenerator */ protected function validateFreeNumber($count, $type) { - /** @var EntityManager $em */ + /* @var EntityManager $em */ $em = $this->entityManager; try { $em->getConnection()->insert( @@ -108,7 +108,7 @@ class SequenceGenerator */ public function getLastNumberFor($type) { - /** @var EntityManager $em */ + /* @var EntityManager $em */ $em = $this->entityManager; return $em->getConnection()->executeQuery(